Vim docs: vim-lsp with initial configuration.

`vim-lsp` is another popular LSP client for Vim.  And, as there is no
`rust-analyzer` specific UI, it is non-trivial to figure out how the
initial configuration is performed.
This commit is contained in:
Ilya Bobyr 2021-02-03 18:49:59 -08:00
parent 6781692732
commit 9ffe4ca26c

View file

@ -307,6 +307,52 @@ EOF
See https://sharksforarms.dev/posts/neovim-rust/ for more tips on getting started.
==== vim-lsp
vim-lsp is installed by following https://github.com/prabirshrestha/vim-lsp[the plugin instructions].
It can be as simple as adding this line to your `.vimrc`:
[source,vim]
----
Plug 'prabirshrestha/vim-lsp'
----
Next you need to register the `rust-analyzer` binary.
If it is available in `$PATH`, you may want to add this to your `.vimrc`:
[source,vim]
----
if executable('rust-analyzer')
au User lsp_setup call lsp#register_server({
\ 'name': 'Rust Language Server',
\ 'cmd': {server_info->['rust-analyzer']},
\ 'whitelist': ['rust'],
\ })
endif
----
There is no dedicated UI for the server configuration, so you would need to send any options as a value of the `initialization_options` field, as described in the <<_configuration,Configuration>> section.
Here is an example of how to enable the proc-macro support:
[source,vim]
----
if executable('rust-analyzer')
au User lsp_setup call lsp#register_server({
\ 'name': 'Rust Language Server',
\ 'cmd': {server_info->['rust-analyzer']},
\ 'whitelist': ['rust'],
\ 'initialization_options': {
\ 'cargo': {
\ 'loadOutDirsFromCheck': v:true,
\ },
\ 'procMacro': {
\ 'enable': v:true,
\ },
\ },
\ })
endif
----
=== Sublime Text 3
Prerequisites: You have installed the <<rust-analyzer-language-server-binary,`rust-analyzer` binary>>.