You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.org
+44-9Lines changed: 44 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,15 +6,24 @@
6
6
7
7
This package makes use of clj-kondo's analysis data to provide code editing facilities related to Clojure, ClojureScript and cljc source. This means you get advanced editing features like auto-complete without the need for a connected REPL, because clj-kondo performs its magic using static source code analysis.
8
8
9
-
Currently, it gives you contextual auto-completion using completion-at-point, which works without a REPL connected, since it relies on clj-kondo's static source analysis. It will list out all available Vars, Ns and Aliases in a given buffer.
9
+
Current Features:
10
10
11
-
It supports the notion of projects, using projectile and Clojure's tools.deps. This means it'll pick up the buffer's current project root using projectile, and it will use Clojure's tools.deps to get the project's classpath. If it can't find either, it'll only auto-complete within the buffer, it won't be able to show candidates from the required dependencies.
11
+
+ It gives you contextual auto-completion using completion-at-point, which works without a REPL connected, since it relies on clj-kondo's static source analysis. It will list out all available Vars, Ns and Aliases in a given buffer.
12
+
+ It can also perform locals completion, using an Emacs implemented heuristic completion based on dabbrev that works really well in practice and can handle unbalanced code.
13
+
+ It can also complete Java classes and their static methods and fields. It does so by relying on jar and javap JDK command line binaries.
14
+
+ It supports the notion of projects, using projectile and Clojure's tools.deps. This means it'll pick up the buffer's current project root using projectile, and it will use Clojure's tools.deps to get the project's classpath. If it can't find either, it'll only auto-complete within the buffer, it won't be able to show candidates from the required dependencies.
12
15
13
16
* Screenshots
14
17
15
-
#+CAPTION: Example completion using anakondo
18
+
#+CAPTION: Example Clojure global Vars and namespace completion using anakondo
@@ -35,17 +44,38 @@ It supports the notion of projects, using projectile and Clojure's tools.deps. T
35
44
36
45
** Prerequisites
37
46
38
-
Anakondo needs the Clojure CLI tools.deps and clj-kondo to be installed and accessible from Emacs in order to run properly. To do so:
47
+
For Clojure[Script] completion, Anakondo needs the Clojure CLI tools.deps and clj-kondo to be installed and accessible from Emacs in order to run properly. To do so:
39
48
40
49
1. Install clj-kondo by following its [[https://github.com/borkdude/clj-kondo/blob/master/doc/install.md][install instructions]].
41
50
2. Make sure =clj-kondo= is in your shell's ~PATH~.
42
51
3. Install the Clojure CLI tools.deps by following its [[https://clojure.org/guides/getting_started#_clojure_installer_and_cli_tools][install instruction]].
43
52
4. Make sure the =clojure= CLI is in your shell's ~PATH~.
44
-
5. Now proceed with one of the following strategies to install the anakondo package in your Emacs.
53
+
54
+
For Java completion, you also need to be sure that you have a JDK installed and that its ~/bin~ folder is on the environment PATH used by Emacs.
45
55
46
56
** MELPA
47
57
48
-
Not in MELPA yet, but should be coming soon.
58
+
1. Run: ~M-x package-install anakondo~
59
+
2. Now put this in your init file:
60
+
+ If you want to pre-load it:
61
+
#+BEGIN_SRC elisp
62
+
;; Load anakondo to make available its minor mode in clojure buffers
63
+
(require 'anakondo)
64
+
#+END_SRC
65
+
+ If you want to lazy load it:
66
+
#+BEGIN_SRC elisp
67
+
;; Delays loading of anakondo until a clojure buffer is used
68
+
(autoload 'anakondo-minor-mode "anakondo")
69
+
#+END_SRC
70
+
71
+
** use-package
72
+
73
+
Put this in your in your init file:
74
+
#+begin_src emacs-lisp :tangle yes
75
+
(use-package anakondo
76
+
:ensure t
77
+
:commands anakondo-minor-mode)
78
+
#+end_src
49
79
50
80
** Manual
51
81
@@ -94,7 +124,7 @@ If you are also using Cider, the order in which you add the hooks matters in the
94
124
1. If you add anakondo to the Clojure mode hooks first, then completion will first try to use anakondo's, and only if it can't complete the form will it then try to use Cider's completion. This means if you try to complete a keyword for example, it'll fallback to Cider's, but for completing symbols it won't, even if it finds no candidates.
95
125
2. Otherwise, if you add Cider to the Clojure mode hooks first, then completion will first try to use Cider's, and only if Cider completion is not available, because there is no connected REPL, will it then fallback to try anakondo's completion. If Cider completion is available (because you have a REPL connected), it will never fallback to trying anakondo's completion, even if Cider doesn't find any completion candidates.
96
126
97
-
*Currently, I recommend adding anakondo after Cider*. This will make it so when no REPL is connected, you have anakondo's clj-kondo based static analysis completion. While when a REPL is running, you have Cider's completion, which currently gives you more information and includes locals and java classes. If you do it the other way around, when a REPL is running, if anakondo find completions you will only see the ones it found, which would be missing local bindings and java classes. I'll be exploring options to have the completions merged in the future, so we get the best of both worlds.
127
+
*Currently, I recommend adding anakondo after Cider*. This will make it so when no REPL is connected, you have anakondo's clj-kondo based static analysis completion. While when a REPL is running, you have Cider's completion. If you do it the other way around, when a REPL is running, if anakondo find completions you will only see the ones it found. I'll be exploring options to have the completions merged in the future, so we get the best of both worlds.
98
128
99
129
This also goes if you turn on/off the modes manually, except in that case, order and effect are reversed. The last mode you turn on will be the one who is in charge of completion first. While with the hooks, it is the first mode you add to the hook that will be in charge of completion first.
100
130
@@ -105,6 +135,11 @@ This also goes if you turn on/off the modes manually, except in that case, order
105
135
+ If dependency completion isn't working, remember that =anakondo= only supports =tools.deps= for now, if you don't have a =deps.edn= for your project, it will pick up your global =deps.edn= instead, it won't use your lein =project.clj= or boot =build.boot= dependencies.
106
136
+ If you've disabled cider-mode, and somehow anakondo completion stopped working, this is because of a known bug in cider-mode, which removes all configured completion for the buffer, not just its own, I am trying to get this fixed in cider as well.
107
137
+ If you've killed the REPL, and somehow anakondo completion doesn't seem to be starting back up, this is also due to a bug in cider, where it deletes all configured completion for the buffer on repl quit. I am trying to get this fixed in cider as well.
138
+
+ For Java completions of the default imports, they are going to be the ones defined by Clojure 1.10. So if you use an older or newer version of Clojure, you'll still see the completion of the imports from Clojure 1.10. So don't take it as a source of truth.
139
+
+ The list of Java classes you get completed comes from the boot classpath specified by the =java= command which is on your environment PATH, and the Java dependencies defined in your project's deps.edn. So if you use Java 8, you will see the Java 8 standard classes, if you use Java 11, you will see Java 11's standard classes, etc.
140
+
+ Only Java classes coming from a Jar on your boot classpath and classpath will be completed. If you have =.class= files in your boot classpath or classpath they will not be completed for now. So if you depend on Java dependencies, make sure it is through a Jar, and not a folder containing =.class= files if you want completion for them.
141
+
+ To auto-complete the static methods and fields of a Java class, type =/= after the class and call your completion function, such as completion-at-point or company-indent-or-complete-common, etc.
142
+
+ Java static methods and fields completion doesn't work with custom imports for now, only fully qualified and default imports will get completion.
108
143
109
144
* Changelog
110
145
:PROPERTIES:
@@ -116,7 +151,7 @@ This also goes if you turn on/off the modes manually, except in that case, order
116
151
Additions
117
152
+ Add support for locals auto-completion
118
153
+ Add support for Java classes auto-completion (fully qualified + default imports only for now) (can only complete from jars on the classpath, no support for class files on the classpath for now)
119
-
+ Add support for Java static methods and fields auto-completion on press of `/`
154
+
+ Add support for Java static methods and fields auto-completion on press of =/=
120
155
121
156
Changes
122
157
+ Much faster auto-completion when using "as you type" completion like company-mode
@@ -126,7 +161,7 @@ Fixes
126
161
127
162
Internal
128
163
+ Added a buffer local cache of completion candidates which keeps track of the completion list for the last start positions of completions, makes "as you type" completions much faster
129
-
+ Infers Java boot classpath by using the `java` command itself
164
+
+ Infers Java boot classpath by using the =java= command itself
130
165
+ Uses dabbrev with some custom heuristic to identify symbols and syntax-ppsp for locals completion
131
166
+ Uses javap to find available static methods and fields for a given class
132
167
+ Uses jar to find all classes in the classpath jars
0 commit comments