Fork me on GitHub
#lsp
<
2021-02-27
>
borkdude10:02:42

@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])

ericdallo12:02:36

Hum, if lsp supports the tab char, I think so

borkdude12:02:35

isn't this the same key that activates completions?

ericdallo12:02:37

Yes, for vanilla Emacs yes, so not sure that could has some conflict

jkrasnay16:02:12

clojure-lsp seems to be having a problem with code like this:

(def foo
  {:foo :bar
   #[email protected](:clj
        [:baz :quux])})

ericdallo16:02:20

Hum, yes, it'd failing to return the code actions

ericdallo16:02:57

BTW, is this form correct? I get a missing-map-value clj-kondo error

jkrasnay16:02:47

It works fine in .cljc files. Maybe it’s a clj-kondo issue?

jkrasnay16:02:12

The result should be {:foo :bar, :baz :quux}

jkrasnay16:02:33

…for Clojure of course, just {:foo :bar} for CLJS

ericdallo16:02:10

oh I was not in cljc file, my bad 😅

ericdallo16:02:32

yes, so it's a clojure-lsp issue indeed to get the code actions for that piece of code

ericdallo16:02:19

Actually it could be a rewrite-clj issue on parding that code

jkrasnay16:02:31

Yeah, rewrite-clj is in the stack trace

ericdallo16:02:20

this doesn't work for me:

(z/of-string "{:foo :bar
              #[email protected](:clj
                  [:baz :quux])}")

ericdallo16:02:30

@UE21H2HHD Am I missing anything? 😅

ericdallo16:02:30

Hum, probably related with the fact that clojure-lsp use clj-commons/rewrite-clj and not https://github.com/lread/rewrite-cljc-playground

ericdallo16:02:50

probably we may need to wait @UE21H2HHD work on merging rewrite-cljc with rewrite-clj?

lread16:02:15

Maybe… I just tried your sample above in rewrite-clj v1 branch and got not exceptions.

ericdallo16:02:49

nice, exited to see that v1 get merged 🙂

lread16:02:03

I toil daily simple_smile

❤️ 3
lread16:02:35

Just to make sure I understand, you were just expecting that the above be parseable, right?

lread16:02:03

And it throws for you on rewrite-clj v0?

ericdallo16:02:38

@U0DTSCAUU feel free to open a clojure-lsp issue so we can close it after using rewrite-clj v1

jkrasnay16:02:40

Will do. Thanks, you guys rock!

thanks 3
ericdallo00:02:23

@U0DTSCAUU lastest clojure-lsp release should not fix the parsing issue but should avoid the exception during the code actions retrieval 🙂

jkrasnay00:02:59

Cool I'll give it a try. Moving house this weekend though so I might not get to it for a bit.

👍 3
jkrasnay00:03:34

@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

jkrasnay00:03:20

Not a big deal for me, just an FYI 🙂

ericdallo00:03:16

I see, yeah, that probably would only be possible to fix with rewrite-cljc, we will need to wait for the v1 branch

jkrasnay16:02:19

The log shows an exception: java.lang.IllegalArgumentException: No value supplied for key: (read-string "#[email protected](:clj\n [:baz :quux])")

rdsr16:02:47

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

ericdallo16:02:41

download latest version from Github releases

ericdallo16:02:54

how did you installed it? what is the clojure-lsp --version

rdsr16:02:14

./clojure-lsp --help
clojure-lsp 2021.02.26-13.58.48
clj-kondo 2021.02.14-SNAPSHOT

rdsr16:02:20

Downloaded the latest this morning

rdsr16:02:30

using the install-script from github

rdsr16:02:38

running on macos

ericdallo16:02:47

hum, we need to check why it's crashing, anything from the log file?

rdsr16:02:55

thankyou will checkout the troubleshooting guide…

rdsr16:02:01

oh.. where is the log file?

ericdallo16:02:00

for most system is on /tmp/clojure-lsp.*.out

rdsr16:02:07

