1 min read

Things that LSP can do

I found myself wondering today what features the Language Server Protocol (LSP) supports natively. PyCharm supports a few navigations/searches and refactors that I value. I'm curious if I can get the same effect using Emacs for C/C++ with a language server, rather than using VSCode, CLion, or XCode.

Some examples of PyCharm features I use:

  1. Completion.
  2. Go to definition.
  3. Go to usage.
  4. Show all usages.
  5. Go to superclass/subclass.
  6. Show method signature/parameters and documentation.
  7. Rename variable/method/class/etc. at point.
  8. Sometimes: Inline variable/method.
  9. Sometimes: Extract method.
  10. Rarely, but very useful when I do: Move variable/method/class/etc.

Here's what's in and out of the language server specification:

  1. Completion, of course.
  2. Go to definition/declaration.
  3. NOT: Go to usage. (Presumably the next feature would let you do it in the editor?)
  4. Show all usages via find all references and prepare call hierarchy request.
  5. Go to superclass/subclass maybe via prepare type hierarchy request.
  6. Show method signature/parameters and documentation via the same request, I think.
  7. Rename thing at point.
  8. NOT: Inline variable/method. Maybe doable using Monikers? Not easy though.
  9. NOT: Extract method. I don't see a way to do this.
  10. NOT: Move. As far as I can see, anyway. Maybe Monikers help?

From a quick search I don't see an easy way of doing 8 through 10 — but that doesn't mean there isn't one.