@ericdallo Not sure if this is a good idea, but would it be possible to activate showing the docstring / arg position when pressing TAB when writing a function call like (foo [TAB])
Hum, if lsp supports the tab char, I think so
isn't this the same key that activates completions?
Yes, for vanilla Emacs yes, so not sure that could has some conflict
clojure-lsp seems to be having a problem with code like this:
(def foo
{:foo :bar
#?@(:clj
[:baz :quux])})
@ericdallo 2021.03.01-19.18.54
no longer shows the exception in the log but auto-completion still does not work when there’s a splicing reader conditional in the file
Not a big deal for me, just an FYI 🙂
I see, yeah, that probably would only be possible to fix with rewrite-cljc, we will need to wait for the v1 branch
The log shows an exception: java.lang.IllegalArgumentException: No value supplied for key: (read-string "#?@(:clj\n [:baz :quux])")
Hum, yes, it'd failing to return the code actions
BTW, is this form correct? I get a missing-map-value clj-kondo error
It works fine in .cljc
files. Maybe it’s a clj-kondo issue?
The result should be {:foo :bar, :baz :quux}
…for Clojure of course, just {:foo :bar}
for CLJS
oh I was not in cljc file, my bad 😅
yes, so it's a clojure-lsp issue indeed to get the code actions for that piece of code
Actually it could be a rewrite-clj issue on parding that code
Yeah, rewrite-clj is in the stack trace
this doesn't work for me:
(z/of-string "{:foo :bar
#?@(:clj
[:baz :quux])}")
@lee Am I missing anything? 😅
Hum, probably related with the fact that clojure-lsp use clj-commons/rewrite-clj
and not https://github.com/lread/rewrite-cljc-playground
probably we may need to wait @lee work on merging rewrite-cljc with rewrite-clj?
Maybe… I just tried your sample above in rewrite-clj v1 branch and got not exceptions.
nice, exited to see that v1 get merged 🙂
I toil daily :simple_smile:
Just to make sure I understand, you were just expecting that the above be parseable, right?
yes
And it throws for you on rewrite-clj v0?
yep
@jkrasnay feel free to open a clojure-lsp issue so we can close it after using rewrite-clj v1
Will do. Thanks, you guys rock!
coolio!
My clojure lsp server is not starting.. This is the message I get
Server clojure-lsp:5242 status:starting exited with status exit. Do you want to restart it? (y or n) y
It was working a couple days agao
check https://clojure-lsp.github.io/clojure-lsp/troubleshooting/#server-is-not-initializing
download latest version from Github releases
how did you installed it?
what is the clojure-lsp --version
./clojure-lsp --help
clojure-lsp 2021.02.26-13.58.48
clj-kondo 2021.02.14-SNAPSHOT
Downloaded the latest this morning
using the install-script from github
running on macos
hum, we need to check why it's crashing, anything from the log file?
thankyou will checkout the troubleshooting guide…
oh.. where is the log file?
for most system is on /tmp/clojure-lsp.*.out
hmm.. no log file there…
probably it's in another path so, you can specify the log path in clojure-lsp settings
ohk.. I’ll try that
with log-file
setting
Do you recall what was the version before the issue?
if you used the script, probably there is a backup version on ~/bin
I missed. that
previously I installed manually
ok
so we need to check the log to find the exception
Interesting, on reading through the troubleshooting page. It says runing clojure-lsp executable should print the following
{}
Apr 12, 2019 7:07:02 AM org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer fireError
SEVERE: Missing header Content-Length in input "{}
"
java.lang.IllegalStateException: Missing header Content-Length in input "{}""""
Mine prints nothing, just hangstest it with your editor
when it crash, check the logs again
sorry, my bad.. read the doc wrong… my executable seems to work
./clojure-lsp
{}
Feb 27, 2021 8:54:36 AM org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer fireError
SEVERE: Missing header Content-Length in input "{}
"
java.lang.IllegalStateException: Missing header Content-Length in input "{}
"
oh, probably lsp-mode is not finding clojure-lsp
are you using Emacs?
yes
alright
check here: https://emacs-lsp.github.io/lsp-mode/tutorials/clojure-guide/
you need to configure lsp-clojure-custom-server-command
to point to the ~/bin/clojure-lsp
executable
that’s there.. I have configured it
do I have to specify log-file in config.edn ?
https://github.com/ericdallo/dotfiles/blob/master/.lsp/config.edn
yes
ohk thnku
oh sorry, there is no log-file
setting 😅
That's something that I want to add
you can get the log-file but only after server initialized 😕
I think for some macos the log file is persisted in some weird folder /var/... https://clojurians.slack.com/archives/CPABC1H61/p1613922700052500?thread_ts=1613921955.048800&cid=CPABC1H61
hmm that might be the http://java.io.tmpdir ? which is usually some random path under /var …
Exactly
I will add today a flag to pass the log file to help debug those cases
But only available on next release, probably tomorrow
thku
this is the log
Starting server...
DEBUG [clojure-lsp.nrepl:24] - nrepl not found, skipping nrepl server start...
found TMPDIR from env vars and then greped for lsp
Nice, any exceptions on it?
Found the problem. I had to set
lsp-clojure-server-command ‘(“bash” “-c” “/Users/rratti/bin/clojure-lsp”)
instead of lsp-clojure-custom-server-command '("bash" "-c" "/Users/rratti/bin/clojure-lsp")
the manual mentions
(setq lsp-clojure-custom-server-command '("bash" "-c" "/path/to/clojure-lsp"))
Here: https://emacs-lsp.github.io/lsp-mode/tutorials/clojure-guide/
Oh, it's wrong indeed
Sorry for that, will fix it, thank you!
thks, It works great now!
@rdsr both variable should work, lsp-clojure-server-command is deprecated in favor of lsp-clojure-custom-server-command
https://github.com/emacs-lsp/lsp-mode/blob/master/clients/lsp-clojure.el#L36-L39
You probably have a lsp-mode outdated?
Wanted: Some elisp or emacs config which allows me to bind a function to M-. which uses cider (without prompting for a symbol) and when it doesn't find the var, falls back to lsp-find-definition (or vice versa, whatever gets me to the function)
This is great -- I needed this too, but I had to add
(define-key cider-mode-map (kbd "M-.") #'find-definition)
Possibly because I had set up
(clojure-mode . cider-mode)
in cider?Maybe something like this:
(defun find-definition ()
"Try to find definition of cursor via LSP otherwise fallback to cider."
(interactive)
(let ((cursor (point)))
(lsp-find-definition)
(when (eq cursor (point))
(cider-find-var))))
Almost, I think. It redirects me to the right definition, but is still going to invoke the cider one too
I updated the code
it seems to work for me
oh you updated ok
yep, works!
Now I must override the key binding
nice 🙂
How do I do this for clojure-mode?
I think:
(define-key clojure-mode-map (kbd "M-.") #'find-definition)
aaaaah....
I’ll check
This will not work if the definition is in another buffer. Updated:
(defun find-definition ()
"Try to find definition of cursor via LSP otherwise fallback to cider."
(interactive)
(let ((cursor (point))
(buffer (current-buffer)))
(lsp-find-definition)
(when (and (eq buffer (current-buffer))
(eq cursor (point)))
(cider-find-var))))
ok, updating