lsp

:clojure-lsp: Clojure implementation of the Language Server Protocol: https://clojure-lsp.io/
Eamonn Sullivan 2021-01-27T08:33:12.112500Z

I have a really silly question: If I'm just using clojure-lsp as normal in Emacs (i.e., letting it install itself automatically in .config/emacs/.cache/lsp) do I get new versions as they come out, or do I need to clear my cache periodically to get new versions?

Eamonn Sullivan 2021-01-27T08:44:01.112600Z

There doesn't seem to be an equivalent to lsp-java-update-server or lsp-csharp-update-server that I see?

codeasone 2021-01-27T09:59:45.112800Z

I place clojure-lsp in my ~/.local/bin which is on the path accessible to Emacs and it seems to prefer that, and not download a separate version to .config/emacs/.cache/lsp - this way I control the version being used, or I think I do 😉

Eamonn Sullivan 2021-01-27T10:17:00.113Z

I did do that originally, but that was when clojure-lsp wasn't automatically sorted by lsp-mode (it now offers to install it for you when you first open a Clojure project). I got tired of keeping that updated across the couple of laptops I use... Maybe I've just substituted one problem for another. :thinking_face:

ericdallo 2021-01-27T12:14:24.113400Z

ATM we don't have a automatic install, you can C-u lsp-install-server to force download latest clojure-lsp

Eamonn Sullivan 2021-01-27T12:58:59.113600Z

Perfect. Thank you!

Lucy Wang 2021-01-27T13:30:25.114300Z

File a clj-kondo bug relating to linting some cljc file https://github.com/clj-kondo/clj-kondo/issues/1148

ericdallo 2021-01-27T13:31:23.114700Z

👀

borkdude 2021-01-27T13:32:18.114900Z

Thanks, I'll look into it

Lucy Wang 2021-01-27T13:37:18.115100Z

Thanks!

borkdude 2021-01-27T13:54:29.115300Z

I found the issue. It has to do with redefining -> while also using cond-> which expands into -> but then it uses the wrong one... I'll fix it

borkdude 2021-01-27T13:54:36.115500Z

in promise.cljc

🚀 2
borkdude 2021-01-27T14:03:03.115800Z

Fixed with ebbf162bdf92702b662f7567afc5fa7b2fdd02af pushed to master.

Lucy Wang 2021-01-27T14:21:34.116100Z

Re-build clojure-lsp with latest clj-kondo, works like a charm!

👍 1
dharrigan 2021-01-27T15:34:10.116700Z

Observing an error with latest lsp (could be co-incidental)...

ericdallo 2021-01-27T15:34:23.116800Z

What error?

dharrigan 2021-01-27T15:34:28.117Z

dharrigan 2021-01-27T15:35:02.117400Z

It just spins, with the "initializing...." stuck

ericdallo 2021-01-27T15:35:08.117600Z

Oh, usually this happens when starting clojure-lsp manually and passing wrong json

dharrigan 2021-01-27T15:35:42.117800Z

it get's initialised by coc when I enter neovim with a clojure program

ericdallo 2021-01-27T15:36:00.118Z

anything on /tmp/clojure-lsp.out ?

dharrigan 2021-01-27T15:36:04.118200Z

"languageserver": {
    "clojure-lsp": {
      "command": "bash",
      "args": ["-c", "clojure-lsp"],
      "filetypes": ["clojure"],
      "disableDiagnostics": true,
      "rootPatterns": ["deps.edn", "project.clj"],
      "additionalSchemes": ["jar", "zipfile"],
      "trace.server": "verbose",
      "initializationOptions": {
        "project-specs": [{
          "project-path": "deps.edn",
          "classpath-cmd": ["clj", "-Spath"]
        }],
        "use-metadata-for-privacy?": true,
        "ignore-classpath-directories": true
      }
    }
  }

dharrigan 2021-01-27T15:36:28.118400Z

Yes, lots of these...

dharrigan 2021-01-27T15:36:32.118600Z

