lsp-mode
Table of Contents
:ID: 040AE749-B677-4481-A65B-19FB842CE227
https://emacs-lsp.github.io/lsp-mode/ https://develop.spacemacs.org/layers/+lang/ruby/README.html#language-server-protocol
# Selecting language servers
If there are multiple installed, the highest priority will win. To select the server you want independent of priority you can do this:
(add-to-list 'lsp-disabled-clients 'ruby-ls) ;; solargraph (add-to-list 'lsp-enabled-clients 'ruby-lsp-ls) ;; ruby-lsp (shopify's thing)
# Typescript / Javascript
# Setup
Followed these instructions https://emacs-lsp.github.io/lsp-mode/page/lsp-typescript/ for ls-ts Node dependencies needed:
- typescript-language-server
- typescript
Weirdly, I got an error that it couldn’t find typescript even though it was installed globably and was in my path. I had to copy the node module into the emacs npm cache:
cp -R .config/yarn/global/node_modules/typescript spacemacs/.cache/lsp/npm/typescript
# Ruby
There are a bunch of options for LSP servers. You can have multiple servers and the one used can be specified in a dir-local file See also emacs-lsp FAQ
# Ruby LSP
https://github.com/Shopify/ruby-lsp
2023-08-04: I tried it but it didn’t appear to have jump to definition or any features for that matter.
# Solargraph
It doesn’t require yard, but it can help it out.
# Setup
Just follow the instructions linked above. For spacemacs, set the ruby-mode
backend to 'lsp
- Rails
Use the solargraph-rails plugin. When using this you’ll need to include
"**/*.rb"
and use the exclude directive in the .solargraph.yml
# Features
- autocompletion
- other things…
cmd | description |
---|---|
lsp-ui-peek-jump-backward | Moves cursor back to the previous location |
lsp-ui-peek-jump-forward | Moves cursor back to the next location |
lsp-ui-peek-find-references | Shows a list of where something is used in the code |
lsp-ui-peek-find-definitions | Navigate to definition of thing at point |
lsp-describe-thing-at-point | Shows documentation |
# Vue2
Install vls
# Issues
When trying to start vls:
Error: Cannot find module 'vscode-css-languageservice/lib/umd/data/browsers'
# Performance
I had performance issues with LSP mode, especially with Typescript.
See https://emacs-lsp.github.io/lsp-mode/page/performance/ for suggestions.
I increased the read-process-output-max
to 3mb and that seemed to help.
I was already using emacs v28, so I just rebuild it with native comp. There was some pain making the transition, but it completely solved the performance issues.
See https://xenodium.com/emacs-plus-with-native-comp/ and https://github.com/d12frosted/homebrew-emacs-plus#emacs-27-and-emacs-28-options