lsp

:clojure-lsp: Clojure implementation of the Language Server Protocol: https://clojure-lsp.io/
2021-05-21T15:37:16.013300Z

hi there! I tried to integrate clojure-lsp-native with sublime text but unfortunatelly getting strange exception filed it here - https://github.com/clojure-lsp/clojure-lsp/issues/430

flowthing 2021-05-22T08:20:55.032900Z

I've now deployed the latest version into Package Control, so instead of using the master branch, you can just update via Package Control. Probably need to restart ST. I've also updated the documentation at https://tutkain.flowthing.me/.

2021-05-21T15:37:43.013900Z

maybe someone already knows what is going on and how to fix this 🙂

ericdallo 2021-05-21T15:38:36.014Z

Hey! it seems a missing graalvm reflection config, I can fix it

ericdallo 2021-05-21T15:38:51.014200Z

meanwhile you can test wit with the JVM embedded binary

ericdallo 2021-05-21T15:39:34.014400Z

It seems other editors (vim, emacs, vscode ) doesn't use that class for some reason

ericdallo 2021-05-21T15:43:18.014600Z

@delaguardo Fixed on master, besides the option mentioned above, you can build a new image following https://clojure-lsp.github.io/clojure-lsp/building/ or wait for the next release which should be soon

2021-05-21T15:43:35.014900Z

so far I just download clojure-lsp.jar and use it like that: ["java", "-jar", "/path/to/jar"]

👍 1
2021-05-21T15:43:51.015100Z

wow 🙏 that was quick )

2021-05-21T15:43:57.015300Z

will test it right away )

2021-05-21T15:44:28.015500Z

thanks!

ericdallo 2021-05-21T15:45:29.015800Z

LMK if that works well with sublimeText 🙂

2021-05-21T16:43:23.016Z

no it complain about org.eclipse.lsp4j.MarkdownCapabilities I’ll fix it and make a PR later today. Will check if anything else is missing

ericdallo 2021-05-21T16:47:07.016200Z

Odd... Well, try to follow my commit and check if there is anything left, thanks!

flowthing 2021-05-21T16:54:56.017Z

On the subject of Sublime Text, I've been working on a Clojure package for ST for the past year or so. I've recently been migrating it off of nREPL to socket REPL and adding ClojureScript support (shadow-cljs only for now). If you're interested in trying it out, let me know.

2021-05-21T17:39:55.017300Z

Sure, definitely will try it out

2021-05-21T17:42:21.017500Z

Is it tutkain package? https://tutkain.flowthing.me/

2021-05-21T17:42:55.017700Z

Then I already using it) smooth sailing so far

2021-05-21T17:43:42.017900Z

Great job! :thumbsup_all:

flowthing 2021-05-21T17:59:31.018700Z

Yes, that’s it. 🙂 Are you using the master branch?

flowthing 2021-05-21T18:04:23.018900Z

Just asking because the version that's in Package Control still uses nREPL -- it's pretty old now and I'll be dropping nREPL support in the next version.

2021-05-21T18:10:42.019100Z

From package control, yes. I will try master branch, thanks

flowthing 2021-05-21T18:11:47.019300Z

OK, cool. Feel free to DM me if you come across any problems.

flowthing 2021-05-21T18:14:21.019700Z

I sadly didn't have the time to get everything into shape for the ST4 release, so no documentation yet, but the long and short of it is that just run Tutkain: Connect to connect to a Clojure, shadow-cljs, or a Babashka socket REPL, run Tutkain: Edit Key Bindings to see a bunch of example key bindings, copy-paste and edit what you need, and you should be off to the races.

👍 1
2021-05-21T21:15:51.025700Z

Hey guys, With lsp installed and enabled and - with my point in Emacs on one of the core clojure symbols like defonce, defn, or println - invoking lsp-find-definition takes a long while and the performance of cider-find-var has also regressed for me. In each instance, Emacs is blocked while a new LSP server seems to be starting up on a new port!

