Fork me on GitHub
#lsp
<
2021-11-07
>
hugod17:11:36

Would anyone have an emacs minor mode that adds keybindings for clojure-lsp’s refactorings?

ericdallo17:11:08

Any reason why not always rely/use code actions instead of manually calling the refactors?

hugod17:11:23

how do you do that?

ericdallo17:11:35

lsp-execute-code-action

ericdallo17:11:42

it should show all available code actions for that line

ericdallo17:11:16

if your refactor is not on that list it's because it wouldn't work, so code actions are more reliable

hugod17:11:08

Ok, I guess I’m not understanding the difference between a code action and a refactoring.

ericdallo17:11:04

from LSP eyes, there is only code actions, clojure-lsp exposes the refactorings but you don't need to call it manually

hugod17:11:15

s-l l a vs s-l l r

ericdallo17:11:40

I don't know what those keybindings mean

ericdallo17:11:21

my suggestion is to use code actions as they will have all the refactorings and it has a better UX

hugod17:11:06

Using lsp-mode’s keymap, it has a for actions and r for refactor. Know I know refactorings are under code actions, I can find them 🙂

ericdallo17:11:26

Oh, I got your question from lsp-mode code, the refactors are: lsp-organize-imports (that is a code action under the hood) lsp-rename which is not a code action, it's a LSP feature called rename

ericdallo17:11:36

so the refactor name is just something lsp-mode calls

hugod17:11:31

confusion removed - thank you!

hugod17:11:04

and the latest release is so much more responsive - a big thank you for that too

ericdallo17:11:17

cool! glad to hear it

dpsutton17:11:38

I made a hydra that’s quite helpful

ericdallo17:11:40

IMO keybindings for the clojure-lsp commands (refactorings) were useful when clojure-lsp didn't has the code actions feature, now IMO you can always rely on code actions

ericdallo17:11:24

because if clojure-lsp return that code action, it's known that it will work if you call it, but if you call the refactoring manually, you need to know if that will work

dpsutton17:11:06

i had to turn off the ui that shows the code actions everywhere. it was too noisy and unfortunately it would cause lots of "jumps" in the code when it introduces a new line for the actions

ericdallo17:11:23

you don't need to have lsp-ui to have code actions :)

ericdallo17:11:40

code-actions are something from lsp-mode, lsp-ui just adds UI things for that

dpsutton17:11:10

ah right. i guess i'm not sure what indicates there are code actions available

ericdallo17:11:18

there is also the code-actions for modeline if you like it, it's way less noisy:

dpsutton17:11:47

oh i like that

ericdallo18:11:32

When then I call lsp-execute-code-action:

ericdallo18:11:01

BTW I have also disabled the lsp-ui codea ctions, the modeline icon is way better to me :)

ericdallo18:11:34

I actually added that icon support for lsp-mode because I didn't like the noisy lsp-ui code actions as well :p

mpenet18:11:47

I am not using lsp-ui at all (tried a few times, always ended up removing it). I wonder if there's anything must have I am missing. It seems most features have a more lightweight equivalent without it

ericdallo18:11:56

yes, I personally only use lsp-ui-sideline-diagnostics

mpenet18:11:02

I usually get diagnostics with consult+embark. How does it look?

mpenet18:11:10

I can try tomorrow

mpenet18:11:23

Oh it's a sideline thing. I am not fond of that display, but that's quite personal

mpenet18:11:12

Oops it's a thread, sorry for highjacking

ericdallo20:11:00

Yeah, I just use lsp-ui-sideline-diagnostics because I don't know any other alternative that shows me the diagnostics of the current line without the need to move the cursor to the diagnostics itself, I like that lsp-ui shows me when I'm on the same line