Fork me on GitHub
#lsp
<
2021-07-26
>
practicalli-johnny11:07:08

Is there a correct way of restarting the LSP server from emacs? I tried lsp-workspace-restart and the server starts, but I am unable to do things like renaming a namespace? I get the error Connected Server does not support naming When hovering over the little rocket in the powerline, it says clojure-lsp/42334334/starting Perhaps its not fully starting because of my dodgy code 🙂 The server seems to stop at some point after as I've had to restart a couple of times. Any suggestions ?

lassemaatta12:07:32

Have you peeked the logs under /tmp/clojure-lsp*?

ericdallo12:07:50

☝️ exactly, the way to restart is correct, but the server is not starting because some issue, check the server log https://clojure-lsp.github.io/clojure-lsp/troubleshooting/#getting-server-log

practicalli-johnny13:07:55

The logs are not brimming with information

2021-07-26T11:31:25.985Z statsbomb INFO [clojure-lsp.main:391] - Starting server...
2021-07-26T11:31:25.989Z statsbomb INFO [clojure-lsp.nrepl:21] - ====== LSP nrepl server started on port 41953
2021-07-26T11:54:40.868Z statsbomb INFO [clojure-lsp.main:345] - Shutting down

ericdallo13:07:45

Yeah, no exceptions or error logs, could you check the clojure-lsp stderr emacs buffer?

practicalli-johnny13:07:17

Ah, there is some nastyness in that buffer...

ericdallo13:07:37

any exceptions?

ericdallo13:07:49

messages about "request cancellation" are ok

practicalli-johnny13:07:52

Jul 24, 2021 11:53:39 AM org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer fireError
SEVERE: Unable to invoke no-args constructor for class org.eclipse.lsp4j.CodeLensWorkspaceCapabilities. Registering an InstanceCreator with Gson for this type may fix this problem.
java.lang.RuntimeException: Unable to invoke no-args constructor for class org.eclipse.lsp4j.CodeLensWorkspaceCapabilities. Registering an InstanceCreator with Gson for this type may fix this problem.
This is the start of a long stacktrace 🙂

ericdallo13:07:22

alright, that's what I was expecting

ericdallo13:07:30

it's a reflection missing for graalvm

ericdallo13:07:14

the problem though, is that we already have that reflection config, are you using latest clojure-lsp?

ericdallo13:07:24

what's your clojure-lsp --version ?

practicalli-johnny13:07:01

Doh, I've move to a new computer and it doesnt look like clojure-lsp binary is installed on the execution path.

ericdallo13:07:05

it should work after version , but I recommend you update to latest

ericdallo13:07:22

so lsp-mode is using some old clojure-lsp?

ericdallo13:07:06

you can force lsp-mode reinstalling latest clojure-lsp with C-u M-x lsp-install-server clojure-lsp

practicalli-johnny13:07:19

downloaded and workspace initialised successfully... thank you.

practicalli-johnny13:07:38

Now its telling me how many bugs I have in my code :rolling_on_the_floor_laughing:

practicalli-johnny13:07:51

but thats not your problem

ericdallo13:07:10

nice hahah thank god no 😛

practicalli-johnny13:07:24

Very useful troubleshooting though, thank you.

practicalli-johnny16:07:46

I found an interesting Emacs edge case for lsp when adding a new file and automatically inserting the namespace 1. Existing project open (probably the same on a new project) 2. Use helm find-file to create a new file in a directory that does not yet exist 3. The buffer is created and a mini-buffer prompt asks if the directory should be created 3.1 At this time LSP (the UI I guess) is trying to add the ns expression to the buffer, however, the buffer is somehow switched to read-only mode 4. In the mini-buffer, confirm the creation of the new directory for the file 5. change the new clojure buffer to be writable and continue hacking. This has only happened once so far and not really a big issue. I can raise an issue somewhere if you think there is merrit?

ericdallo16:07:25

I can't not repro that, it works perfect to me, your issue seems your buffer being marked as read only, not sure why

ericdallo16:07:27

anyway, it seems to be a lsp-mode (not UI) issue/question, I suggest you ask on their Discord channel, they may help you understand why this is happening for you

ericdallo16:07:40

but doesn't seems to be a issue in the code though

ericdallo16:07:05

it could be a helm issue maybe, as with ivy that works to me

practicalli-johnny16:07:21

Thanks for the insight about possible areas to look into. I'll investigate further if it happens again. Thanks.

👍 2
practicalli-johnny21:07:50

Another curiosity, when using a namespace with a zero at the end of the name, e.g. practicalli.auth0 Creating a file for this namespace, lsp does insert a namespace form, but seems to not be able to parse the actual namespace correctly. Instead it inserts (ns Wrong type argument: stringp, nil) I think I've seen this when adding a dev/user.clj file and wonder if its lsp or an underlying Java classpath issue. yasnippets also seems to struggle with auth0 namespace when using the ns snippet. Probably quite an edge case anyway.

ericdallo21:07:00

An edge case indeed, but we can debug it to check where the bug is, client or server side

ericdallo21:07:37

But I can't repro that as well, it works to me...

ericdallo21:07:07

you can check lsp mode client<->server json logs to confirm server returned a correct code after the didOpen request

practicalli-johnny12:07:26

Is that the same logs as /tmp/clojure.xxxxxxxxxxx