hmm.. no log file there…

ericdallo16:02:31

probably it's in another path so, you can specify the log path in clojure-lsp settings

rdsr16:02:50

ohk.. I’ll try that

ericdallo16:02:57

with log-file setting

ericdallo16:02:18

Do you recall what was the version before the issue?

ericdallo16:02:39

if you used the script, probably there is a backup version on ~/bin

rdsr16:02:41

I missed. that

rdsr16:02:53

previously I installed manually

ericdallo16:02:14

so we need to check the log to find the exception

thanks2 3
rdsr16:02:52

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 hangs

ericdallo16:02:39

test it with your editor

ericdallo16:02:48

when it crash, check the logs again

rdsr16:02:21

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 "{}

"

ericdallo16:02:00

oh, probably lsp-mode is not finding clojure-lsp

ericdallo16:02:07

are you using Emacs?

ericdallo16:02:00

check here: https://emacs-lsp.github.io/lsp-mode/tutorials/clojure-guide/ you need to configure lsp-clojure-custom-server-command

ericdallo16:02:15

to point to the ~/bin/clojure-lsp executable

rdsr16:02:44

that’s there.. I have configured it

rdsr16:02:03

do I have to specify log-file in config.edn ?

rdsr16:02:39

ohk thnku

ericdallo17:02:17

oh sorry, there is no log-file setting 😅 That's something that I want to add

ericdallo17:02:35

you can get the log-file but only after server initialized 😕

rdsr17:02:45

hmm that might be the http://java.io.tmpdir ? which is usually some random path under /var …

ericdallo17:02:36

I will add today a flag to pass the log file to help debug those cases

ericdallo17:02:47

But only available on next release, probably tomorrow

rdsr17:02:59

this is the log

Starting server...
DEBUG [clojure-lsp.nrepl:24] - nrepl not found, skipping nrepl server start...

rdsr17:02:14

found TMPDIR from env vars and then greped for lsp

ericdallo18:02:58

Nice, any exceptions on it?

rdsr18:02:08

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")

rdsr18:02:18

the manual mentions

(setq lsp-clojure-custom-server-command '("bash" "-c" "/path/to/clojure-lsp"))

ericdallo18:02:54

Oh, it's wrong indeed

ericdallo18:02:02

Sorry for that, will fix it, thank you!

rdsr18:02:21

thks, It works great now!

ericdallo18:02:40

@U0AHTPQBG both variable should work, lsp-clojure-server-command is deprecated in favor of lsp-clojure-custom-server-command

ericdallo18:02:07

You probably have a lsp-mode outdated?

rdsr20:02:21

I’ll check

rdsr16:02:09

It was working a couple days agao

borkdude19:02:45

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)

ericdallo19:02:47

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))))

borkdude19:02:35

Almost, I think. It redirects me to the right definition, but is still going to invoke the cider one too

ericdallo19:02:08

I updated the code

ericdallo19:02:14

it seems to work for me

borkdude19:02:20

oh you updated ok

borkdude19:02:44

yep, works!

borkdude19:02:49

Now I must override the key binding

borkdude19:02:56

How do I do this for clojure-mode?

ericdallo19:02:11

I think:

(define-key clojure-mode-map (kbd "M-.") #'find-definition)

borkdude20:02:02

(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))))

(define-key clojure-mode-map (kbd "M-.") #'find-definition)
(define-key clojurec-mode-map (kbd "M-.") #'find-definition)
(define-key clojurescript-mode-map (kbd "M-.") #'find-definition)

🆒 3
👍 6
ericdallo22:02:03

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))))

borkdude22:02:51

ok, updating

Eamonn Sullivan16:03:33

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?

borkdude20:02:02

(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))))

(define-key clojure-mode-map (kbd "M-.") #'find-definition)
(define-key clojurec-mode-map (kbd "M-.") #'find-definition)
(define-key clojurescript-mode-map (kbd "M-.") #'find-definition)

🆒 3
👍 6