2021/01/27 15:33:04 2639895 ERROR clojure-lsp.crawler Cannot find position for: new {:name new, :filename "/home/david/devel>
2021/01/27 15:33:04 2639895 ERROR clojure-lsp.crawler Cannot find position for: fn* {:name fn*, :filename "/home/david/devel>
2021/01/27 15:33:04 2639895 DEBUG clojure-lsp.main :initialize 6493 ()

dharrigan 2021-01-27T15:36:49.118800Z

(ignore the devel chop, that's just my terminal)

ericdallo 2021-01-27T15:37:17.119Z

Those are expected

ericdallo 2021-01-27T15:37:30.119200Z

anything more related to the error?

dharrigan 2021-01-27T15:38:14.119400Z

Nothing much. this is the start of the session:

dharrigan 2021-01-27T15:38:18.119600Z

2021/01/27 15:32:57 2639895 INFO  clojure-lsp.main Starting server...
2021/01/27 15:32:57 2639895 INFO  clojure-lsp.main ====== LSP nrepl server started on port 43527
2021/01/27 15:32:57 2639895 INFO  clojure-lsp.main Initializing...
2021/01/27 15:32:57 2639895 WARN  clojure-lsp.db Could not load db path to '/home/david/development/workspaces/personal/clojure/kaocha/.lsp/sqlite.db': '/home/david/development/workspaces/personal/clojure/kaocha/.lsp' does not exist
2021/01/27 15:33:00 2639895 INFO  clojure-lsp.crawler Analyzing 23 paths with clj-kondo with batch size of  1 ...
2021/01/27 15:33:03 2639895 INFO  clojure-lsp.crawler Paths analyzed, took 3.68586 secs. Caching for next startups...
2021/01/27 15:33:04 2639895 INFO  clojure-lsp.crawler Paths analyzed, took 0.4616381 secs. Caching for next startups...

dharrigan 2021-01-27T15:38:28.119800Z

then lots of those errors as mentioned above

dharrigan 2021-01-27T15:39:04.120Z

Then on CoC

dharrigan 2021-01-27T15:39:06.120200Z

2021-01-27T15:32:55.059 INFO (pid:2639865) [language-client-index] - Language server "languageserver.clojure-lsp" started with 2639895
2021-01-27T15:33:04.394 ERROR (pid:2639865) [server] - uncaughtException Error: Header must provide a Content-Length property.
    at qw.onData (/home/david/.env/vim/bundle/coc.nvim/build/index.js:25:2759)
    at Socket.<anonymous> (/home/david/.env/vim/bundle/coc.nvim/build/index.js:25:2496)
    at Socket.emit (node:events:379:20)
    at addChunk (node:internal/streams/readable:313:12)
    at readableAddChunk (node:internal/streams/readable:288:9)
    at Socket.Readable.push (node:internal/streams/readable:227:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)
2021-01-27T15:38:53.577 INFO (pid:2639865) [attach] - receive notification: openLog []

dharrigan 2021-01-27T15:39:31.120400Z

maybe it's coc itself?

ericdallo 2021-01-27T15:40:12.120600Z

Yep, server is initializing correct, so coc is sending a wrong json probably

ericdallo 2021-01-27T15:40:27.120800Z

check coc logs, on emacs lsp-mode, it has a buffer with requests and response

dharrigan 2021-01-27T15:41:27.121Z

I trawled through the CoC issues and everyone who reports the content-length, the reply is "it's a bug of your language server"

ericdallo 2021-01-27T15:42:15.121200Z

hahaha :thinking_face:

dharrigan 2021-01-27T15:50:00.121400Z

now it worked.

dharrigan 2021-01-27T15:50:06.121600Z

hmmm, timing I suppose

ericdallo 2021-01-27T15:51:58.121800Z

tested latest with emacs and it works correctly too

dharrigan 2021-01-27T15:54:55.122Z

thanks. I'll put it down to a startup timing issue

👍 1
ericdallo 2021-01-27T16:47:34.122300Z

FYI https://github.com/clojure-lsp/clojure-lsp/issues/283

dharrigan 2021-01-27T17:09:28.122600Z

ah!

dharrigan 2021-01-27T17:09:31.122800Z

I'm not alone 🙂

😉 1
2021-01-27T19:45:01.123500Z

Yeah, I had the same issue haha, I thought it was only me.

dharrigan 2021-01-27T19:52:24.124Z

Updated the ticket.

ericdallo 2021-01-27T19:53:44.124200Z

I'll try to fix it tonight (couple of hours)

ericdallo 2021-01-27T20:50:57.124400Z

@snoe do you think just wrapping the kondo calls with with-out-str should be enough?

snoe 2021-01-27T21:33:24.124600Z

not sure - it's really where the output is coming from.... maybe the wrappers in main should do it

ericdallo 2021-01-27T21:34:58.124900Z

Oh, you mean wrap this run ? https://github.com/clojure-lsp/clojure-lsp/blob/master/src/clojure_lsp/main.clj#L450

ericdallo 2021-01-27T21:35:14.125200Z

this is kind of hard to test since I cannot reproduce the issue with emacs 😞

ericdallo 2021-01-27T21:40:52.125400Z

Ok, I may have found the issue, it was my mistake, a forgotten println :man-facepalming: https://github.com/clojure-lsp/clojure-lsp/blob/master/src/clojure_lsp/crawler.clj#L103

ericdallo 2021-01-27T21:41:41.125700Z

I'll remove it and try the with-out-str on run to avoid errors like this in the future

ericdallo 2021-01-27T21:47:55.125900Z

Fixed on latest release @dharrigan, thanks for the report!

dharrigan 2021-01-27T21:49:07.126100Z

Thank you! 🙂

dharrigan 2021-01-27T21:56:17.126300Z

Yup works. New version available on Arch 🙂

ericdallo 2021-01-27T21:56:30.126500Z

:nice: :clojure-lsp:

dharrigan 2021-01-27T21:56:45.126700Z

ttfn! bed time!

💤 1