Search code examples
emacsclojureautocompletespacemacs

How make spacemacs with clojure layer to complete function in dependency automatic


As titile, my use spacemacs and add clojure layer. And I add a dependency in project.clj, but it cannot complete the function automatic.

Here is some of my configuration:

dotspacemacs-configuration-layers
'(
 (auto-completion :variables
                  auto-completion-enable-help-tooltip t
                  auto-completion-enable-snippets-in-popup t
                  auto-completion-enable-sort-by-usage t)
 better-defaults
 emacs-lisp
 (git :variables
      git-magit-status-fullscreen t
      git-enable-github-support t
      git-gutter-use-fringe t)
 github
 markdown
 org
 syntax-checking
 version-control
 clojure
 )

When I import a dependency, I do not know which function it offers, so I want to emacs help me to complete automatic, or is there someway else to achieve my goals.

Thanks.


Solution

  • When you require a dependency give it a name like this:

    (ns example.core
      (:require [com.ok.my-library :as library])
      ... )
    

    then in your code when you type

    library/
    

    spacemacs/emacs will create the drop down of names offered by that namespace. adding the :as name-here is generally a help to others exploring your code later as well.

    If your emacs is not populating that list that would be a problem independent of this one (both need solving).