Fork me on GitHub
#lsp
<
2021-11-28
>
Sophie17:11:49

Hey everybody, I am using clojure-lsp with emacs and I have noticed that I cannot use the rename action on code I have just written even if I save the file. I get a nil from the lsp as an answer. Has someone else here encountered something similar or point me in a direction to debug this?

ericdallo17:11:35

No, where you are seeing the nil?

ericdallo17:11:03

Could you get both client and server logs?

Sophie17:11:22

I saw it in the answer of the lsp in the logs.

Sophie17:11:01

I will reproduce it really quick, one second

ericdallo17:11:01

Do you have a updated clojure-lsp? Some recent version we introduced client errors support, which we return to clietn why a operation could not be made

Sophie17:11:08

I have the following builds installed:

clojure-lsp 2021.09.30-15.28.01
clj-kondo 2021.09.25

Sophie17:11:22

Response I get:

Received response 'textDocument/rename [...]
Result: null

Sophie17:11:13

Can I set the log level for the clojure-lsp.xxxxxxx.out logs? All I see in there is :rename 0ms for the event

ericdallo17:11:26

Please update your clojure-lsp, we fixed rename related issues that should fix your issue

ericdallo17:11:54

latest version should not print null anymore

ericdallo18:11:02

I think it'll work for you

Sophie18:11:13

I think I found a potential problem. How is the project root determined? It set the project root to be /home/.../foo but the project.clj and src dir are in /home/.../foo/bar.

ericdallo18:11:26

yeah, that will cause issues indeed

Sophie18:11:28

Does the emacs lsp mode set the project root?

ericdallo18:11:37

the project-root is determined by client (lsp-mode)

ericdallo18:11:42

try lsp-workspace-folders-remove

πŸ‘ 1
ericdallo18:11:53

and then lsp and choose the correct project root with I

Sophie18:11:58

Thank you so much! It worked ☺️

murtaza21:12:45

This had been bugging me for a while and I had the same problem of having an incorrect lsp workspace. I could never figure out that was causing renames to not work.

ericdallo22:12:04

Yeah, I will add that to the troubleshooting section

πŸ‘ 1