]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/vim-lsp/README.md

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '56df844d3c39ec494dacc69eae34272b27db185a' as '.vim/bundle/asyncomplete'
[etc/vim.git] / .vim / bundle / vim-lsp / README.md
1 # vim-lsp [![Gitter](https://badges.gitter.im/vimlsp/community.svg)](https://gitter.im/vimlsp/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
2
3 Async [Language Server Protocol](https://github.com/Microsoft/language-server-protocol) plugin for vim8 and neovim.
4
5 # Installing
6
7 Install [vim-plug](https://github.com/junegunn/vim-plug) and then:
8
9 ```viml
10 Plug 'prabirshrestha/vim-lsp'
11 ```
12
13 __Performance__
14
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+
17
18 ## Registering servers
19
20 ```viml
21 if executable('pylsp')
22     " pip install python-lsp-server
23     au User lsp_setup call lsp#register_server({
24         \ 'name': 'pylsp',
25         \ 'cmd': {server_info->['pylsp']},
26         \ 'allowlist': ['python'],
27         \ })
28 endif
29
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)
46
47     let g:lsp_format_sync_timeout = 1000
48     autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync')
49     
50     " refer to doc to add more commands
51 endfunction
52
53 augroup lsp_install
54     au!
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()
57 augroup END
58 ```
59
60 Refer to [vim-lsp-settings](https://github.com/mattn/vim-lsp-settings) on how to easily setup language servers using vim-lsp automatically.
61
62 ```viml
63 Plug 'prabirshrestha/vim-lsp'
64 Plug 'mattn/vim-lsp-settings'
65 ```
66
67 ## auto-complete
68
69 Refer to docs on configuring omnifunc or [asyncomplete.vim](https://github.com/prabirshrestha/asyncomplete.vim).
70
71 ## Snippets
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)
77
78 For more information, refer to the readme and documentation of the respective plugins.
79
80 ## Folding
81
82 You can let the language server automatically handle folding for you. To enable this, you have to set `'foldmethod'`, `'foldexpr'` and (optionally) `'foldtext'`:
83
84 ```vim
85 set foldmethod=expr
86   \ foldexpr=lsp#ui#vim#folding#foldexpr()
87   \ foldtext=lsp#ui#vim#folding#foldtext()
88 ```
89
90 If you would like to disable folding globally, you can add this to your configuration:
91
92 ```vim
93 let g:lsp_fold_enabled = 0
94 ```
95
96 Also see `:h vim-lsp-folding`.
97
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.
103
104 ## Supported commands
105
106 **Note:**
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.
109
110 | Command | Description|
111 |--|--|
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 |
143
144 ### Diagnostics
145
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
150 `0`:
151
152 ```viml
153 let g:lsp_diagnostics_enabled = 0         " disable diagnostics support
154 ```
155
156 ### Highlight references
157
158 Highlight references to the symbol under the cursor (enabled by default).
159 You can disable it by adding
160
161 ```viml
162 let g:lsp_document_highlight_enabled = 0
163 ```
164
165 to your configuration.
166
167 To change the style of the highlighting, you can set or link the `lspReference`
168 highlight group, e.g.:
169
170 ```viml
171 highlight lspReference ctermfg=red guifg=red ctermbg=green guibg=green
172 ```
173
174 ## Debugging
175
176 In order to enable file logging set `g:lsp_log_file`.
177
178 ```vim
179 let g:lsp_log_verbose = 1
180 let g:lsp_log_file = expand('~/vim-lsp.log')
181
182 " for asyncomplete.vim log
183 let g:asyncomplete_log_file = expand('~/asyncomplete.log')
184 ```
185
186 You can get detailed status on your servers using `:CheckHealth` with a plugin on vim:
187
188 ```vim
189 if !has('nvim') | Plug 'rhysd/vim-healthcheck' | endif
190 CheckHealth
191 ```
192
193 ## Tests
194
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.
198
199 ## Maintainers
200
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)
206
207 ## Backers
208
209 Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/vim-lsp#backer)]
210
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>
226
227
228 ## Sponsors
229
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)]
231
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>
247