From 9ffe4ca26ce473d165e2fb925c6dedf7abad1591 Mon Sep 17 00:00:00 2001 From: Ilya Bobyr Date: Wed, 3 Feb 2021 18:49:59 -0800 Subject: 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. --- docs/user/manual.adoc | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'docs/user/manual.adoc') diff --git a/docs/user/manual.adoc b/docs/user/manual.adoc index 93bf6d678..a1018b0cb 100644 --- a/docs/user/manual.adoc +++ b/docs/user/manual.adoc @@ -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 <>. -- cgit v1.2.3