All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 # vim-lsp [](https://gitter.im/vimlsp/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
3 Async [Language Server Protocol](https://github.com/Microsoft/language-server-protocol) plugin for vim8 and neovim.
7 Install [vim-plug](https://github.com/junegunn/vim-plug) and then:
10 Plug 'prabirshrestha/vim-lsp'
15 Certain bottlenecks in Vim script have been implemented in lua. If you would like to take advantage of these performance gains
16 use vim compiled with lua or neovim v0.4.0+
18 ## Registering servers
21 if executable('pylsp')
22 " pip install python-lsp-server
23 au User lsp_setup call lsp#register_server({
25 \ 'cmd': {server_info->['pylsp']},
26 \ 'allowlist': ['python'],
30 function! s:on_lsp_buffer_enabled() abort
31 setlocal omnifunc=lsp#complete
32 setlocal signcolumn=yes
33 if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
34 nmap <buffer> gd <plug>(lsp-definition)
35 nmap <buffer> gs <plug>(lsp-document-symbol-search)
36 nmap <buffer> gS <plug>(lsp-workspace-symbol-search)
37 nmap <buffer> gr <plug>(lsp-references)
38 nmap <buffer> gi <plug>(lsp-implementation)
39 nmap <buffer> gt <plug>(lsp-type-definition)
40 nmap <buffer> <leader>rn <plug>(lsp-rename)
41 nmap <buffer> [g <plug>(lsp-previous-diagnostic)
42 nmap <buffer> ]g <plug>(lsp-next-diagnostic)
43 nmap <buffer> K <plug>(lsp-hover)
44 nnoremap <buffer> <expr><c-f> lsp#scroll(+4)
45 nnoremap <buffer> <expr><c-d> lsp#scroll(-4)
47 let g:lsp_format_sync_timeout = 1000
48 autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync')
50 " refer to doc to add more commands
55 " call s:on_lsp_buffer_enabled only for languages that has the server registered.
56 autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
60 Refer to [vim-lsp-settings](https://github.com/mattn/vim-lsp-settings) on how to easily setup language servers using vim-lsp automatically.
63 Plug 'prabirshrestha/vim-lsp'
64 Plug 'mattn/vim-lsp-settings'
69 Refer to docs on configuring omnifunc or [asyncomplete.vim](https://github.com/prabirshrestha/asyncomplete.vim).
72 vim-lsp does not support snippets by default. If you want snippet integration, you will first have to install a third-party snippet plugin and a plugin that integrates it in vim-lsp.
73 At the moment, you have following options:
74 1. [vim-vsnip](https://github.com/hrsh7th/vim-vsnip) together with [vim-vsnip-integ](https://github.com/hrsh7th/vim-vsnip-integ)
75 2. [UltiSnips](https://github.com/SirVer/ultisnips) together with [vim-lsp-ultisnips](https://github.com/thomasfaingnaert/vim-lsp-ultisnips)
76 3. [neosnippet.vim](https://github.com/Shougo/neosnippet.vim) together with [vim-lsp-neosnippet](https://github.com/thomasfaingnaert/vim-lsp-neosnippet)
78 For more information, refer to the readme and documentation of the respective plugins.
82 You can let the language server automatically handle folding for you. To enable this, you have to set `'foldmethod'`, `'foldexpr'` and (optionally) `'foldtext'`:
86 \ foldexpr=lsp#ui#vim#folding#foldexpr()
87 \ foldtext=lsp#ui#vim#folding#foldtext()
90 If you would like to disable folding globally, you can add this to your configuration:
93 let g:lsp_fold_enabled = 0
96 Also see `:h vim-lsp-folding`.
98 ## Semantic highlighting
99 vim-lsp supports the unofficial extension to the LSP protocol for semantic highlighting (https://github.com/microsoft/vscode-languageserver-node/pull/367).
100 This feature requires Neovim highlights, or Vim with the `textprop` feature enabled.
101 You will also need to link language server semantic scopes to Vim highlight groups.
102 Refer to `:h vim-lsp-semantic` for more info.
104 ## Supported commands
107 * Some servers may only support partial commands.
108 * While it is possible to register multiple servers for the same filetype, some commands will pick only the first server that supports it. For example, it doesn't make sense for rename and format commands to be sent to multiple servers.
110 | Command | Description|
112 |`:LspAddTreeCallHierarchyIncoming`| Find incoming call hierarchy for the symbol under cursor, but add the result to the current list |
113 |`:LspCallHierarchyIncoming`| Find incoming call hierarchy for the symbol under cursor |
114 |`:LspCallHierarchyOutgoing`| Find outgoing call hierarchy for the symbol under cursor |
115 |`:LspCodeAction`| Gets a list of possible commands that can be applied to a file so it can be fixed (quick fix) |
116 |`:LspCodeLens`| Gets a list of possible commands that can be executed on the current document |
117 |`:LspDeclaration`| Go to the declaration of the word under the cursor, and open in the current window |
118 |`:LspDefinition`| Go to the definition of the word under the cursor, and open in the current window |
119 |`:LspDocumentDiagnostics`| Get current document diagnostics information |
120 |`:LspDocumentFormat`| Format entire document |
121 |`:LspDocumentRangeFormat`| Format document selection |
122 |`:LspDocumentSymbol`| Show document symbols |
123 |`:LspHover`| Show hover information |
124 |`:LspImplementation` | Show implementation of interface in the current window |
125 |`:LspNextDiagnostic`| jump to next diagnostic (all of error, warning, information, hint) |
126 |`:LspNextError`| jump to next error |
127 |`:LspNextReference`| jump to next reference to the symbol under cursor |
128 |`:LspNextWarning`| jump to next warning |
129 |`:LspPeekDeclaration`| Go to the declaration of the word under the cursor, but open in preview window |
130 |`:LspPeekDefinition`| Go to the definition of the word under the cursor, but open in preview window |
131 |`:LspPeekImplementation`| Go to the implementation of an interface, but open in preview window |
132 |`:LspPeekTypeDefinition`| Go to the type definition of the word under the cursor, but open in preview window |
133 |`:LspPreviousDiagnostic`| jump to previous diagnostic (all of error, warning, information, hint) |
134 |`:LspPreviousError`| jump to previous error |
135 |`:LspPreviousReference`| jump to previous reference to the symbol under cursor |
136 |`:LspPreviousWarning`| jump to previous warning |
137 |`:LspReferences`| Find references |
138 |`:LspRename`| Rename symbol |
139 |`:LspStatus` | Show the status of the language server |
140 |`:LspTypeDefinition`| Go to the type definition of the word under the cursor, and open in the current window |
141 |`:LspTypeHierarchy`| View type hierarchy of the symbol under the cursor |
142 |`:LspWorkspaceSymbol`| Search/Show workspace symbol |
146 Document diagnostics (e.g. warnings, errors) are enabled by default, but if you
147 preferred to turn them off and use other plugins instead (like
148 [Neomake](https://github.com/neomake/neomake) or
149 [ALE](https://github.com/w0rp/ale), set `g:lsp_diagnostics_enabled` to
153 let g:lsp_diagnostics_enabled = 0 " disable diagnostics support
156 ### Highlight references
158 Highlight references to the symbol under the cursor (enabled by default).
159 You can disable it by adding
162 let g:lsp_document_highlight_enabled = 0
165 to your configuration.
167 To change the style of the highlighting, you can set or link the `lspReference`
168 highlight group, e.g.:
171 highlight lspReference ctermfg=red guifg=red ctermbg=green guibg=green
176 In order to enable file logging set `g:lsp_log_file`.
179 let g:lsp_log_verbose = 1
180 let g:lsp_log_file = expand('~/vim-lsp.log')
182 " for asyncomplete.vim log
183 let g:asyncomplete_log_file = expand('~/asyncomplete.log')
186 You can get detailed status on your servers using `:CheckHealth` with a plugin on vim:
189 if !has('nvim') | Plug 'rhysd/vim-healthcheck' | endif
195 [vim-themis](https://github.com/thinca/vim-themis) is used for testing. To run
196 integration tests [gopls](https://github.com/golang/tools/tree/master/gopls)
197 executable must be in path.
201 - [Prabir Shrestha](https://github.com/prabirshrestha) (author, maintainer)
202 - [mattn](https://github.com/mattn) (maintainer)
203 - [hrsh7th](https://github.com/hrsh7th) (maintainer)
204 - [Thomas Faingnaert](https://github.com/thomasfaingnaert) (maintainer)
205 - [rhysd](https://github.com/rhysd) (maintainer)
209 Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/vim-lsp#backer)]
211 <a href="https://opencollective.com/vim-lsp/backer/0/website" target="_blank"><img src="https://opencollective.com/vim-lsp/backer/0/avatar.svg"></a>
212 <a href="https://opencollective.com/vim-lsp/backer/1/website" target="_blank"><img src="https://opencollective.com/vim-lsp/backer/1/avatar.svg"></a>
213 <a href="https://opencollective.com/vim-lsp/backer/2/website" target="_blank"><img src="https://opencollective.com/vim-lsp/backer/2/avatar.svg"></a>
214 <a href="https://opencollective.com/vim-lsp/backer/3/website" target="_blank"><img src="https://opencollective.com/vim-lsp/backer/3/avatar.svg"></a>
215 <a href="https://opencollective.com/vim-lsp/backer/4/website" target="_blank"><img src="https://opencollective.com/vim-lsp/backer/4/avatar.svg"></a>
216 <a href="https://opencollective.com/vim-lsp/backer/5/website" target="_blank"><img src="https://opencollective.com/vim-lsp/backer/5/avatar.svg"></a>
217 <a href="https://opencollective.com/vim-lsp/backer/6/website" target="_blank"><img src="https://opencollective.com/vim-lsp/backer/6/avatar.svg"></a>
218 <a href="https://opencollective.com/vim-lsp/backer/7/website" target="_blank"><img src="https://opencollective.com/vim-lsp/backer/7/avatar.svg"></a>
219 <a href="https://opencollective.com/vim-lsp/backer/8/website" target="_blank"><img src="https://opencollective.com/vim-lsp/backer/8/avatar.svg"></a>
220 <a href="https://opencollective.com/vim-lsp/backer/9/website" target="_blank"><img src="https://opencollective.com/vim-lsp/backer/9/avatar.svg"></a>
221 <a href="https://opencollective.com/vim-lsp/backer/10/website" target="_blank"><img src="https://opencollective.com/vim-lsp/backer/10/avatar.svg"></a>
222 <a href="https://opencollective.com/vim-lsp/backer/11/website" target="_blank"><img src="https://opencollective.com/vim-lsp/backer/11/avatar.svg"></a>
223 <a href="https://opencollective.com/vim-lsp/backer/12/website" target="_blank"><img src="https://opencollective.com/vim-lsp/backer/12/avatar.svg"></a>
224 <a href="https://opencollective.com/vim-lsp/backer/13/website" target="_blank"><img src="https://opencollective.com/vim-lsp/backer/13/avatar.svg"></a>
225 <a href="https://opencollective.com/vim-lsp/backer/14/website" target="_blank"><img src="https://opencollective.com/vim-lsp/backer/14/avatar.svg"></a>
230 Become a sponsor and get your logo on our README on GitHub with a link to your site. [[Become a sponsor](https://opencollective.com/vim-lsp#sponsor)]
232 <a href="https://opencollective.com/vim-lsp/sponsor/0/website" target="_blank"><img src="https://opencollective.com/vim-lsp/sponsor/0/avatar.svg"></a>
233 <a href="https://opencollective.com/vim-lsp/sponsor/1/website" target="_blank"><img src="https://opencollective.com/vim-lsp/sponsor/1/avatar.svg"></a>
234 <a href="https://opencollective.com/vim-lsp/sponsor/2/website" target="_blank"><img src="https://opencollective.com/vim-lsp/sponsor/2/avatar.svg"></a>
235 <a href="https://opencollective.com/vim-lsp/sponsor/3/website" target="_blank"><img src="https://opencollective.com/vim-lsp/sponsor/3/avatar.svg"></a>
236 <a href="https://opencollective.com/vim-lsp/sponsor/4/website" target="_blank"><img src="https://opencollective.com/vim-lsp/sponsor/4/avatar.svg"></a>
237 <a href="https://opencollective.com/vim-lsp/sponsor/5/website" target="_blank"><img src="https://opencollective.com/vim-lsp/sponsor/5/avatar.svg"></a>
238 <a href="https://opencollective.com/vim-lsp/sponsor/6/website" target="_blank"><img src="https://opencollective.com/vim-lsp/sponsor/6/avatar.svg"></a>
239 <a href="https://opencollective.com/vim-lsp/sponsor/7/website" target="_blank"><img src="https://opencollective.com/vim-lsp/sponsor/7/avatar.svg"></a>
240 <a href="https://opencollective.com/vim-lsp/sponsor/8/website" target="_blank"><img src="https://opencollective.com/vim-lsp/sponsor/8/avatar.svg"></a>
241 <a href="https://opencollective.com/vim-lsp/sponsor/9/website" target="_blank"><img src="https://opencollective.com/vim-lsp/sponsor/9/avatar.svg"></a>
242 <a href="https://opencollective.com/vim-lsp/sponsor/10/website" target="_blank"><img src="https://opencollective.com/vim-lsp/sponsor/10/avatar.svg"></a>
243 <a href="https://opencollective.com/vim-lsp/sponsor/11/website" target="_blank"><img src="https://opencollective.com/vim-lsp/sponsor/11/avatar.svg"></a>
244 <a href="https://opencollective.com/vim-lsp/sponsor/12/website" target="_blank"><img src="https://opencollective.com/vim-lsp/sponsor/12/avatar.svg"></a>
245 <a href="https://opencollective.com/vim-lsp/sponsor/13/website" target="_blank"><img src="https://opencollective.com/vim-lsp/sponsor/13/avatar.svg"></a>
246 <a href="https://opencollective.com/vim-lsp/sponsor/14/website" target="_blank"><img src="https://opencollective.com/vim-lsp/sponsor/14/avatar.svg"></a>