2021-05-22T20:47:39.036300Z

Hey @ericdallo, I debugged through the elisp code to see why it was doing so.

2021-05-22T20:48:31.036500Z

My lsp-session-file contained my ~/.emacs.d directory from my LSP use a while ago.

2021-05-22T20:49:08.036700Z

I fixed that by clearing the session file; a cleanup was useful for my purposes anyway. 🙂

2021-05-22T20:49:49.036900Z

That fixed the behaviour on lsp-find-definition.

2021-05-22T20:50:18.037100Z

However, it did not fix the issue with cider-find-var.

2021-05-22T20:52:00.037300Z

I noted that since the session file reset, I’ve only opened one project with LSP but it seems to have automagically added an entry for my home directory as well; I am guessing because of the cider-find-var invocation.

2021-05-22T20:52:40.037500Z

#s(lsp-session ("/Users/affan" "/Users/affan/scratch/clj/rdd-demo") nil #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data ()) #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data ()) #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data ()))

ericdallo 2021-05-22T20:53:06.037700Z

I always had issues with cider-find-var, sorry, maybe you can get that answer on #cider

ericdallo 2021-05-22T20:53:34.037900Z

Lsp-mode asks what's the root, you probably selected your home in the past

2021-05-22T20:53:48.038100Z

Can I reset that?

ericdallo 2021-05-22T20:54:14.038300Z

Yes, lsp-workspace-folders-remove I think

2021-05-22T20:54:37.038500Z

Ah, I’ll give that a shot. 🙂

2021-05-22T20:56:55.038700Z

Hm, after successful removal (both from the LSP completion list and the session file), it added it back in when I tried cider-find-var.

ericdallo 2021-05-22T20:59:35.038900Z

lsp-mode has nothing related with cider, that command only removes the folder as root, so next time you lsp it will ask what's the project root

ericdallo 2021-05-22T20:59:45.039100Z

The cider issue seems another issue

2021-05-22T21:01:57.039300Z

The reason this ends up related is because, like the recommended configuration, I’ve got lsp activated through clojure-mode-hook so when cider-find-var takes me to a new Clojure file, lsp kicks in.

2021-05-22T21:03:31.039600Z

And that’s when the session file is checked while deciding whether a new LSP server is needed. At any rate, I think I’ve worked out the cause for the home directory returning; this is because I’ve got lsp-auto-guess-root enabled and in that case projectile state also needs cleaning up.

ericdallo 2021-05-22T21:09:59.039900Z

I see now, yes, lsp-auto-guess-root is not enabled by default for those kind of issues, I suggest disable it indeed

2021-05-22T21:13:21.040100Z

Ah, I see. I followed your useful guide[1] amongst other resources but did not come across that.

ericdallo 2021-05-22T21:14:29.040600Z

Good point, maybe I should add a mention to that on there :)

2021-05-22T21:15:12.040800Z

That sounds good; thanks Eric :)

2021-05-22T21:17:02.041Z

I think I’d prefer lsp-find-definition but I’m running into a significant slowdown (and UI blocking) on the first access to a file like clojure.core.clj:

2021-05-22T21:17:22.041200Z

which-func-ff-hook error: (error "Timeout while waiting for response.  Method: textDocument/documentSymbol")

ericdallo 2021-05-22T21:18:45.041400Z

Hum, it should be fast to go to that file :thinking_face:

2021-05-22T21:19:01.041600Z

It seems like my generally useful which-func-mode is waiting for the symbol information from LSP (probably indirectly), hm…

2021-05-22T21:30:10.041800Z

I see; which-function creates the Imenu index for the buffer, if necessary.

2021-05-22T21:31:14.042Z

It does so in its find-file hook.

ericdallo 2021-05-22T21:32:49.042200Z

Hum, so It keeps requesting document-symbols

2021-05-22T21:35:05.042400Z

Hm, it times out but only on the clojure.core.clj file. At least, it’s fine on the small project files that I’ve tested lsp with so far. :)

