LSP mode key bindings

Hi!

What is your workflow when using lsp-mode? In particular, I am interested if you have setup specific key bindings. For example, if I want to see the references of a symbol, I have to type SPC c l g r, which is, well, not easy :). Other LSP functionality is also hidden under SCP c l, and the prefixes don’t have any help either.

Maybe there are more general functions with better bindings that use the functions provided by lsp-mode, if it is available. I know about +lookup/definition, which uses lsp-find-definition. Are there any others?

Finally, is there a way to jump to a definition/type/whatever in the OTHER window while keeping point at the current position?

So for references they also exist under SPC c d/SPC c D as well as g d/g D. Most of the others exist there too.

Finally, is there a way to jump to a definition/type/whatever in the OTHER window while keeping point at the current position?

I’d also like a good answer for this. I’ve debated adding an embark action for it, but I don’t know of a better way.

It’s an available in both Doom and vanilla Emacs as C-x 4 ..

Thank you! There is a lot more functionality available though in lsp-mode, and I think all those other things are hidden under SPC c l. For example, one can jump to the definition of the type of a symbol with SPC c l g t, or one can perform code actions SPC c l a. In my opinion, we should create a better key binding for lsp-mode actions (or provide better access to them from Doom default functions such as +lookup/definition).

Thanks. Should we set up a Doom-like equivalent for xref-find-definitions-other-window. For example +lookup/definition-other-window? I also suggest adding a nmemonic key binding.

For example, one can jump to the definition of the type of a symbol

g D/SPC c D

one can perform code actions

SPC c a

They’re all available elsewhere :slight_smile:

g D gives a list of references. I was talking about lsp-find-type-definition. This was just an example, but there is a lot of other stuff available.

I was not aware of SPC c a. I would say: Some of them are available elsewhere. I am suggesting having them somewhat more organized, and not behing SPC c l. If you disagree, please let me know, and probably provide a reason for your opinion!

There’s SPC h b b (embark-bindings/describe-bindings), they let you discover/search for key bindings, try typing “lsp” there to find what Doom binds by default.

About lsp-find-type-definition, I think its usage frequency is rare enough that SPC c l g t is fine. But you can of course propose your scheme by a PR, maybe instead of SPC c l g <char> we can shorten a key press to SPC c g <char> instead?

Thank you for pointing out SPC h b b. The bindings behind SCP c l do not show up there. Again, I was just picking lsp-find-type-definition as an example. There are tens of functions behind SPC c l, and I don’t know which ones are unique to lsp mode, which ones are used by other, more general functions (like +lookup/...).

I don’t have a particular solution in mind. I was more thinking about getting some ideas about how other people move around with (or without) lsp mode, and also other opinions.

The fact is, I am a bit annoyed at the status quo. The key bindings are not consistent, and it is not easy to find them. What usually works best for me is SPC h f and type what I want, and then I see the key binding in the help (but even there, the SCP c l g t binding does not show up). This workflow can be replaced using SCP h b b. But maybe we can come up with something better.

I think a PR on core bindings will not be successful unless there is some momentum and support behind it.