Fork me on GitHub
#lsp
<
2021-05-21
>
delaguardo15:05:16

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

flowthing16:05:56

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.

delaguardo17:05:55

Sure, definitely will try it out

delaguardo17:05:55

Then I already using it) smooth sailing so far

flowthing17:05:31

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

flowthing18:05:23

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.

delaguardo18:05:42

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

flowthing18:05:47

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

flowthing18:05:21

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.

👍 3
flowthing08:05:55

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/.

delaguardo15:05:43

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

ericdallo15:05:36

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

ericdallo15:05:51

meanwhile you can test wit with the JVM embedded binary

ericdallo15:05:34

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

ericdallo15:05:18

@U04V4KLKC 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

delaguardo15:05:35

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

👍 2
delaguardo15:05:51

wow 🙏 that was quick )

delaguardo15:05:57

will test it right away )

ericdallo15:05:29

LMK if that works well with sublimeText 🙂

delaguardo16:05:23

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

ericdallo16:05:07

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

Affan Salman21:05:51

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!

ericdallo21:05:59

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

ericdallo21:05:32

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

Affan Salman21:05:46

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

Affan Salman21:05:49

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

Affan Salman21:05:47

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

Affan Salman21:05:00

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

Affan Salman21:05:56

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

ericdallo21:05:42

yes, I think that's correct

ericdallo21:05:00

it should not start a new workspace session

Affan Salman20:05:39

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

Affan Salman20:05:31

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

Affan Salman20:05:08

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

Affan Salman20:05:49

That fixed the behaviour on lsp-find-definition.

Affan Salman20:05:18

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

Affan Salman20:05:00

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.

Affan Salman20:05:40

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

ericdallo20:05:06

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

ericdallo20:05:34

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

Affan Salman20:05:48

Can I reset that?

ericdallo20:05:14

Yes, lsp-workspace-folders-remove I think

Affan Salman20:05:37

Ah, I’ll give that a shot. 🙂

Affan Salman20:05:55

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.

ericdallo20:05:35

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

ericdallo20:05:45

The cider issue seems another issue

Affan Salman21:05:57

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.

Affan Salman21:05:31

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.

ericdallo21:05:59

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

Affan Salman21:05:21

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

ericdallo21:05:29

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

Affan Salman21:05:12

That sounds good; thanks Eric :)

Affan Salman21:05:02

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:

Affan Salman21:05:22

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

ericdallo21:05:45

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

Affan Salman21:05:01

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

Affan Salman21:05:10

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

Affan Salman21:05:14

It does so in its find-file hook.

ericdallo21:05:49

Hum, so It keeps requesting document-symbols

Affan Salman21:05:05

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

Affan Salman22:05:14

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

ericdallo22:05:02

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

Affan Salman22:05:58

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.

Affan Salman22:05:24

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

ericdallo22:05:45

Yes, thats correct

Affan Salman22:05:50

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

Affan Salman22:05:23

Thanks Eric 🙂

ericdallo22:05:58

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

Affan Salman22:05:10

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

ericdallo22:05:02

DocumentSymbol seems quite fast

Affan Salman22:05:35

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

ericdallo22:05:07

What do you mean with UI not responding?

Affan Salman22:05:18

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.

Affan Salman22:05:45

Input queued for a while.

ericdallo22:05:56

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

ericdallo22:05:53

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

Affan Salman23:05:08

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

👍 3
Affan Salman19:05:08

Hi @UKFSJSM38, 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.)

ericdallo19:05:54

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

Affan Salman19:05:05

That sounds good. Thanks Eric :)