2021-05-22T22:00:14.042600Z

I was able to resolve this by lowering which-func-maxout to 5000 with a setq-local for my clojure-mode-hook function.

ericdallo 2021-05-22T22:02:02.042800Z

Yeah, could you check your clojure-lsp.out log file? To get how much time it's taking the request

2021-05-22T22:05:58.043Z

Ah, that’ll be useful because while find-file is no longer blocking (and that timeout error’s gone), there’s still a significant period of UI blocking immediately after the file loads up.

2021-05-22T22:06:24.043200Z

I’ve got the log-path from lsp-clojure-server-info.

ericdallo 2021-05-22T22:06:45.043400Z

Yes, thats correct

2021-05-22T22:06:50.043600Z

It’s a 39 line file; what would be the best way of sharing it with you?

2021-05-22T22:07:23.043800Z

Thanks Eric 🙂

2021-05-22T22:10:36.044Z

I’ve created a Gist: https://gist.github.com/affan-salman/78568d35119bc483b8eeb899d4a32710

ericdallo 2021-05-22T22:17:58.044200Z

I can only see didOpen taking to much time, but I think it's ok since it's scanning clojure.core and it's a huge buffer

2021-05-22T22:18:10.044400Z

And here’s the original version -- without lowering which-func-maxout:

ericdallo 2021-05-22T22:19:02.044800Z

DocumentSymbol seems quite fast

2021-05-22T22:20:35.045Z

Right. 🙂 That ~28secs on didOpen does feel slightly painful. There’s a long while of UI not responding, of course 🙂

ericdallo 2021-05-22T22:31:07.045300Z

What do you mean with UI not responding?

2021-05-22T22:34:18.047100Z

I mean that trying to navigate in the file is prevented for a while. For instance, pressing C-n to move to the next line does not respond.

2021-05-22T22:34:45.047600Z

Input queued for a while.

ericdallo 2021-05-22T22:56:56.047800Z

Hum, that shouldn't happen as lsp-mode is just starting/opening a file, it shouldn't block emacs

ericdallo 2021-05-22T22:57:53.048Z

You can try understand if it is some package of yours via lsp-start-plain.el

2021-05-22T23:05:08.049600Z

Ah, cool … I’ll be able to resume tomorrow and this will be a useful starting point. Thanks, @ericdallo 🙃

👍 1
2021-05-24T19:00:08.051600Z

Hi @ericdallo, I resolved the remaining part of it by setting lsp-enable-imenu to nil. (Without it, which-function is triggered which waits on LSP thus freezing Emacs.)

ericdallo 2021-05-24T19:24:54.051900Z

Nice, I intend to spend some time taking a look on performance, that should help this issue as well

2021-05-24T19:30:05.052100Z

That sounds good. Thanks Eric :)

ericdallo 2021-05-21T21:17:59.025800Z

Do you have both lsp-mode and clojure-lso udpated?

ericdallo 2021-05-21T21:18:32.026300Z

we had a recent change that made use the lib as the same workspace avoiding connecting a new clojure-lsp as a new workspace

2021-05-21T21:19:46.028100Z

Thanks @ericdallo; I updated all my Emacs packages today. I’ll check the version and let you know.

2021-05-21T21:20:49.028900Z

Emacs package manager is using lsp-mode-<tel:2021052|2021052>1.446

2021-05-21T21:23:47.029800Z

I’m using the latest clojure-lsp release (2021.05.14-15.26.02) on macOS.

2021-05-21T21:28:00.031400Z

The “new workspace” path, in the case of lsp-find-definition, ends up being ~/.emacs.d/workspace/.cache/.

2021-05-21T21:28:56.032100Z

And in CIDER’s case, ~/.m2/repository/org/clojure/clojure/1.10.2/clojure-1.10.2.jar:clojure/.

ericdallo 2021-05-21T21:39:42.032400Z

yes, I think that's correct

ericdallo 2021-05-21T21:40:00.032600Z

it should not start a new workspace session