clojure-emacs / ac-nrepl Goto Github PK
View Code? Open in Web Editor NEW[DEPRECATED] Emacs auto-complete backend for nrepl completions
[DEPRECATED] Emacs auto-complete backend for nrepl completions
When enter something like "clojure.repl/", java.lang.ClassNotFoundException exception will be thrown. Here is a patch to fix that:
(Sorry the formatting is all messed up. Basically, Just one line is changed on "when-let" clause)
((defun ac-nrepl-candidates-static-methods ()
"Return static method candidates."
(ac-nrepl-candidates*
(ac-nrepl-filtered-clj
"(let [prefix \"%s\"]
(if-not (.contains prefix \"/\")
'()
(let [scope (symbol (first (.split prefix \"/\")))]
(map (fn [memb] (str scope \"/\" memb))
(when-let [class (try (complete.core/resolve-class scope) (catch java.lang.ClassNotFoundException e nil))]
(complete.core/static-members class)))))) ")))
An exception is thrown in the REPL, when completing a string that begins with a "/" character.
; nREPL 0.1.3
user> (println "/t")
results in the following exception after waiting for auto-completion pop-up:
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt (String.java:686)
clojure.lang.Compiler.maybeResolveIn (Compiler.java:6786)
clojure.core$ns_resolve.invoke (core.clj:3883)
clojure.core$ns_resolve.invoke (core.clj:3880)
clojure.core$resolve.invoke (core.clj:3889)
complete.core$resolve_class.invoke (core.clj:83)
complete.core$eval670$fn__671.invoke (core.clj:100)
clojure.lang.MultiFn.invoke (MultiFn.java:167)
complete.core$completions.invoke (core.clj:124)
user$eval713.invoke (NO_SOURCE_FILE:1)
clojure.lang.Compiler.eval (Compiler.java:6511)
clojure.lang.Compiler.eval (Compiler.java:6477)
clojure.core$eval.invoke (core.clj:2797)
clojure.main$repl$read_eval_print__6405.invoke (main.clj:245)
clojure.main$repl$fn__6410.invoke (main.clj:266)
clojure.main$repl.doInvoke (main.clj:266)
clojure.lang.RestFn.invoke (RestFn.java:1096)
clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__337.invoke (interruptible_eval.clj:51)
clojure.lang.AFn.applyToHelper (AFn.java:159)
clojure.lang.AFn.applyTo (AFn.java:151)
clojure.core$apply.invoke (core.clj:601)
clojure.core$with_bindings_STAR_.doInvoke (core.clj:1771)
clojure.lang.RestFn.invoke (RestFn.java:425)
clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invoke (interruptible_eval.clj:36)
clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__374$fn__376.invoke (interruptible_eval.clj:162)
clojure.core$comp$fn__4034.invoke (core.clj:2278)
clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__367.invoke (interruptible_eval.clj:129)
clojure.lang.AFn.run (AFn.java:24)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask (ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:908)
java.lang.Thread.run (Thread.java:662)
https://gist.github.com/dffbc82d523cf575e3e7
I really like the popup documentation that ac-nrepl gives you, but I wanted to be able to invoke it on-demand rather than only just when I've been autocompleted (see gist). I'm not sure if this is something that makes sense as a feature of ac-nrepl itself (maybe it should go up to nrepl mode instead?) but I thought I'd send the gist your way.
I have a buffer with contents:
#_(ns test)
(Double/)
With point behind /
, I get proper completion. Note that nothing has been sourced yet.
But if I uncomment the first form, I get Namespace not found
error when I try to complete.
After sourcing, the problem disappears.
It's a bit of a nuisance, since at the point when I need completion,
the code isn't in the valid state. And I'm currently just editing
within org-babel
source blocks, so I need to drop out of source block etc.
Now the text will show fully in the pop up, but the end of line "^M" are still there. Can be fixed with an extra replace-regexp-in-string "\r" "".
(defun ac-nrepl-documentation (symbol)
"Return documentation for the given SYMBOL, if available."
(substring-no-properties
(replace-regexp-in-string "\r" "" ;; remove "^M" on Windows
(replace-regexp-in-string
"^( |-------------------------\r?\n)" ""
(plist-get (nrepl-send-string-sync
(format "(clojure.repl/doc %s)" symbol)
(nrepl-current-ns))
:stdout)))))
If I attempt to display popup documentation with point on a thing for which there is nil documentation (e.g. a space) I get a strange message:
popup-tip: Wrong type argument: stringp, nil
Fix to follow...
Hi Steve,
if place the point at the bottom of a buffer, type "clojure.core$", and then press <UP>
, 12 newlines get inserted. Only happens in clojure-mode, not emacs-lisp-mode et al.
I am able to reproduce the issue with a minimal configuration which is available here: http://github.com/vemv/emacs-minimal
The workaround I found is performing (setq ac-quick-help-height 0)
. If you can reproduce the issue, perhaps you'd be interested in incorporating this knowledge to the readme.
Thank you - Victor
In my nrepl buffer, with ac-nrepl, *1 is not getting bound to the results of the last expression evaluated. Instead, it is always ().
More details on the nrepl forum at clojure-emacs/cider#200. There, we identified that the bug appears to be connected to ac-nrepl.
Setting up ac-nrepl causes the eshell (Emacs Shell) to no longer be able to cycle through completions, but instead always use the first possible completion.
This might have something to do with the completion-at-point
function
The error is:
java.lang.NullPointerException:
Reflector.java:296 clojure.lang.Reflector.invokeNoArgInstanceMember
core.clj:118 clj-stacktrace.core/parse-exception
repl.clj:106 clj-stacktrace.repl/pst-on
repl.clj:129 clj-stacktrace.repl/pst+
RestFn.java:408 clojure.lang.RestFn.invoke
Var.java:415 clojure.lang.Var.invoke
NO_SOURCE_FILE:2 user/eval7
Compiler.java:6511 clojure.lang.Compiler.eval
Compiler.java:6477 clojure.lang.Compiler.eval
core.clj:2797 clojure.core/eval
main.clj:245 clojure.main/repl[fn]
main.clj:266 clojure.main/repl[fn]
main.clj:266 clojure.main/repl
RestFn.java:1096 clojure.lang.RestFn.invoke
interruptible_eval.clj:51 clojure.tools.nrepl.middleware.interruptible-eval/evaluate[fn]
AFn.java:159 clojure.lang.AFn.applyToHelper
AFn.java:151 clojure.lang.AFn.applyTo
core.clj:601 clojure.core/apply
core.clj:1771 clojure.core/with-bindings*
RestFn.java:425 clojure.lang.RestFn.invoke
interruptible_eval.clj:36 clojure.tools.nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj:164 clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval[fn]
core.clj:2278 clojure.core/comp[fn]
interruptible_eval.clj:131 clojure.tools.nrepl.middleware.interruptible-eval/run-next[fn]
AFn.java:24 clojure.lang.AFn.run
(Unknown Source) java.util.concurrent.ThreadPoolExecutor$Worker.runTask
(Unknown Source) java.util.concurrent.ThreadPoolExecutor$Worker.run
(Unknown Source) java.lang.Thread.run
From time to time I get an error looking like the below. Most of the time everything works fine, and I haven't been able to determine exactly what triggers the error. I am using nREPL 0.1.8-preview and ac-nrepl 20130420.929.
Debugger entered--Lisp error: (args-out-of-range 1 143)
count-lines(143 1)
popup-create(143 69 20 :min-height 0 :around t :margin-left nil :margin-right nil :scroll-bar nil :face popup-tip-face :parent nil :parent-offset nil)
popup-tip("clojure.core/take\n([n coll])\nReturns a lazy sequence of the first n items in coll, or all items if\nthere are fewer than n.\n" :point 143 :height 20 :min-height 0 :around t :parent nil :parent-offset nil :point 143 :height 20 :nowait t)
apply(popup-tip "clojure.core/take\n([n coll])\nReturns a lazy sequence of the first n items in coll, or all items if\nthere are fewer than n.\n" :point 143 :height 20 :min-height 0 :around t :parent nil :parent-offset nil (:point 143 :height 20 :nowait t))
popup-menu-show-quick-help([cl-struct-popup 143 8 0 10 10 nil 1 [#<overlay from 146 to 146 in core.clj> #<overlay from 147 to 147 in core.clj> #<overlay from 148 to 148 in core.clj> #<overlay from 149 to 149 in core.clj> #<overlay from 150 to 150 in core.clj> #<overlay from 151 to 151 in core.clj> #<overlay from 152 to 152 in core.clj> #<overlay from 153 to 153 in core.clj> #<overlay from 154 to 154 in core.clj> #<overlay from 155 to 155 in core.clj>](keymap %28mouse-5 . ac-mouse-5%29 %28mouse-4 . ac-mouse-4%29 %28down-mouse-1 . ac-ignore%29 %28mouse-1 . ac-mouse-1%29 %2819 . ac-isearch%29 %2816 . ac-previous%29 %2814 . ac-next%29 keymap %28C-up . ac-quick-help-scroll-up%29 %28C-down . ac-quick-help-scroll-down%29 %2867108927 . ac-help%29 %28M-f1 . ac-persist-help%29 %28f1 . ac-help%29 %28up . ac-previous%29 %28down . ac-next%29 %2827 keymap %2857 . ac-complete-9%29 %2856 . ac-complete-8%29 %2855 . ac-complete-7%29 %2854 . ac-complete-6%29 %2853 . ac-complete-5%29 %2852 . ac-complete-4%29 %2851 . ac-complete-3%29 %2850 . ac-complete-2%29 %2849 . ac-complete-1%29 %2816 . ac-quick-help-scroll-up%29 %2814 . ac-quick-help-scroll-down%29 %2867108927 . ac-persist-help%29 %28112 . ac-previous%29 %28110 . ac-next%29 %289 . auto-complete%29%29 %28return%29 %2813%29 %28tab . ac-expand%29 %289 . ac-expand%29) nil 0 ac-candidate-face ac-candidate-mouse-face ac-selection-face popup-summary-face 1 0 nil t t 0 0 0 0 (#("take" 0 4 (selection-face ac-nrepl-selection-face popup-face ac-nrepl-candidate-face document ac-nrepl-documentation symbol "v")) #("take-nth" 0 8 (selection-face ac-nrepl-selection-face popup-face ac-nrepl-candidate-face document ac-nrepl-documentation symbol "v")) #("take-last" 0 9 (selection-face ac-nrepl-selection-face popup-face ac-nrepl-candidate-face document ac-nrepl-documentation symbol "v")) #("take-while" 0 10 (selection-face ac-nrepl-selection-face popup-face ac-nrepl-candidate-face document ac-nrepl-documentation symbol "v"))) 9 nil (#("take" 0 4 (selection-face ac-nrepl-selection-face popup-face ac-nrepl-candidate-face document ac-nrepl-documentation symbol "v")) #("take-nth" 0 8 (selection-face ac-nrepl-selection-face popup-face ac-nrepl-candidate-face document ac-nrepl-documentation symbol "v")) #("take-last" 0 9 (selection-face ac-nrepl-selection-face popup-face ac-nrepl-candidate-face document ac-nrepl-documentation symbol "v")) #("take-while" 0 10 (selection-face ac-nrepl-selection-face popup-face ac-nrepl-candidate-face document ac-nrepl-documentation symbol "v")))] nil :point 143 :height 20 :nowait t)
ac-quick-help()
apply(ac-quick-help nil)
byte-code("r\301�\302H�\303H"\210)\301\207" [timer apply 5 6] 4)
timer-event-handler([t 0 0 500000 0.5 ac-quick-help nil idle 0])
accept-process-output(nil 0.005)
nrepl-send-request-sync(("ns" "com.jayway.rps.core" "op" "eval" "session" "c6135125-2940-4693-bdaa-741f1e075b90" "code" "(require 'complete.core) (filter #(.startsWith % "ta")(complete.core/namespaces ns))"))
nrepl-send-string-sync("(require 'complete.core) (filter #(.startsWith % "ta")(complete.core/namespaces ns))" "com.jayway.rps.core" "c6135125-2940-4693-bdaa-741f1e075b90")
ac-nrepl-sync-eval("(require 'complete.core) (filter #(.startsWith % "ta")(complete.core/namespaces ns))")
ac-nrepl-candidates_("(filter #(.startsWith % "ta")(complete.core/namespaces *ns_))")
ac-nrepl-candidates-ns()
ac-candidates-1(((candidates . ac-nrepl-candidates-ns) (symbol . "n") (available . ac-nrepl-available-p) (candidate-face . ac-nrepl-candidate-face) (selection-face . ac-nrepl-selection-face) (prefix . ac-nrepl-symbol-start-pos) (document . ac-nrepl-documentation)))
ac-candidates()
ac-update(t)
ac-show-menu()
apply(ac-show-menu nil)
byte-code("r\301�\302H�\303H"\210)\301\207" [timer apply 5 6] 4)
timer-event-handler([t 0 0 400000 0.4 ac-show-menu nil idle 0])
please mind including your latest release version on the readme?
Hi -
I know this is a newbie question, but I have spend couple of days trying to figure this out and haven't been successful.
As the title says: auto-complete is not displaying popup-tip documentation while in clojure-mode, repl, or cider-mode. Here is my emacs configuration for clojure:
;----------------;
;;; Clojure ;;;
;----------------;
(require 'ac-nrepl)
(add-hook 'clojure-mode-hook 'paredit-mode)
(add-hook 'clojure-mode-hook 'rainbow-delimiters-mode)
(add-hook 'cider-repl-mode-hook 'paredit-mode)
(add-hook 'cider-repl-mode-hook 'rainbow-delimiters-mode)
(add-hook 'cider-repl-mode-hook 'ac-nrepl-setup)
(add-hook 'cider-mode-hook 'cider-turn-on-eldoc-mode)
(add-hook 'cider-mode-hook 'ac-nrepl-setup)
(eval-after-load "auto-complete"
'(add-to-list 'ac-modes 'cider-repl-mode))
(defun set-auto-complete-as-completion-at-point-function ()
(setq completion-at-point-functions '(auto-complete)))
(add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function)
(add-hook 'cider-repl-mode-hook 'set-auto-complete-as-completion-at-point-function)
(add-hook 'cider-mode-hook 'set-auto-complete-as-completion-at-point-function)
(eval-after-load "cider"
'(define-key cider-mode-map (kbd "C-c C-d") 'ac-nrepl-popup-doc))
(provide 'clojure-settings)
However, auto-complete is working fine while in other modes, example: Emacs Lisp mode.
I have attached couple of screen shots:
I think, I have followed the directions correctly, and have spent some trying to figure it out. But, now its just getting to the point of being frustrating.
I hope you can help me with this issue.
Thanks,
Sagun
Putting this here for future users who hit the same issue.
If you see the following on emacs startup.
Warning (emacs): Unable to activate package `ac-nrepl'.
Required package `cider-0.1' is unavailable
and ac-nrepl does not work after following the setup instructions, you
might have a broken package.el
lying about (if you've upgraded from emacs 23
to emacs 24 and have stuff lying around ~/.emacs.d)
an updated package.el
is bundled in emacs 24, try locating and removing
stale copies of it in ~/.emacs.d and restarting emacs.
I have a strange reproducable behaviour where ac-nrepl display nothing and java hogs up cpu.
ac-nrepl should now popup after a while but it doesn't. Java runs up to 100% on one core.
switch back to core.clj
C-c C-k to compile, the following stacktrace show up in nREPL:
clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: if-let in this context, compiling:(NO_SOURCE_PATH:1:1)
at clojure.lang.Compiler.analyze (Compiler.java:6380)
clojure.lang.Compiler.analyze (Compiler.java:6322)
clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3573)
clojure.lang.Compiler.analyzeSeq (Compiler.java:6562)
clojure.lang.Compiler.analyze (Compiler.java:6361)
clojure.lang.Compiler.analyze (Compiler.java:6322)
clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5708)
clojure.lang.Compiler$FnMethod.parse (Compiler.java:5139)
clojure.lang.Compiler$FnExpr.parse (Compiler.java:3751)
clojure.lang.Compiler.analyzeSeq (Compiler.java:6558)
clojure.lang.Compiler.analyze (Compiler.java:6361)
clojure.lang.Compiler.eval (Compiler.java:6616)
clojure.lang.Compiler.eval (Compiler.java:6582)
clojure.core$eval.invoke (core.clj:2852)
clojure.main$repl$read_eval_print__6588$fn__6591.invoke (main.clj:259)
clojure.main$repl$read_eval_print__6588.invoke (main.clj:259)
clojure.main$repl$fn__6597.invoke (main.clj:277)
clojure.main$repl.doInvoke (main.clj:277)
clojure.lang.RestFn.invoke (RestFn.java:1096)
clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__589.invoke (interruptible_eval.clj:56)
clojure.lang.AFn.applyToHelper (AFn.java:159)
clojure.lang.AFn.applyTo (AFn.java:151)
clojure.core$apply.invoke (core.clj:617)
clojure.core$with_bindings_STAR_.doInvoke (core.clj:1788)
clojure.lang.RestFn.invoke (RestFn.java:425)
clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invoke (interruptible_eval.clj:41)
clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__630$fn__633.invoke (interruptible_eval.clj:171)
clojure.core$comp$fn__4154.invoke (core.clj:2330)
clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__623.invoke (interruptible_eval.clj:138)
clojure.lang.AFn.run (AFn.java:24)
java.util.concurrent.ThreadPoolExecutor.runWorker (:-1)
java.util.concurrent.ThreadPoolExecutor$Worker.run (:-1)
java.lang.Thread.run (:-1)
;; startup package initialization early
;; disable loading packages after startup (again)
(setq package-enable-at-startup nil)
(package-initialize)
;; auto-complete
(require 'auto-complete-config)
(ac-config-default)
;; ac-nrepl
(require 'ac-nrepl)
(add-hook 'nrepl-mode-hook 'ac-nrepl-setup)
(add-hook 'nrepl-interaction-mode-hook 'ac-nrepl-setup)
(eval-after-load "auto-complete" '(add-to-list 'ac-modes 'nrepl-mode))
With ac-nrepl on, I notice a delay in responsiveness as I type.
The reason, I think, could be that it tries to talk to nrepl as I type,
and nrepl doesn't respond fast enough.
I've got ac-delay
on 0.1s, and it works great for e.g. ac-source-words-in-same-mode-buffers
or elisp stuff.
Is it possible to have ac-delay
on 0.1s for fast sources, and 0.5s for ac-nrepl sources?
Is it possible to choose to cache all completions and not to talk to nrepl at all?
Or, even better, start talking to nrepl only after a custom period of inactivity?
e.g. for def
, the pop-up shows:
Please see http://clojure.org/special_forms#def
but (doc def)
returns:
def
(def symbol doc-string? init?)
Special Form
Creates and interns a global var with the name
of symbol in the current namespace (*ns*) or locates such a var if
it already exists. If init is supplied, it is evaluated, and the
root binding of the var is set to the resulting value. If init is
not supplied, the root binding of the var is unaffected.
Please see http://clojure.org/special_forms#def
Hi purcell, I use your emacs.d for setting up clojure developing environment and it is awesome :-)
Recently I find ritz is powerful and maybe a good enhencement of nrepl.
The problem is after I use nrepl-ritz-jack-in
, ac-nrepl do not work.
But, after I start a new server by nrepl-jack-in
and switch back to the ritz server buffer, ac-nrepl partially
works(e.g. popup the choice list but not consist of all candidates).
So, I wander is it possible to use ac-nrepl with ritz?
I am using yasnippet along with auto complete and ac-nrepl.
When I start a fresh emacs session, open my .clj file, type something like def
, I see bunch of normal candidates and highlighted yasnippet's target. I can then tab
to complete or ret
to call yas-expand.
However, I noticed that after I start nrepl, and evaluate the (ns ...)
form of my clj file, I can no longer see yasnippet's target in auto-complete lists.
I than found out that if I comment out (add-to-list 'ac-sources 'ac-source-nrepl-vars)
in ac-nrepl-setup
, the yasnippet's target appears again.
Like the title says. I only get documentation (and function arguments) when in the repl buffer, not in source code. I do get general auto-completion though.
I see this when I attempt to auto-complete in a cider repl:
ac-nrepl-sync-eval: Symbol's function definition is void: nrepl-current-ns
I think this needs to be changed to cider-current-ns
, or maybe aliased in cider.
https://github.com/clojure-emacs/cider/blob/master/cider-interaction.el#L582
This falls back to eval if not present, but will now rely on the presence of the 'complete' nrepl op, which also works with clojurescript repls.
Backend impl is here:
https://github.com/gtrak/cider-nrepl/blob/master/src/cider/nrepl/middleware/complete.clj
Company mode is doing something similar:
https://github.com/clojure-emacs/company-cider/blob/master/company-cider.el#
Seems sensible to me since ac-nrepl's already relying on cider.
Using the latest nrepl.el and ac-nrepl packages from marmelade and with [org.clojure/tools.nrepl "0.2.2"] in my ~/.lein/profiles.clj, ac-nrepl will freeze whenever an autocomplete happens (triggered or automatic), freezing the nrepl/emacs UI along with it (without using extra CPU time I might add, and the rest of the system remains completely responsive).
The problem here is the 10+ secs it takes to do one autocomplete, not only making the feature defeat its own purpose, but effectively disabling proper typing in nrepl.el because of the automatic autocompletes while ac-nrepl is activated. This issue disappears on disabling ac-nrepl, prompting me to open an issue here as opposed to in nrepl.el.
The nrepl server is not on localhost, but on an android device I own, though that shouldn't be a problem as it never has been in the past.
In case it helps (TBH I don't really know if it's related), I found this entry in my Messages buffer when the latest AC was done:
Error in timer: (wrong-type-argument arrayp nil)
Use with cider. Normal complete works. Fuzzy complete not.
A sequence of (.l
auto-complete
e
gives:
.length [java.lang.String]
.length [java.lang.CharSequence]
.length [java.lang.StringBuffer]
.length [java.lang.StringBuilder]
Which is fine, but starting completion from (.le
gives:
(.length [java.lang.
instead of just expanding to (.length
.
There's some discussion about this issue here: clojure-emacs/cider#168
Where the issue is finally tracked down to some kind of interaction between the two hooks registered for nrepl-connected-hook
.
When ac-nrepl
's hook comes first and nrepl-connected-hook has the value: (ac-nrepl-refresh-class-cache nrepl-enable-on-existing-clojure-buffers), the second hook doesn't seem to get called (or at least doesn't have the desired effect).
If I manually reverse the order of the callbacks via (setq nrepl-connected-hook (reverse nrepl-connected-hook))
all works OK.
Not sure if this is ac-nrepl's or nrepl's fault, but suspect the former -- any ideas?
Cheers
My configuration of auto-complete is like this:
(setq ac-auto-start 3)
(setq ac-auto-show-menu .8)
so It will pop up completion menu automatically.but If I enable the sources provide by ac-nrepl, the auto-complete becomes very slow. Any solution to improve the performance?
Sporadically, Emacs crashes horribly on autocompleting the docstring of a Clojure var :-(
It's hard to figure out what's happening as I don't get a stacktrace or any other useful information, other than seeing Emacs just die.
I believe it's when the docstring is autocompleted due to the timing of the crash, but it's not completely obvious that this is the case - it's just something that appears to be the case.
To reproduce this, I just fire up nrepl within Emacs, and then type (re
and let it autocomplete to ref
and then wait for the docstring to appear. If the docstring appears, it didn't crash, so I simply delete the e
and retype it and see if it crashes. Rinse and repeat till it crashes. It's not a consistant number of times before a crash - it appears to be nondeterministic.
I have observed the following behaviours:
This is on a Mac running with the latest nrepl.el and latest ac-nrepl.el.
If there's anything I can do to help shed some light on this, please let me know.
Because of those Linux style line endings in the text (I am really annoyed that Clojure cannot get the doc text right across platforms. Not ac-nrepl's fault)
I just changed ac-nrepl-documentation function to the following:
(defun ac-nrepl-documentation (symbol)
"Return documentation for the given SYMBOL, if available."
(substring-no-properties
(replace-regexp-in-string "\r" "" ;; Fix Linux style line-ending on Windows
(replace-regexp-in-string
"^( |-------------------------\n)" ""
(plist-get (nrepl-send-string-sync
(format "(clojure.repl/doc %s)" symbol)
(nrepl-current-ns))
:stdout)))))
That fixed the issue on Windows. I did not test if the above will break on Linux.
This could be a configuration issue, but I have set up ac-nrep according to the instructions and although it works well for nrepl buffers, it ails on any clojure file.
The failure is:
When trying to complete something like clojure.set, the nrepl process will show this exception:
java.lang.ClassNotFoundException: clojure.set
at java.net.URLClassLoader$1.run (URLClassLoader.java:202)
java.security.AccessController.doPrivileged (AccessController.java:-2)
java.net.URLClassLoader.findClass (URLClassLoader.java:190)
clojure.lang.DynamicClassLoader.findClass (DynamicClassLoader.java:61)
java.lang.ClassLoader.loadClass (ClassLoader.java:306)
java.lang.ClassLoader.loadClass (ClassLoader.java:247)
java.lang.Class.forName0 (Class.java:-2)
java.lang.Class.forName (Class.java:247)
clojure.lang.RT.classForName (RT.java:2039)
clojure.lang.Compiler.maybeResolveIn (Compiler.java:6789)
clojure.core$ns_resolve.invoke (core.clj:3883)
clojure.core$ns_resolve.invoke (core.clj:3880)
clojure.core$resolve.invoke (core.clj:3889)
clojure.repl$doc.invoke (repl.clj:128)
clojure.lang.Var.invoke (Var.java:423)
clojure.lang.AFn.applyToHelper (AFn.java:167)
clojure.lang.Var.applyTo (Var.java:532)
clojure.lang.Compiler.macroexpand1 (Compiler.java:6366)
clojure.lang.Compiler.macroexpand (Compiler.java:6427)
clojure.lang.Compiler.eval (Compiler.java:6495)
clojure.lang.Compiler.eval (Compiler.java:6477)
clojure.core$eval.invoke (core.clj:2797)
clojure.main$repl$read_eval_print__6405.invoke (main.clj:245)
clojure.main$repl$fn__6410.invoke (main.clj:266)
clojure.main$repl.doInvoke (main.clj:266)
clojure.lang.RestFn.invoke (RestFn.java:1096)
clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__609.invoke (interruptible_eval.clj:51)
clojure.lang.AFn.applyToHelper (AFn.java:159)
clojure.lang.AFn.applyTo (AFn.java:151)
clojure.core$apply.invoke (core.clj:601)
clojure.core$with_bindings_STAR_.doInvoke (core.clj:1771)
clojure.lang.RestFn.invoke (RestFn.java:425)
clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invoke (interruptible_eval.clj:36)
clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__646$fn__648.invoke (interruptible_eval.clj:162)
clojure.core$comp$fn__4034.invoke (core.clj:2278)
clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__639.invoke (interruptible_eval.clj:129)
clojure.lang.AFn.run (AFn.java:24)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask (ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:908)
java.lang.Thread.run (Thread.java:680)
Hello, i installed everything as described, "AC" and "nREPL" modes enabled, but no signs of popups or something similar, how to debug what is wrong ?
init.el:
;; autocomplete
(add-to-list 'load-path "/.emacs.d") ; This may not be appeared if you have already added./.emacs.d/ac-dict")
(require 'auto-complete-config)
(ac-config-default)
(add-to-list 'ac-dictionary-directories "
;; nrepl
(require 'ac-nrepl)
(add-hook 'nrepl-mode-hook 'ac-nrepl-setup)
(add-hook 'nrepl-interaction-mode-hook 'ac-nrepl-setup)
(eval-after-load "auto-complete"
'(add-to-list 'ac-modes 'nrepl-mode))
Using the latest nrepl.el and ac-nrepl packages from marmelade and with [org.clojure/tools.nrepl "0.2.2"] in my ~/.lein/profiles.clj, ac-nrepl will freeze whenever an autocomplete happens (triggered or automatic), freezing the nrepl/emacs UI along with it (without using extra CPU time I might add, and the rest of the system remains completely responsive).
The problem here is the 10+ secs it takes to do one autocomplete, not only making the feature defeat its own purpose, but effectively disabling proper typing in nrepl.el because of the automatic autocompletes while ac-nrepl is activated. This issue disappears on disabling ac-nrepl, prompting me to open an issue here as opposed to in nrepl.el.
The nrepl server is not on localhost, but on an android device I own, though that shouldn't be a problem as it never has been in the past.
In case it helps (TBH I don't really know if it's related), I found this entry in my Messages buffer when the latest AC was done:
Error in timer: (wrong-type-argument arrayp nil)
I find that (require 'ac-nrepl)
pretty slows down the loading of .emacs (probably because it's dragging clojure/cider related dependencies at an early stage). Maybe it's better to suggest a "hooked" alternative as the preferred way to configure ac-nrepl.
Now I'm starting to see Emacs freeze on autocompleting stuff.
I see the following Clojure stacktrace, and Emacs hangs. I assume that Emacs is waiting for a reply from the Clojure process which isn't being received due to this error. If this is the case, perhaps it's worth looking into adding timeouts to the synchronous comms?
Exception in thread "nREPL-worker-1" java.lang.NullPointerException
at clojure.core$refer.doInvoke(core.clj:3775)
at clojure.lang.RestFn.applyTo(RestFn.java:139)
at clojure.core$apply.invoke(core.clj:602)
at clojure.core$load_lib.doInvoke(core.clj:5252)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:602)
at clojure.core$load_libs.doInvoke(core.clj:5271)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:604)
at clojure.core$use.doInvoke(core.clj:5363)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.main$repl.doInvoke(main.clj:258)
at clojure.lang.RestFn.invoke(RestFn.java:1096)
at clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__337.invoke(interruptible_eval.clj:51)
at clojure.lang.AFn.applyToHelper(AFn.java:159)
at clojure.lang.AFn.applyTo(AFn.java:151)
at clojure.core$apply.invoke(core.clj:600)
at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1769)
at clojure.lang.RestFn.invoke(RestFn.java:425)
at clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invoke(interruptible_eval.clj:36)
at clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__374$fn__376.invoke(interruptible_eval.clj:164)
at clojure.core$comp$fn__3758.invoke(core.clj:2276)
at clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__367.invoke(interruptible_eval.clj:131)
at clojure.lang.AFn.run(AFn.java:24)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
I've noticed lengthy slowdowns before while ac-nrepl is 'caching JVM class names', but recently found a show-stopper where this hangs indefinitely (I just left it overnight) after adding "(use 'clj-stacktrace.repl)" to :repl-options :init
in my .lein/profiles.clj
.
Not sure whether this is ac-nrepl's fault or clj-stacktraces (so I opened mmcgrana/clj-stacktrace#18 too), but in general it might be good to put some kind of timeout or limits on this caching business, or do it in a separate thread (no idea if this is possible!) since it seems to block the emacs UI pretty severely with a killall emacs24
being the only way I found to interrupt it.
(If it's doing something recursive, perhaps it needs some recursion depth limit or cycle avoidance logic?)
There is useful, non-ac-dependent code here that I'd rather not duplicate in a separate package. How should I go about using it in an nrepl completion back-end for company-mode, without forcing the users to install auto-complete (even automatically)?
I suggest removing the hard dependency, or extracting all non-ac-specific bits to another package (nrepl-mode?).
Pushing the Clojure code upstream might be an alternative, as suggested in #15.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.