1 *lsp.txt* Language Server Protocol (LSP) Plugin for Vim9
4 Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
5 For Vim version 9.0 and above
6 Last change: June 7, 2023
8 ==============================================================================
9 CONTENTS *lsp-contents*
11 1. Overview ................................. |lsp-overview|
12 2. Requirements ............................. |lsp-installation|
13 3. Usage .................................... |lsp-usage|
14 4. Configuration............................. |lsp-configuration|
15 5. Commands ................................. |lsp-commands|
16 6. Insert Mode Completion ................... |lsp-ins-mode-completion|
17 7. Diagnostics .............................. |lsp-diagnostics|
18 8. Tag Function ............................. |lsp-tagfunc|
19 9. LSP Formatting ........................... |lsp-format|
20 10. Call Hierarchy ........................... |lsp-call-hierarchy|
21 11. Autocommands ............................. |lsp-autocmds|
22 12. Highlight Groups ......................... |lsp-highlight-groups|
23 13. Debugging ................................ |lsp-debug|
24 14. Custom Command Handlers .................. |lsp-custom-commands|
25 15. Custom LSP Completion Kinds .............. |lsp-custom-kinds|
26 16. Multiple Language Servers for a buffer ... |lsp-multiple-servers|
27 17. Language Servers Features ................ |lsp-features|
28 18. License .................................. |lsp-license|
30 ==============================================================================
31 1. Overview *lsp-overview*
33 The Language Server Protocol (LSP) plugin implements a LSP client for Vim9.
34 Refer to the following pages for more information about LSP:
36 https://microsoft.github.io/language-server-protocol/
37 https://langserver.org/
39 This plugin needs Vim version 9.0 and after. You will need a programming
40 language specific server in your system to use this plugin. Refer to the above
41 pages for a list of available language servers for the various programming
44 The Github repository for this plugin is available at:
46 http://github.com/yegappan/lsp
48 ==============================================================================
49 2. Installation *lsp-installation*
51 You can install this plugin directly from github using the following steps:
53 $ mkdir -p $HOME/.vim/pack/downloads/opt
54 $ cd $HOME/.vim/pack/downloads/opt
55 $ git clone https://github.com/yegappan/lsp
57 or you can use any one of the Vim plugin managers (dein.vim, pathogen, vam,
58 vim-plug, volt, Vundle, etc.) to install and manage this plugin.
60 To uninstall the LSP plugin, either use the uninstall command provided by the
61 plugin manager or manually remove the $HOME/.vim/pack/downloads/lsp directory.
63 To use this plugin, add the following line to your .vimrc file:
67 ==============================================================================
70 The following commands are provided:
72 :LspCodeAction Apply the code action supplied by the language server
73 to the diagnostic in the current line.
74 :LspCodeLens Display all the code lens commands available for the
75 current file and apply the selected command.
76 :LspDiagCurrent Display the diagnostic message for the current line.
77 :LspDiagFirst Jump to the first diagnostic message for the current
79 :LspDiagHere Jump to the next diagnostic message in the current
81 :LspDiagHighlightDisable
82 Disable highlighting lines with a diagnostic message
83 for the current Vim session.
84 :LspDiagHighlightEnable Enable highlighting lines with a diagnostic message
85 for the current Vim session.
86 :LspDiagLast Jump to the last diagnostic message for the current
88 :LspDiagNext Jump to the next diagnostic message for the current
89 buffer after the current cursor position.
90 :LspDiagPrev Jump to the previous diagnostic message for the
91 current buffer before the current current position.
92 :LspDiagShow Display the diagnostics messages from the language
93 server for the current buffer in a location list.
94 :LspFold Fold the current file
95 :LspFormat Format a range of lines in the current file using the
96 language server. The default range is the entire
97 file. See |lsp-format| for more information.
98 :LspGotoDeclaration Go to the declaration of the symbol under cursor
99 :LspGotoDefinition Go to the definition of the symbol under cursor
100 :LspGotoImpl Go to the implementation of the symbol under cursor
101 :LspGotoTypeDef Go to the type definition of the symbol under cursor
102 :LspHighlight Highlight all the matches for the keyword under cursor
103 :LspHighlightClear Clear all the matches highlighted by :LspHighlight
104 :LspHover Show the documentation for the symbol under the cursor
106 :LspIncomingCalls Display the list of symbols calling the current symbol
108 :LspOutgoingCalls Display the list of symbols called by the current
110 :LspOutline Show the list of symbols defined in the current file
111 in a separate window.
112 :LspPeekDeclaration Open the declaration of the symbol under cursor in a
114 :LspPeekDefinition Open the definition of the symbol under cursor in a
116 :LspPeekImpl Open the implementation of the symbol under cursor in
118 :LspPeekReferences Display the list of references to the symbol under
119 cursor in a popup window.
120 :LspPeekTypeDef Open the type definition of the symbol under cursor in
122 :LspRename Rename the current symbol
123 :LspSelectionExpand Expand the current symbol range visual selection
124 :LspSelectionShrink Shrink the current symbol range visual selection
125 :LspServer Command to display the status and messages from a
126 language server and to restart the language server.
127 :LspShowAllServers Display the status of all the registered language
129 :LspShowReferences Display the list of references to the keyword under
130 cursor in a new location list.
131 :LspShowSignature Display the signature of the symbol under cursor.
132 :LspSubTypeHierarchy Display the sub type hierarchy in a popup window.
133 :LspSuperTypeHierarchy Display the super type hierarchy in a popup window.
134 :LspSwitchSourceHeader Switch between a source and a header file.
135 :LspSymbolSearch Perform a workspace wide search for a symbol
136 :LspWorkspaceAddFolder {folder}
137 Add a folder to the workspace
138 :LspWorkspaceListFolders
139 Show the list of folders in the workspace
140 :LspWorkspaceRemoveFolder {folder}
141 Remove a folder from the workspace
143 ==============================================================================
144 4. Configuration *lsp-configuration*
145 *LspAddServer()* *g:LspAddServer()*
147 To use the plugin features with a particular file type(s), you need to first
148 register a language server for that file type(s).
150 To register one or more language servers, use the LspAddServer() function with
151 a list of lanaguge server details in the .vimrc file.
153 To register a language server, add the following lines to your .vimrc file
154 (use only the language servers that you need from the below list).
155 If you used [vim-plug](https://github.com/junegunn/vim-plug) to install the
156 LSP plugin, the steps are described later in this section: >
161 name: 'typescriptls',
162 filetype: ['javascript', 'typescript'],
163 path: '/usr/local/bin/typescript-language-server',
169 path: '/usr/local/bin/pyls',
170 args: ['--check-parent-process', '-v']
173 LspAddServer(lspServers)
175 Depending on the location of the typescript and python pyls language servers
176 installed in your system, update the "path" in the above snippet
179 Another example, for adding the language servers for the C, C++, Golang, Rust,
180 Shell script, Vim script and PHP file types: >
186 filetype: ['c', 'cpp'],
187 path: '/usr/local/bin/clangd',
188 args: ['--background-index']
192 filetype: ['go', 'gomod', 'gohtmltmpl', 'gotexttmpl'],
193 path: '/path/to/.go/bin/gopls',
200 path: '/path/to/.cargo/bin/rust-analyzer',
207 path: '/usr/local/bin/bash-language-server',
213 path: '/usr/local/bin/vim-language-server',
219 path': '/usr/local/bin/intelephense',
222 initializationOptions: {
223 licenceKey: 'xxxxxxxxxxxxxxx'
227 LspAddServer(lspServers)
229 To add a language server, the following information is needed:
232 name (Optional) name of the language server. Can by any
233 string. Used in LSP messages and log files.
235 path complete path to the language server executable
236 (without any arguments).
238 args a |List| of command-line arguments passed to the
239 language server. Each space separated language server
240 command-line argument is a separate List item.
242 filetype One or more file types supported by the language
243 server. This can be a |String| or a |List|. To
244 specify multiple file types, use a List.
245 *lsp-cfg-initializationOptions*
246 initializationOptions
247 (Optional) for lsp servers (e.g. intelephense) some
248 additional initialization options may be required
249 or useful for initialization. Those can be provided in
250 this dictionary and if present will be transmitted to
252 *lsp-cfg-workspaceConfig*
253 workspaceConfig (Optional) a json encodable value that will be sent to
254 the language server after initialization as the
255 "settings" in a "workspace/didChangeConfiguration"
256 notification. Refer to the language server
257 documentation for the values that will be accepted in
258 this notification. This configuration is also used to
259 respond to the "workspace/configuration" request
260 message from the language server.
262 rootSearch (Optional) a List of file and directory names used to
263 locate the root path or uri of the workspace. The
264 directory names in "rootSearch" must end in "/" or
265 "\". Each file and directory name in "rootSearch" is
266 searched upwards in all the parent directories. If
267 multiple directories are found, then the directory
268 closest to the directory of the current buffer is used
269 as the workspace root.
271 If this parameter is not specified or the files are
272 not found, then the current working directory is used
273 as the workspace root for decendent files, for any
274 other files the parent directory of the file is used.
276 *lsp-cfg-runIfSearch*
277 runIfSearch (Optional) a List of file and directory names used to
278 determinate if a server should run or not. The
279 directory names in "runIfSearch" must end in "/" or
280 "\". Each file and directory name in "runIfSearch" is
281 searched upwards in all the parent directories.
282 Exactly like |lsp-cfg-rootSearch|.
284 If a file or directory is found then the server will
285 be started, otherwise it will not.
287 If this parameter is not specified or is an empty
288 list, then the server will be started unless
289 |lsp-cfg-runUnlessSearch| prevents it.
291 *lsp-cfg-runUnlessSearch*
292 runUnlessSearch (Optional) Opposite of |lsp-cfg-runIfSearch|.
294 Additionally the following configurations can be made:
296 *lsp-cfg-customNotificationHandlers*
297 customNotificationHandlers
298 (Optional) some lsp servers (e.g.
299 typescript-language-server) will send additional
300 notifications which you might want to silence or
301 handle. The provided notification handlers will be
302 called with a reference to the "lspserver" and the
307 filetype: ['javascript', 'typescript'],
308 path: '/usr/local/bin/typescript-language-server',
310 customNotificationHandlers: {
311 '$/typescriptVersion': (lspserver, reply) => {
312 echom printf("TypeScript Version = %s",
313 reply.params.version)
318 *lsp-cfg-customRequestHandlers*
319 customRequestHandlers
320 (Optional) some lsp servers will send additional
321 request replies which you might want to silence or
322 handle. The provided request handlers will be called
323 with a reference to the "lspserver" and the "request".
326 (Optional) toggle which features should be enabled for
327 a given language server. See |lsp-multiple-servers|
328 and |lsp-features| for more information.
330 omnicompl (Optional) a boolean value that enables (true)
331 or disables (false) omni-completion for these file
332 types. By default this is set to "v:true". This value
333 is applicable only if auto completion is disabled
334 (|lsp-opt-autoComplete|).
335 *lsp-cfg-processDiagHandler*
337 (Optional) A |Funcref| or |lambda| that takes a list
338 of language server diagnostics and returns a new list
339 of filtered, or otherwise changed diagnostics. Can be
340 used to remove unwanted diagnostics, prefix the
341 diagnostics text, etc. The following example will
342 remove all but errors and warnings: >
346 filetype: ['javascript', 'typescript'],
347 path: '/usr/local/bin/typescript-language-server',
349 processDiagHandler: (diags: list<dict<any>>) => {
350 # Only include errors and warnings
351 return diags->filter((diag, ix) => {
352 return diag.severity <= 2
357 And this example will prefix the diagnostic message
358 with the string "TypeScript: ": >
362 filetype: ['javascript', 'typescript'],
363 path: '/usr/local/bin/typescript-language-server',
365 processDiagHandler: (diags: list<dict<any>>) => {
366 return diags->map((diag, ix) => {
367 diag.message = $'TypeScript: {diag.message}'
374 syncInit (Optional) for language servers (e.g. rust analyzer,
375 gopls, etc.) that take time to initialize and reply to
376 a "initialize" request message this should be set to
377 "true". If this is set to true, then a synchronous
378 call is used to initialize the language server,
379 otherwise the server is initialized asynchronously.
380 By default this is set to "false".
382 debug (Optional) log the messages printed by this language
383 server in stdout and stderr to a file. Useful for
384 debugging a language server. By default the
385 messages are not logged. See |lsp-debug| for more
388 The language servers are added using the LspAddServer() function. This
389 function accepts a list of language servers with the above information.
391 If you used [vim-plug](https://github.com/junegunn/vim-plug) to install the
392 LSP plugin, then you need to use the VimEnter autocmd to initialize the
393 language server and to set the language server options. For example: >
399 filetype: ['c', 'cpp'],
400 path: '/usr/local/bin/clangd',
401 args: ['--background-index']
404 autocmd VimEnter * LspAddServer(lspServers)
406 var lspOpts = {'autoHighlightDiags': true}
407 autocmd VimEnter * LspOptionsSet(lspOpts)
409 *lsp-options* *LspOptionsSet*
412 Some of the LSP plugin features can be enabled or disabled by using the
413 LspOptionsSet() function. This function accepts a dictionary argument with the
414 following optional items:
417 aleSupport |Boolean| option. If true, diagnostics will be sent to
418 Ale, instead of being displayed by this plugin.
419 This is useful to combine all LSP and linter
420 diagnostics. By default this is set to false.
421 *lsp-opt-autoComplete*
422 autoComplete |Boolean| option. In insert mode, automatically
423 complete the current symbol. Otherwise use
424 omni-completion. By default this is set to true.
425 *lsp-opt-autoHighlight*
426 autoHighlight |Boolean| option. In normal mode, automatically
427 highlight all the occurrences of the symbol under the
428 cursor. By default this is set to false.
429 *lsp-opt-autoHighlightDiags*
430 autoHighlightDiags |Boolean| option. Automatically place signs on the
431 lines with a diagnostic message from the language
432 server. By default this is set to true.
433 *lsp-opt-autoPopulateDiags*
434 autoPopulateDiags |Boolean| option. Automatically populate the location
435 list with diagnostics from the language server.
436 By default this is set to false.
437 *lsp-opt-completionMatcher*
438 completionMatcher |String| option. Enable fuzzy or case insensitive
439 completion for language servers that replies with a
440 full list of completion items. Some language servers
441 does completion filtering in the server, while other
442 relies on the client to do the filtering.
444 This option only works for language servers that
445 expect the client to filter the completion items.
447 This option accepts one of the following values:
448 case - case sensitive matching (default).
449 fuzzy - fuzzy match completion items.
450 icase - ignore case when matching items.
451 *lsp-opt-completionTextEdit*
452 completionTextEdit |Boolean| option. If true, apply the LSP server
453 supplied text edits after a completion. If a snippet
454 plugin is going to apply the text edits, then set
455 this to false to avoid applying the text edits twice.
456 By default this is set to true.
457 *lsp-opt-completionKinds*
458 completionKinds |Dictionary| option. See |lsp-custom-kinds| for all
459 completion kind names.
460 *lsp-opt-customCompletionKinds*
461 customCompletionKinds |Boolean| option. If you set this to true, you can
462 set custom completion kinds using the option
464 *lsp-opt-diagSignErrorText*
465 diagSignErrorText |String| option. Change diag sign text for errors
467 *lsp-opt-diagSignHintText*
468 diagSignHintText |String| option. Change diag sign text for hints
470 *lsp-opt-diagSignInfoText*
471 diagSignInfoText |String| option. Change diag sign text for info
473 *lsp-opt-diagSignWarningText*
474 diagSignWarningText |String| option. Change diag sign text for warnings
476 *lsp-opt-diagVirtualTextAlign*
477 diagVirtualTextAlign |String| option. Alignment of diagnostics messages
478 if |lsp-opt-showDiagWithVirtualText| is set to true.
479 Allowed values are 'above', 'below' or 'after'
480 By default this is set to 'above',
481 *lsp-opt-echoSignature*
482 echoSignature |Boolean| option. In insert mode, echo the current
483 symbol signature instead of showing it in a popup.
484 By default this is set to false.
485 *lsp-opt-hideDisabledCodeActions*
486 hideDisabledCodeActions |Boolean| option. Hide all the disabled code actions.
487 By default this is set to false.
488 *lsp-opt-highlightDiagInline*
489 highlightDiagInline |Boolean| option. Highlight the diagnostics inline
490 By default this is set to false.
491 *lsp-opt-hoverInPreview*
492 hoverInPreview |Boolean| option. Show |:LspHover| in a preview window
494 By default this is set to false.
495 *lsp-opt-ignoreMissingServer*
496 ignoreMissingServer |Boolean| option. Do not print a missing language
497 server executable. By default this is set to false.
498 *lsp-opt-keepFocusInDiags*
499 keepFocusInDiags |Boolean| option. Focus on the location list window
501 By default this is set to true.
502 *lsp-opt-keepFocusInReferences*
503 keepFocusInReferences |Boolean| option. Focus on the location list window
504 after LspShowReferences.
505 By default this is set to true.
506 *lsp-opt-noDiagHoverOnLine*
507 noDiagHoverOnLine |Boolean| option. Suppress diagnostic hover from
508 appearing when the mouse is over the line instead of
510 By default this is set to true.
511 *lsp-opt-noNewlineInCompletion*
512 noNewlineInCompletion |Boolean| option. Suppress adding a new line on
513 completion selection with <CR>.
514 By default this is set to false.
515 *lsp-opt-outlineOnRight*
516 outlineOnRight |Boolean| option. Open the outline window on the
517 right side, by default this is false.
518 *lsp-opt-outlineWinSize*
519 outlineWinSize |Number| option. The size of the symbol Outline
520 window. By default this is set to 20.
521 *lsp-opt-showDiagInPopup*
522 showDiagInPopup |Boolean| option. When using the |:LspDiagCurrent|
523 command to display the diagnostic message for the
524 current line, use a popup window to display the
525 message instead of echoing in the status area.
526 By default this is set to true.
527 *lsp-opt-showDiagOnStatusLine*
528 showDiagOnStatusLine |Boolean| option. Show a diagnostic message on a
529 status line. By default this is set to false.
530 *lsp-opt-showDiagWithVirtualText*
531 showDiagWithVirtualText |Boolean| option. Show diagnostic message text from
532 the language server with virtual text. By default
533 this is set to false. The "autoHighlightDiags" option
534 should be set to true.
535 Needs Vim version 9.0.1157 or later.
536 *lsp-opt-showInlayHints*
537 showInlayHints |Boolean| option. Show inlay hints from the language
538 server. By default this is set to false. The inlay
539 hint text is displayed as a virtual text. Needs Vim
540 version 9.0.0178 or later.
541 *lsp-opt-showSignature*
542 showSignature |Boolean| option. In insert mode, automatically show
543 the current symbol signature in a popup.
544 By default this is set to true.
545 *lsp-opt-snippetSupport*
546 snippetSupport |Boolean| option. Enable snippet completion support.
547 Need a snippet completion plugin like vim-vsnip.
548 By default this is set to false.
549 *lsp-opt-ultisnipsSupport*
550 ultisnipsSupport |Boolean| option. Enable SirVer/ultisnips support.
551 Need a snippet completion plugin SirVer/ultisnips.
552 By default this is set to false.
553 *lsp-opt-vssnipSupport*
554 vsnipSupport |Boolean| option. Enable hrsh7th/vim-vsnip support.
555 Need snippet completion plugins hrsh7th/vim-vsnip
556 and hrsh7th/vim-vsnip-integ. Make sure
557 ultisnipsSupport is set to false before enabling this.
558 By default this option is set to false.
559 *lsp-opt-usePopupInCodeAction*
560 usePopupInCodeAction |Boolean| option. When using the |:LspCodeAction|
561 command to display the code action for the current
562 line, use a popup menu instead of echoing.
563 By default this is set to false.
564 *lsp-opt-useQuickfixForLocations*
565 useQuickfixForLocations |Boolean| option. Show |:LspShowReferences| in a
566 quickfix list instead of a location list.
567 By default this is set to false.
568 *lsp-opt-useBufferCompletion*
569 useBufferCompletion |Boolean| option. If enabled, the words from the
570 current buffer are added to the auto completion list.
571 This may degrade Vim performance as the current buffer
572 contents are processed every time the completion menu
574 By default this is set to false.
576 For example, to disable the automatic placement of signs for the LSP
577 diagnostic messages, you can add the following line to your .vimrc file: >
579 LspOptionsSet({'autoHighlightDiags': false})
581 The LspOptionsGet() function returns a |Dict| of all the LSP plugin options,
582 To get a particular option value you can use the following: >
584 echo LspOptionsGet()['autoHighlightDiags']
586 ==============================================================================
587 5. Commands *lsp-commands*
589 A description of the various commands provided by this plugin is below. You
590 can map these commands to keys and make it easier to invoke them.
593 :LspCodeAction [query] Apply the code action supplied by the language server
594 to the diagnostic in the current line. This works only
595 if there is a diagnostic message for the current line.
596 You can use the |:LspDiagCurrent| command to display
597 the diagnostic for the current line.
599 When [query] is given the code action starting with
600 [query] will be applied. [query] can be a regexp
601 pattern, or a digit corresponding to the index of the
602 code actions in the created prompt.
604 When [query] is not given you will be prompted to
605 select one of the actions supplied by the language
609 :LspCodeLens Display a list of code lens commands available for the
610 current buffer and apply the selected code lens
614 :LspDiagCurrent Displays the diagnostic message (if any) for the
615 current line. If the option 'showDiagInPopup' is set
616 to true (default), then the message is displayed in
617 a popup window. Otherwise the message is displayed in
618 the status message area.
620 :LspDiagCurrent! Only display a diagnostic message if it's directly
621 under the cursor. Otherwise works exactly like
624 To show the current diagnotic under the cursor while
625 moving around the following autocmd can be used: >
629 au CursorMoved * silent! LspDiagCurrent!
633 :LspDiagFirst Jumps to the location of the first diagnostic message
634 for the current file.
637 :LspDiagHere Jumps to the location of the diagnostic message in
638 the current line (start from current column).
640 :LspDiagHighlightDisable *:LspDiagHighlightDisable*
641 Disable highlighting lines with a diagnostic message
642 for the current Vim session.
643 To always disable the highlighting, set the
644 autoHighlightDiags option to false.
646 *:LspDiagHighlightEnable*
647 :LspDiagHighlightEnable Enable highlighting lines with a diagnostic message
648 for the current Vim session. Note that highlighting
649 lines with a diagnostic message is enabled by default.
652 :LspDiagLast Jumps to the location of the first diagnostic message
653 for the current file.
656 :[count]LspDiagNext Go to the [count] diagnostic message after the current
657 cursor position. If [count] is omitted, then 1 is
658 used. If [count] exceeds the number of diagnostics
659 after the current position, then the last diagnostic
663 :[count]LspDiagPrev Go to the [count] diagnostic message before the
664 current cursor position. If [count] is omitted, then
665 1 is used. If [count] exceeds the number of
666 diagnostics before the current position, then first
667 last diagnostic is selected.
670 :LspDiagShow Creates a new location list with the diagnostics
671 messages (if any) from the language server for the
672 current file and opens the location list window. You
673 can use the Vim location list commands to browse the
677 :LspFold Create folds for the current buffer.
680 :LspFormat Format the current file using the language server. The
681 'shiftwidth' and 'expandtab' values set for the
682 current buffer are used when format is applied.
684 :{range}LspFormat Format the specified range of lines in the current
685 file using the language server.
687 *:LspGotoDeclaration*
688 :[count]LspGotoDeclaration
689 Jumps to the declaration of the symbol under the
690 cursor. The behavior of this command is similar to the
691 |:LspGotoDefinition| command.
694 :[count]LspGotoDefinition
695 Jumps to the [count] definition of the symbol under
696 the cursor. If there are multiple matches and [count]
697 isn't specified, then a location list will be created
698 with the list of locations.
700 If there is only one location, or [count] is provided
701 then the following will apply:
703 If the file is already present in a window, then jumps
704 to that window. Otherwise, opens the file in a new
705 window. If the current buffer is modified and
706 'hidden' is not set or if the current buffer is a
707 special buffer, then a new window is opened. If the
708 jump is successful, then the current cursor location
709 is pushed onto the tag stack. The |CTRL-T| command
710 can be used to go back up the tag stack. Also the
711 |``| mark is set to the position before the jump.
713 This command supports |:command-modifiers|. You can
714 use the modifiers to specify whether a new window or
715 a new tab page is used and where the window is opened.
718 # Open a horizontally split window
719 :topleft LspGotoDefinition
720 # Open a vertically split window
721 :vert LspGotoDefinition
722 # Open a new tab page
723 :tab LspGotoDefinition
725 You may want to map a key to invoke this command: >
727 nnoremap <buffer> gd <Cmd>LspGotoDefinition<CR>
728 nnoremap <buffer> <C-W>gd <Cmd>topleft LspGotoDefinition<CR>
730 Or if you want to support [count]gd >
732 nnoremap <buffer> gd <Cmd>execute v:count .. 'LspGotoDefinition'<CR>
733 nnoremap <buffer> <C-W>gd <Cmd>execute 'topleft ' .. v:count .. 'LspGotoDefinition'<CR>
736 :[count]LspGotoImpl Jumps to the implementation of the symbol under the
737 cursor. The behavior of this command is similar to the
738 |:LspGotoDefinition| command. Note that not all the
739 language servers support this feature.
741 You may want to map a key to invoke this command: >
743 nnoremap <buffer> gi <Cmd>LspGotoImpl<CR>
746 :[count]LspGotoTypeDef Jumps to the type definition of the symbol under the
747 cursor. The behavior of this command is similar to the
748 |:LspGotoDefinition| command. Note that not all the
749 language servers support this feature.
751 You may want to map a key to invoke this command: >
753 nnoremap <buffer> gt <Cmd>LspGotoTypeDef<CR>
756 :LspHighlight Highlights all the matches for the symbol under
757 cursor. The text, read and write references to the
758 symbol are highlighted using Search, DiffChange and
759 DiffDelete highlight groups respectively.
762 :LspHighlightClear Clears all the symbol matches highlighted by the
763 |:LspHighlight| command.
766 :LspHover Show the documentation for the symbol under the cursor
767 in a popup window. If you want to show the symbol
768 documentation in the preview window instead of in a
771 LspOptionsSet({'hoverInPreview': true})
773 You can use the |K| key in normal mode to display the
774 documentation for the keyword under the cursor by
775 setting the 'keywordprg' Vim option: >
777 :set keywordprg=:LspHover
780 :LspIncomingCalls Display a hierarchy of symbols calling the symbol
781 under the cursor in a window. See
782 |lsp-call-hierarchy| for more information. Note that
783 not all the language servers support this feature.
786 :LspOutoingCalls Display a hierarchy of symbols called by the symbol
787 under the cursor in a window. See
788 |lsp-call-hierarchy| for more information. Note that
789 not all the language servers support this feature.
792 :[count]LspOutline Opens a vertically split window with the list of
793 symbols defined in the current file. The current
794 symbol is highlighted. The symbols are grouped by
795 their type. You can select a symbol and press <Enter>
796 to jump to the position of the symbol. As you move the
797 cursor in a file, the current symbol is automatically
798 highlighted in the outline window. If you open a new
799 file, the outline window is automatically updated with
800 the symbols in the new file. Folds are created in the
801 outline window for the various group of symbols.
803 You can use |lsp-opt-outlineOnRight| and
804 |lsp-opt-outlineWinSize| to customize the placement
805 and size of the window.
807 This command also supports |:command-modifiers|. You
808 can use the modifiers specify the position of the
809 window. Note that the default is ":vert :topleft" or
810 ":vert :botright" depending on
811 |lsp-opt-outlineOnRight|
813 This command also supports providing a [count] to
814 specify the size of the window. Note that this
815 overrides the values defined in
816 |lsp-opt-outlineWinSize|.
819 # Open the outline window just above the current
821 :aboveleft LspOutline
823 # Open the outline window just next to the current
824 # window, this is different from the default, when
825 # you have multiple splits already
826 :vert aboveleft LspOutline
828 # Same as above, but with a width of 50
829 :vert aboveleft 50LspOutline
831 *:LspPeekDeclaration*
832 :[count]LspPeekDeclaration
833 Displays the line where the symbol under the
834 cursor is declared in a popup window. The
835 behavior of this command is similar to the
836 |:LspPeekDefinition| command.
839 :[count]LspPeekDefinition
840 Displays the line where the symbol under the cursor is
841 defined in a popup window. The symbol is highlighted
842 in the popup window. Moving the cursor or pressing
843 <Esc> will close the popup window.
844 When more than one symbol is found all of them will be
845 shown. The corresponding file for the symbol is
846 displayed in another popup window. As the selection
847 in the symbol popup menu changes, the file in the
849 When [count] is provided only the [count] symbol will
853 :[count]LspPeekImpl Displays the implementation of the symbol under the
854 cursor in a popup window. The behavior of this
855 command is similar to the |:LspPeekDefinition|
856 command. Note that not all the language servers
857 support this feature.
860 :LspPeekReferences Displays the list of references to the symbol under
861 cursor in a popup menu. The corresponding file for
862 the reference is displayed in another popup window.
863 As the selection in the reference popup menu changes,
864 the file in the popup is updated.
867 :[count]LspPeekTypeDef Displays the line where the type of the symbol under
868 the cursor is defined in a popup window. The
869 behavior of this command is similar to the
870 |:LspPeekDefinition| command. Note that not all the
871 language servers support this feature.
874 :LspRename [newName] Rename the current symbol.
876 When [newName] is not given, then you will be prompted
877 to enter the new name for the symbol. You can press
878 <Esc> or enter an empty string in the prompt to cancel
881 *:LspSelectionExpand*
882 :LspSelectionExpand Visually select the region of the symbol under the
883 cursor. In visual mode, expands the current symbol
884 visual region selection to include the next level.
886 For example, if the cursor is on a "for" statement,
887 this command selects the "for" statement and the body
888 of the "for" statement.
890 It is useful to create a visual map to use this
893 xnoremap <silent> <Leader>e <Cmd>LspSelectionExpand<CR>
895 With the above map, you can press "\e" in visual mode
896 successively to expand the current symbol visual
899 *:LspSelectionShrink*
900 :LspSelectionShrink Shrink the current symbol range visual selection. It
901 is useful to create a visual map to use this command.
904 xnoremap <silent> <Leader>s <Cmd>LspSelectionShrink<CR>
906 With the above map, you can press "\s" in visual mode
907 successively to shrink the current symbol visual
911 :LspServer { debug | restart | show | trace }
912 Command to display and control the language server for
913 the current buffer. Each argument has additional
914 sub-commands which are described below.
916 debug { on | off | messages | errors }
917 Command to enable or disable the language server
918 debug messages and to display the debug messages
919 and error messages received from the language
920 server. The following sub-commands are supported:
921 errors Open the log file containing the
922 language server error messages.
924 Open the log file containing the
925 language server debug messages.
926 off Disable the logging of the language
928 on Enable the logging of the messages
929 emitted by the language server in the
930 standard output and standard error.
931 By default, the language server messages are not
932 logged. On a Unix-like system, when enabled,
933 these messages are logged to the
934 /tmp/lsp-<server-name>.log and
935 /tmp/lsp-<server-name>.err file respectively. On
936 MS-Windows, the %TEMP%/lsp-<server-name>.log and
937 %TEMP%/lsp-<server-name>.err% files are used. See
938 |lsp-debug| for more information.
941 Restart (stop and then start) the language server
942 for the current buffer. All the loaded buffers
943 with the same filetype as the current buffer are
944 added back to the server.
946 show {capabilities | initializeRequest | messages
948 The following sub-commands are supported:
950 Display the list of language server
951 capabilities for the current buffer.
952 The server capabilities are described
953 in the LSP protocol specification
954 under the "ServerCapabilities"
957 Display the contents of the language
958 server initialization request message
961 Display the log messages received from
962 the language server. This includes
963 the messages received using the
964 "window/logMessage" and "$/logTrace"
967 Display the language server status for
968 the current buffer. The output shows
969 the path to the language server
970 executable and the server status.
972 trace { off | messages | verbose }
973 Set the language server debug trace value using
974 the "$/setTrace" command.
977 :LspShowAllServers Displays the list of registered language servers and
978 their status. The language servers are registered
979 using the LspAddServer() function. The output is
980 displayed in a scratch buffer. The output shows the
981 Vim file type, the corresponding language server
982 status and the path to the language server executable.
983 The language server information for each buffer is
987 :LspShowReferences Creates a new location list with the list of locations
988 where the symbol under the cursor is referenced and
989 opens the location window. If you want to show the
990 references in a quickfix list instead of in a location
993 LspOptionsSet({'useQuickfixForLocations': true})
996 :LspShowSignature Displays the signature of the symbol (e.g. a function
997 or method) before the cursor in a popup.
999 The popup is also automatically displayed in insert
1000 mode after entering a symbol name followed by a
1001 separator (e.g. a opening parenthesis). To disable
1002 this, you can set the showSignature option to false in
1005 LspOptionsSet({'showSignature': false})
1009 You can get the function signature echoed in cmdline
1010 rather than displayed in popup if you use >
1012 LspOptionsSet({'echoSignature': true})
1016 *:LspSubTypeHierarchy*
1017 :LspSubTypeHierarchy Show the sub type hierarchy for the symbol under the
1018 cursor in a popup window. The file containing the
1019 type is shown in another popup window. You can jump
1020 to the location where a type is defined by browsing
1021 the popup menu and selecting an entry.
1023 *:LspSuperTypeHierarchy*
1024 :LspSuperTypeHierarchy Show the super type hierarchy for the symbol under the
1025 cursor in a popup window. The file containing the
1026 type is shown in another popup window. As the current
1027 entry in the type hierarchy popup menu changes, the
1028 file popup window is updated to show the location
1029 where the type is defined. You can jump to the
1030 location where a type is defined by selecting the
1031 entry in the popup menu.
1033 Note that the type hierarchy support is based on the
1034 protocol supported by clangd. This is different from
1035 the one specified in the 3.17 of the LSP standard.
1037 *:LspSwitchSourceHeader*
1038 :LspSwitchSourceHeader Switch between source and header files. This is a
1039 Clangd specific extension and only works with C/C++
1043 :LspSymbolSearch <sym> Perform a workspace wide search for the symbol <sym>.
1044 If <sym> is not supplied, then you will be prompted to
1045 enter the symbol name (the keyword under the cursor is
1046 used as the default). A popup window is opened with
1047 the list of matching symbols. You can enter a few
1048 characters to narrow down the list of matches. The
1049 displayed symbol name can be erased by pressing
1050 <Backspace> or <C-U> and a new symbol search pattern
1051 can be entered. You can close the popup menu by
1052 pressing the escape key or by pressing CTRL-C.
1054 In the popup menu, the following keys can be used:
1056 CTRL-F - Scroll one page forward
1058 CTRL-B - Scroll one page backward
1060 CTRL-Home - Jump to the first entry
1061 CTRL-End - Jump to the last entry
1062 <Up> - Go up one entry
1064 <Down> - Go down one entry
1066 <Enter> - Open the selected file
1067 <Esc> - Close the popup menu
1069 <BS> - Erase one character from the
1072 <C-U> - Erase the filter text
1074 Any other alphanumeric key will be used to narrow down
1075 the list of names displayed in the popup menu. When
1076 you type a filter string, then only the symbols fuzzy
1077 matching the string are displayed in the popup menu.
1078 You can enter a new search pattern to do a workspace
1081 *:LspWorkspaceAddFolder*
1082 :LspWorkspaceAddFolder {folder}
1083 Add a folder to the workspace
1085 :LspWorkspaceListFolders *:LspWorkspaceListFolders*
1086 Show the list of folders in the workspace.
1088 *:LspWorkspaceRemoveFolder*
1089 :LspWorkspaceRemoveFolder {folder}
1090 Remove a folder from the workspace
1092 ==============================================================================
1093 6. Insert mode completion *lsp-ins-mode-completion*
1095 By default, in insert mode, the LSP plugin automatically displays the matches
1096 for the symbol under the cursor in an insert-completion popup menu. You can
1097 use the keys described in |popupmenu-keys| with this menu.
1099 To disable the auto-completion for all the files, you can set the
1100 'autoComplete' option to false in your .vimrc file: >
1102 LspOptionsSet({'autoComplete': false})
1104 If this variable is set, then the LSP plugin will not automatically start
1105 completion in insert mode and instead supports omni-completion (|compl-omni|).
1106 It sets the 'omnifunc' option for the buffers which have a registered language
1107 server. To complete a symbol in insert mode manually, you can press CTRL-X
1108 CTRL-O to invoke completion using the items suggested by the language server.
1110 You can also enable or disable omni-completion for a specific language
1111 server by setting the 'omnicompl' item to 'false' when registering a lsp
1112 server for the filetype. If this item is not specified, then omni-completion
1113 is enabled by default. The following example disables omni-completion for
1121 path: '/usr/local/bin/pyls',
1122 args: ['--check-parent-process', '-v']
1126 If you want to use omni completion, in addition to the automatic completion,
1127 then you can set the 'omnifunc' option to the "g:LspOmniFunc" function: >
1129 set omnifunc=g:LspOmniFunc
1131 To use omni completion, press CTRL-X CTRL-O in insert mode. Refer to
1132 |compl-omni| for more information.
1134 When doing insert-mode completion, the plugin sends a request message to the
1135 language server to return a list of possible completion matches for the
1136 current cursor position. The plugin retrieves the keyword before the cursor
1137 (see 'iskeyword') and then filters the returned list of completion items
1138 against this keyword and displays the completion menu. Some language servers
1139 does completion filtering in the server, while other relies on the client to
1140 do the filtering. By default, case sensitive comparison is used to filter the
1141 returned items. You can modify the 'completionMatcher' option to use either
1142 case insensitive or fuzzy comparison.
1144 ==============================================================================
1145 7. Diagnostics *lsp-diagnostics*
1147 When a source file has syntax errors or warnings or static analysis warnings,
1148 the LSP plugin highlights them by placing |signs| in the |sign-column|. You
1149 can use the |:LspDiagShow| command to display all the diagnostic messages for
1150 the current file in a |location-list-window|. You can use the |:LspDiagFirst|
1151 command to jump to the line with the first diagnostic message, the
1152 |:LspDiagNext| command to jump to the next nearest line with the diagnostic
1153 message, the |:LspDiagPrev| command to jump to the previous nearest line with
1154 the diagnostic message, the |:LspDiagHere| command to jump to the diagnostic
1155 message in the current line. You can use the |:LspDiagCurrent| command to
1156 display the entire diagnostic message from the language server for the current
1159 By default, the lines with a diagnostic message have a sign placed on them and
1160 are highlighted. You can temporarily disable them for the current Vim session
1161 using the |:LspDiagHighlightDisable| command and re-enable them using the
1162 |:LspDiagHighlightEnable| command.
1164 To disable the automatic placement of signs on the lines with a diagnostic
1165 message, you can set the 'autoHighlightDiags' option to false: >
1167 LspOptionsSet({'autoHighlightDiags': false})
1169 By default the 'autoHighlightDiags' option is set to true.
1171 The function lsp#lsp#ErrorCount() function can be used to get the count of the
1172 diagnostic messages in the current buffer by type. This function returns a
1173 Dictionary with the following keys: Info, Hint, Warn and Error. The value for
1174 these keys is the number of diagnostic messages of the corresponding type.
1175 This function can be used to display the number of diagnostics in the current
1176 buffer in a 'statusline'.
1178 For some diagnostic errors/warnings, the language server may provide an
1179 automatic fix. To apply this fix, you can use the |:LspCodeAction| command.
1180 This command applies the action provided by the language server (if any) for
1183 The |:LspDiagShow| command creates a new location list with the current list
1184 of diagnostics for the current buffer. To automatically add the diagnostics
1185 messages to the location list, you can set the 'autoPopulateDiags' option to
1186 true. Â By default this option is set to false. Â When new diagnostics are
1187 received for a buffer, if a location list with the diagnostics is already
1188 present, then it is refreshed with the new diagnostics.
1190 When using GUI Vim or in a terminal Vim with 'ballooneval' option set, when
1191 the mouse is moved over the diagnostic sign displayed in the sign column, then
1192 the diagnostic message is displayed in a popup. By default, the diagnostic
1193 message popup is not displayed when the mouse is moved over the text in the
1194 line. To display the diagnostic message when hovering the mouse over the text
1195 of the line, you can set the 'noDiagHoverOnLine' option to false. By
1196 default, this option is set to true.
1198 To display the diagnostic message for the current line in the status area, you
1199 can set the 'showDiagOnStatusLine' option to true. By default, this option
1202 By default, the |:LspDiagCurrent| command displays the diagnostic message for
1203 the current line in a popup window. To display the message in the status
1204 message area instead, you can set the 'showDiagInPopup' option to false. By
1205 default this is set to true.
1207 ==============================================================================
1208 8. Tag Function *lsp-tagfunc*
1210 The |:LspGotoDefinition| command can be used jump to the location where a
1211 symbol is defined. To jump to the symbol definition using the Vim
1212 |tag-commands|, you can set the 'tagfunc' option to the 'lsp#lsp#TagFunc'
1215 setlocal tagfunc=lsp#lsp#TagFunc
1217 After setting the above option, you can use |Ctrl-]| and other tag related
1218 commands to jump to the symbol definition.
1220 Note that most of the language servers return only one symbol location even if
1221 the symbol is defined in multiple places in the code.
1223 ==============================================================================
1224 9. Code Formatting *lsp-format*
1226 The |:LspFormat| command can be used to format either the entire file or a
1227 selected range of lines using the language server. The 'shiftwidth' and
1228 'expandtab' values set for the current buffer are used when format is applied.
1230 To format code using the 'gq' command, you can set the 'formatexpr' option: >
1232 setlocal formatexpr=lsp#lsp#FormatExpr()
1234 ==============================================================================
1235 10. Call Hierarchy *lsp-call-hierarchy*
1237 The |:LspIncomingCalls| and the |:LspOutoingCalls| commands can be used to
1238 display the call hierarchy of a symbol. For example, the functions calling a
1239 function or the functions called by a function. These two commands open a
1240 window containing the call hierarchy tree. You can use the Vim motion
1241 commands to browse the call hierarchy.
1243 In the call hierarchy tree window, the following keys are supported:
1245 <Enter> Jump to the location of the symbol under the
1247 - Expand and show the symbols calling or called
1248 by the symbol under the cursor.
1249 + Close the call hierarchy for the symbol under
1252 You can display either the incoming call hierarchy or the outgoing call
1253 hierarchy in this window. You cannot display both at the same time.
1255 In the call hierarchy tree window, the following commands are supported:
1257 *:LspCallHierarchyRefresh*
1258 :LspCallHierarchyRefresh Query the language server again for the top
1259 level symbol and refresh the call hierarchy
1261 *:LspCallHierarchyIncoming*
1262 :LspCallHierarchyIncoming Display the incoming call hierarchy for the
1263 top level symbol. If the window is currently
1264 displaying the outgoing calls, then it is
1265 refreshed to display the incoming calls.
1266 *:LspCallHierarchyOutgoing*
1267 :LspCallHierarchyOutgoing Display the outgoing call hierarchy for the
1268 top level symbol. If the window is currently
1269 displaying the incoming calls, then it is
1270 refreshed to display the outgoing calls.
1272 ==============================================================================
1273 11. Autocommands *lsp-autocmds*
1276 LspAttached A |User| autocommand fired when the LSP client
1277 attaches to a buffer. Can be used to configure
1278 buffer-local mappings or options.
1281 LspDiagsUpdated A |User| autocommand invoked when new
1282 diagnostics are received from the language
1283 server. This is invoked after the LSP client
1284 has processed the diagnostics.
1286 ==============================================================================
1287 12. Highlight Groups *lsp-highlight-groups*
1289 The following highlight groups are used by the LSP plugin. You can define
1290 these highlight groups in your .vimrc file before sourcing this plugin to
1293 *LspDiagInlineError* Used to highlight inline error diagnostics.
1294 By default, linked to the "SpellBad" highlight
1296 *LspDiagInlineHint* Used to highlight inline hint diagnostics.
1297 By default, linked to the "SpellLocal"
1299 *LspDiagInlineInfo* Used to highlight inline info diagnostics.
1300 By default, linked to the "SpellRare"
1302 *LspDiagInlineWarning* Used to highlight inline warning diagnostics.
1303 By default, linked to the "SpellCap" highlight
1305 *LspDiagLine* Used to highlight a line with one or more
1306 diagnostics. By default linked to the
1307 "DiffAdd" highlight group. Use "NONE" to
1309 *LspDiagSignErrorText* Used to highlight the sign text for error
1310 diags. By default linked to 'ErrorMsg'.
1311 *LspDiagSignHintText* Used to highlight the sign text for hint
1312 diags. By default linked to 'Question'.
1313 *LspDiagSignInfoText* Used to highlight the sign text for info
1314 diags. By default linked to 'Pmenu'.
1315 *LspDiagSignWarningText* Used to highlight the sign text for warning
1316 diags. By default linked to 'Search'.
1317 *LspDiagVirtualText* Used to highlight diagnostic virtual text.
1318 By default, linked to the "LineNr" highlight
1320 *LspInlayHintsParam* Used to highlight inlay hints of kind
1321 "parameter". By default, linked to the
1322 "Label" highlight group.
1323 *LspInlayHintsType* Used to highlight inlay hints of kind "type".
1324 By default, linked to the "Conceal" highlight
1326 *LspSigActiveParameter* Used to highlight the active signature
1327 parameter. By default, linked to the "LineNr"
1330 For example, to override the highlight used for diagnostics virtual text, you
1331 can use the following: >
1333 highlight LspDiagVirtualText ctermfg=Cyan guifg=Blue
1337 highlight link LspDiagLine NONE
1338 highlight link LspDiagVirtualText WarningMsg
1340 ==============================================================================
1341 13. Debugging *lsp-debug*
1343 To debug this plugin, you can log the language server protocol messages sent
1344 and received by the plugin from the language server. The following command
1345 enables the logging of the messages from the language server for the current
1350 This command also clears the log files. The following command disables the
1351 logging of the messages from the language server for the current buffer: >
1353 :LspServer debug off
1355 By default, the messages are not logged. Another method to enable the debug
1356 is to set the "debug" field to true when adding a language server
1357 using |LspAddServer()|.
1359 The messages printed by the language server in the stdout are logged to the
1360 lsp-<server-name>.log file and the messages printed in the stderr are logged
1361 to the lsp-<server-name>.err file. On a Unix-like system, these files are
1362 created in the /tmp directory. On MS-Windows, these files are created in the
1365 The following command opens the file containing the messages printed by the
1366 language server in the stdout: >
1368 :LspServer debug messages
1370 The following command opens the file containing the messages printed by the
1371 language server in the stderr: >
1373 :LspServer debug errors
1375 To debug language server initialization problems, after enabling the above
1376 server debug, you can restart the server for the file type in the current
1377 buffer using the following command: >
1381 The language servers typically support command line options to enable debug
1382 messages and to increase the verbosity of the messages. You can refer to the
1383 language server documentation for information about this. You can include
1384 these options when registering the language server with this plugin.
1386 If a language server supports the "$/logTrace" LSP notification, then you can
1387 use the :LspServerTrace command to set the server trace value: >
1389 :LspServer trace { off | messages | verbose }
1391 ==============================================================================
1392 14. Custom Command Handlers *lsp-custom-commands*
1394 When applying a code action, the language server may issue a non-standard
1395 command. For example, the Java language server uses non-standard commands
1396 (e.g. java.apply.workspaceEdit). To handle these commands, you can register a
1397 callback function for each command using the LspRegisterCmdHandler() function.
1401 import autoload "lsp/textedit.vim"
1403 def WorkspaceEdit(cmd: dict<any>)
1404 for editAct in cmd.arguments
1405 textedit.ApplyWorkspaceEdit(editAct)
1408 g:LspRegisterCmdHandler('java.apply.workspaceEdit', WorkspaceEdit)
1410 Place the above code in a file named lsp_java/plugin/lsp_java.vim and load
1413 The callback function should accept a Dict argument. The Dict argument
1414 contains the LSP Command interface fields. Refer to the LSP specification for
1415 more information about the "Command" interface.
1417 ==============================================================================
1418 15. Custom LSP Completion Kinds *lsp-custom-kinds*
1420 When a completion popup is triggered, the LSP client will use a default kind
1421 list to show in the completion "kind" section, to customize it, you need to
1422 use the option |lsp-opt-customCompletionKinds| and set all custom kinds in the
1423 option |lsp-opt-completionKinds| . There is a table with all default LSP
1427 ------------------------|--------------------
1455 For example, if you want to change the "Method" kind to the kind "method()": >
1460 customCompletionKinds: true,
1462 "Method": "method()"
1466 In the completion popup, will show something like this: >
1468 var file = new File()
1472 | createIfNotExists method() |
1475 ==============================================================================
1476 16. Multiple Language Servers for a buffer *lsp-multiple-servers*
1478 It's possible to run multiple language servers for a given buffer.
1480 By default the language server defined first will be used for as much as it
1481 supports, then the next and so on. With the exception that diagnostics from
1482 all running language servers will be combined.
1484 This means that you can define a language server that only supports a subset
1485 of features at first and then define the general purpose language server after
1491 # This language server reports that it only supports
1492 # textDocument/documentFormatting, so it will be used
1493 # for :LspFormat but nothing else.
1496 path: 'html-pretty-lsp',
1499 # This language server also supports
1500 # textDocument/documentFormatting, but since it's been
1501 # defined later, the one above will be used instead.
1502 # However this server also supports
1503 # textDocument/definition, textDocument/declaration,
1504 # etc, so it will be used for :LspGotoDefinition,
1505 # :LspGotoDeclaration, etc
1508 path: 'html-language-server',
1513 As shown in the example above the order of when the language servers are being
1514 defined is taken into account for a given method. However sometimes the
1515 language server that you want to use for formatting also reports that it
1516 supports other features. In such a case you can do one of two things:
1518 1. change the order of language servers, and specify that a given language
1519 server should be used for a given method.
1521 2. set the unwanted features to |false| in the features |Dictionary| >
1523 features: { 'codeAction': false }
1525 For example, if you want to use the efm-langserver for formatting, but the
1526 typescript-language-server for everything else: >
1531 # this language server will be used by default, as it's defined
1532 # as the first LSP for 'javascript' and 'typescript'
1534 filetype: ['javascript', 'typescript'],
1535 path: '/usr/local/bin/typescript-language-server',
1538 # this language server will be used for documentFormatting
1540 filetype: ['efm-langserver'],
1541 path: '/usr/local/bin/efm-langserver',
1544 documentFormatting: true
1549 Another way is to disable the unwanted features: for example if you don't want
1550 diagnostics from the typescript-language-server, but want to use it for
1557 filetype: ['javascript', 'typescript'],
1558 path: '/usr/local/bin/typescript-language-server',
1566 ==============================================================================
1567 17. Language Server Features *lsp-features*
1569 By providing the configuration |lsp-cfg-features| it's possible to specify
1570 which servers should be used for a given method. The following feature flags
1571 are supported: See |lsp-multiple-servers| for examples.
1573 *lsp-features-codeAction*
1574 codeAction Used by |:LspCodeAction|
1575 *lsp-features-codeLens*
1576 codeLens Used by |:LspCodeLens|
1577 *lsp-features-completion*
1578 completion Used by 24/7 Completion and 'omnifunc'
1579 *lsp-features-declaration*
1580 declaration Used by |:LspGotoDeclaration|, and
1581 |:LspPeekDeclaration|
1582 *lsp-features-definition*
1583 definition Used by |:LspGotoDefinition|, and
1584 |:LspPeekDefinition|
1585 *lsp-features-diagnostics*
1586 diagnostics Used to disable diagnostics for a single
1587 language server, by default diagnostics are
1588 combined from all running servers, by setting
1589 this to |false| you can ignore diagnostics
1590 from a specific server.
1591 *lsp-features-documentFormatting*
1592 documentFormatting Used by |:LspFormat|, and 'formatexpr'
1593 *lsp-features-documentHighlight*
1594 documentHighlight Used by the |:LspHighlight| and the
1595 |:LspHighlightClear| commands.
1596 *lsp-features-foldingRange*
1597 foldingRange Used by |:LspFold|
1598 *lsp-features-hover*
1599 hover Used by |:LspHover|
1600 *lsp-features-implementation*
1601 implementation Used by |:LspGotoImpl|, and |:LspPeekImpl|
1602 *lsp-features-references*
1603 references Used by |:LspShowReferences|
1604 *lsp-features-rename*
1605 rename Used by |:LspRename|
1606 *lsp-features-selectionRange*
1607 selectionRange Used by the |:LspSelectionExpand| and the
1608 |:LspSelectionShrink| commands.
1609 *lsp-features-typeDefinition*
1610 typeDefinition Used by the |:LspGotoTypeDef| and the
1611 |:LspPeekTypeDef| commands.
1613 ==============================================================================
1615 License: MIT License
1616 Copyright (c) 2020-2023 Yegappan Lakshmanan
1618 Permission is hereby granted, free of charge, to any person obtaining a copy
1619 of this software and associated documentation files (the "Software"), to
1620 deal in the Software without restriction, including without limitation the
1621 rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
1622 sell copies of the Software, and to permit persons to whom the Software is
1623 furnished to do so, subject to the following conditions:
1625 The above copyright notice and this permission notice shall be included in
1626 all copies or substantial portions of the Software.
1628 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1629 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1630 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1631 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1632 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1633 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
1636 ==============================================================================
1638 vim:tw=78:ts=8:noet:ft=help:norl: