]> Sergey Matveev's repositories - vim-lsp.git/blob - doc/lsp.txt
d63ddea6b78c7abce5764c925aea2b76934932c0
[vim-lsp.git] / doc / lsp.txt
1 *lsp.txt*       Language Server Protocol (LSP) Plugin for Vim9
2
3
4 Author: Yegappan Lakshmanan  (yegappan AT yahoo DOT com)
5 For Vim version 9.0 and above
6 Last change: June 25, 2023
7
8 ==============================================================================
9 CONTENTS                                                     *lsp-contents*
10
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|
29
30 ==============================================================================
31 1. Overview                                     *lsp-overview*
32
33 The Language Server Protocol (LSP) plugin implements a LSP client for Vim9.
34 Refer to the following pages for more information about LSP:
35
36     https://microsoft.github.io/language-server-protocol/
37     https://langserver.org/
38
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
42 languages.
43
44 The Github repository for this plugin is available at:
45
46       http://github.com/yegappan/lsp
47
48 ==============================================================================
49 2. Installation                                 *lsp-installation*
50
51 You can install this plugin directly from github using the following steps:
52
53     $ mkdir -p $HOME/.vim/pack/downloads/opt
54     $ cd $HOME/.vim/pack/downloads/opt
55     $ git clone https://github.com/yegappan/lsp
56
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.
59
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.
62
63 To use this plugin, add the following line to your .vimrc file:
64
65     packadd lsp
66
67 ==============================================================================
68 3. Usage                                        *lsp-usage*
69
70 The following commands are provided:
71
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 :LspDiag current        Display the diagnostic message for the current line.
77 :LspDiag first          Jump to the first diagnostic message for the current
78                         buffer.
79 :LspDiag here           Jump to the next diagnostic message in the current
80                         line.
81 :LspDiag highlight disable
82                         Disable highlighting lines with a diagnostic message
83                         for the current Vim session.
84 :LspDiag highlight enable
85                         Enable highlighting lines with a diagnostic message
86                         for the current Vim session.
87 :LspDiag last           Jump to the last diagnostic message for the current
88                         buffer.
89 :LspDiag next           Jump to the next diagnostic message for the current
90                         buffer after the current cursor position.
91 :LspDiag prev           Jump to the previous diagnostic message for the
92                         current buffer before the current current position.
93 :LspDiag show           Display the diagnostics messages from the language
94                         server for the current buffer in a location list.
95 :LspDocumentSymbol      Display the symbols in the current file in a popup
96                         menu and jump to the location of a selected symbol.
97 :LspFold                Fold the current file
98 :LspFormat              Format a range of lines in the current file using the
99                         language server.  The default range is the entire
100                         file.  See |lsp-format| for more information.
101 :LspGotoDeclaration     Go to the declaration of the symbol under cursor
102 :LspGotoDefinition      Go to the definition of the symbol under cursor
103 :LspGotoImpl            Go to the implementation of the symbol under cursor
104 :LspGotoTypeDef         Go to the type definition of the symbol under cursor
105 :LspHighlight           Highlight all the matches for the keyword under cursor
106 :LspHighlightClear      Clear all the matches highlighted by :LspHighlight
107 :LspHover               Show the documentation for the symbol under the cursor
108                         in a popup window.
109 :LspIncomingCalls       Display the list of symbols calling the current symbol
110                         in a window.
111 :LspInlayHints          Enable or disable inlay hints.
112 :LspOutgoingCalls       Display the list of symbols called by the current
113                         symbol in a window.
114 :LspOutline             Show the list of symbols defined in the current file
115                         in a separate window.
116 :LspPeekDeclaration     Open the declaration of the symbol under cursor in a
117                         popup window.
118 :LspPeekDefinition      Open the definition of the symbol under cursor in a
119                         popup window.
120 :LspPeekImpl            Open the implementation of the symbol under cursor in
121                         a popup window.
122 :LspPeekReferences      Display the list of references to the symbol under
123                         cursor in a popup window.
124 :LspPeekTypeDef         Open the type definition of the symbol under cursor in
125                         a popup window.
126 :LspRename              Rename the current symbol
127 :LspSelectionExpand     Expand the current symbol range visual selection
128 :LspSelectionShrink     Shrink the current symbol range visual selection
129 :LspServer              Command to display the status and messages from a
130                         language server and to restart the language server.
131 :LspShowAllServers      Display the status of all the registered language
132                         servers.
133 :LspShowReferences      Display the list of references to the keyword under
134                         cursor in a new location list.
135 :LspShowSignature       Display the signature of the symbol under cursor.
136 :LspSubTypeHierarchy    Display the sub type hierarchy in a popup window.
137 :LspSuperTypeHierarchy  Display the super type hierarchy in a popup window.
138 :LspSwitchSourceHeader  Switch between a source and a header file.
139 :LspSymbolSearch        Perform a workspace wide search for a symbol
140 :LspWorkspaceAddFolder {folder}
141                         Add a folder to the workspace
142 :LspWorkspaceListFolders
143                         Show the list of folders in the workspace
144 :LspWorkspaceRemoveFolder {folder}
145                         Remove a folder from the workspace
146
147 ==============================================================================
148 4. Configuration                                *lsp-configuration*
149                                         *LspAddServer()* *g:LspAddServer()*
150
151 To use the plugin features with a particular file type(s), you need to first
152 register a language server for that file type(s).
153
154 To register one or more language servers, use the LspAddServer() function with
155 a list of lanaguge server details in the .vimrc file.
156
157 To register a language server, add the following lines to your .vimrc file
158 (use only the language servers that you need from the below list).
159 If you used [vim-plug](https://github.com/junegunn/vim-plug) to install the
160 LSP plugin, the steps are described later in this section: >
161
162    vim9script
163    var lspServers = [
164                      {
165                          name: 'typescriptls',
166                          filetype: ['javascript', 'typescript'],
167                          path: '/usr/local/bin/typescript-language-server',
168                          args: ['--stdio']
169                       },
170                      {
171                          name: 'pythonls',
172                          filetype: 'python',
173                          path: '/usr/local/bin/pyls',
174                          args: ['--check-parent-process', '-v']
175                       }
176                    ]
177    LspAddServer(lspServers)
178 <
179 Depending on the location of the typescript and python pyls language servers
180 installed in your system, update the "path" in the above snippet
181 appropriately.
182
183 Another example, for adding the language servers for the C, C++, Golang, Rust,
184 Shell script, Vim script and PHP file types: >
185
186    vim9script
187    var lspServers = [
188                      {
189                         name: 'clangd',
190                         filetype: ['c', 'cpp'],
191                         path: '/usr/local/bin/clangd',
192                         args: ['--background-index']
193                      },
194                      {
195                         name: 'golang',
196                         filetype: ['go', 'gomod', 'gohtmltmpl', 'gotexttmpl'],
197                         path: '/path/to/.go/bin/gopls',
198                         args: [],
199                         syncInit: true,
200                       },
201                      {
202                         name: 'rustls',
203                         filetype: ['rust'],
204                         path: '/path/to/.cargo/bin/rust-analyzer',
205                         args: [],
206                         syncInit: true,
207                       },
208                      {
209                         name: 'bashls',
210                         filetype: 'sh',
211                         path: '/usr/local/bin/bash-language-server',
212                         args: ['start']
213                      },
214                      {
215                         name: 'vimls',
216                         filetype: ['vim'],
217                         path: '/usr/local/bin/vim-language-server',
218                         args: ['--stdio']
219                      },
220                      {
221                         name: 'phpls',
222                         filetype: ['php'],
223                         path': '/usr/local/bin/intelephense',
224                         args: ['--stdio'],
225                         syncInit: true,
226                         initializationOptions: {
227                         licenceKey: 'xxxxxxxxxxxxxxx'
228                         }
229                       }
230                    ]
231    LspAddServer(lspServers)
232 <
233 To add a language server, the following information is needed:
234
235                                                 *lsp-cfg-name*
236         name            (Optional) name of the language server.  Can by any
237                         string.  Used in LSP messages and log files.
238                                                 *lsp-cfg-path*
239         path            complete path to the language server executable
240                         (without any arguments).
241                                                 *lsp-cfg-args*
242         args            a |List| of command-line arguments passed to the
243                         language server.  Each space separated language server
244                         command-line argument is a separate List item.
245                                                 *lsp-cfg-filetype*
246         filetype        One or more file types supported by the language
247                         server.  This can be a |String| or a |List|. To
248                         specify multiple file types, use a List.
249                                         *lsp-cfg-initializationOptions*
250         initializationOptions
251                         (Optional) for lsp servers (e.g. intelephense) some
252                         additional initialization options may be required
253                         or useful for initialization. Those can be provided in
254                         this dictionary and if present will be transmitted to
255                         the lsp server.
256                                                 *lsp-cfg-workspaceConfig*
257         workspaceConfig (Optional) a json encodable value that will be sent to
258                         the language server after initialization as the
259                         "settings" in a "workspace/didChangeConfiguration"
260                         notification.  Refer to the language server
261                         documentation for the values that will be accepted in
262                         this notification.  This configuration is also used to
263                         respond to the "workspace/configuration" request
264                         message from the language server.
265                                                 *lsp-cfg-rootSearch*
266         rootSearch      (Optional) a List of file and directory names used to
267                         locate the root path or uri of the workspace.  The
268                         directory names in "rootSearch" must end in "/" or
269                         "\".  Each file and directory name in "rootSearch" is
270                         searched upwards in all the parent directories.  If
271                         multiple directories are found, then the directory
272                         closest to the directory of the current buffer is used
273                         as the workspace root.
274
275                         If this parameter is not specified or the files are
276                         not found, then the current working directory is used
277                         as the workspace root for decendent files, for any
278                         other files the parent directory of the file is used.
279
280                                                 *lsp-cfg-runIfSearch*
281         runIfSearch     (Optional) a List of file and directory names used to
282                         determinate if a server should run or not. The
283                         directory names in "runIfSearch" must end in "/" or
284                         "\".  Each file and directory name in "runIfSearch" is
285                         searched upwards in all the parent directories.
286                         Exactly like |lsp-cfg-rootSearch|.
287
288                         If a file or directory is found then the server will
289                         be started, otherwise it will not.
290
291                         If this parameter is not specified or is an empty
292                         list, then the server will be started unless
293                         |lsp-cfg-runUnlessSearch| prevents it.
294
295                                                 *lsp-cfg-runUnlessSearch*
296         runUnlessSearch (Optional) Opposite of |lsp-cfg-runIfSearch|.
297
298 Additionally the following configurations can be made:
299
300                                         *lsp-cfg-customNotificationHandlers*
301         customNotificationHandlers
302                         (Optional) some lsp servers (e.g.
303                         typescript-language-server) will send additional
304                         notifications which you might want to silence or
305                         handle.  The provided notification handlers will be
306                         called with a reference to the "lspserver" and the
307                         "reply". >
308
309                 vim9script
310                 g:LspAddServer([{
311                         filetype: ['javascript', 'typescript'],
312                         path: '/usr/local/bin/typescript-language-server',
313                         args: ['--stdio'],
314                         customNotificationHandlers: {
315                                 '$/typescriptVersion': (lspserver, reply) => {
316                                         echom printf("TypeScript Version = %s",
317                                                 reply.params.version)
318                                 }
319                         }
320                 }])
321 <
322                                         *lsp-cfg-customRequestHandlers*
323         customRequestHandlers
324                         (Optional) some lsp servers will send additional
325                         request replies which you might want to silence or
326                         handle.  The provided request handlers will be called
327                         with a reference to the "lspserver" and the "request".
328
329         features                                *lsp-cfg-features*
330                         (Optional) toggle which features should be enabled for
331                         a given language server. See |lsp-multiple-servers|
332                         and |lsp-features| for more information.
333
334         forceOffsetEncoding                     *lsp-cfg-forceOffsetEncoding*
335                         (Optional) a |String| value that forces the use of a
336                         specific offset encoding in LSP messages.  If this
337                         option is not specified, then the UTF offset encoding
338                         is negotiated with the server during initialization.
339                         Supported values are 'utf-8' or 'utf-16' or 'utf-32'.
340                         The Vim native offset encoding is 'utf-32'.  For the
341                         'utf-8' and 'utf-16' encodings, the offsets need to be
342                         encoded and decoded in every LSP message and will
343                         incur some overhead.
344
345                                                 *lsp-cfg-omnicompl*
346         omnicompl       (Optional) a boolean value that enables (true)
347                         or disables (false) omni-completion for these file
348                         types. By default this is set to "v:true".  This value
349                         is applicable only if auto completion is disabled
350                         (|lsp-opt-autoComplete|).
351
352                                                 *lsp-cfg-processDiagHandler*
353         processDiagHandler
354                         (Optional) A |Funcref| or |lambda| that takes a list
355                         of language server diagnostics and returns a new list
356                         of filtered, or otherwise changed diagnostics.  Can be
357                         used to remove unwanted diagnostics, prefix the
358                         diagnostics text, etc.  The following example will
359                         remove all but errors and warnings: >
360
361                 vim9script
362                 g:LspAddServer([{
363                         filetype: ['javascript', 'typescript'],
364                         path: '/usr/local/bin/typescript-language-server',
365                         args: ['--stdio'],
366                         processDiagHandler: (diags: list<dict<any>>) => {
367                                 # Only include errors and warnings
368                                 return diags->filter((diag, ix) => {
369                                         return diag.severity <= 2
370                                 })
371                         },
372                 }])
373 <
374                         And this example will prefix the diagnostic message
375                         with the string "TypeScript: ": >
376
377                 vim9script
378                 g:LspAddServer([{
379                         filetype: ['javascript', 'typescript'],
380                         path: '/usr/local/bin/typescript-language-server',
381                         args: ['--stdio'],
382                         processDiagHandler: (diags: list<dict<any>>) => {
383                                 return diags->map((diag, ix) => {
384                                         diag.message = $'TypeScript: {diag.message}'
385                                         return diag
386                                 })
387                         },
388                 }])
389 <
390                                                 *lsp-cfg-syncInit*
391         syncInit        (Optional) for language servers (e.g. rust analyzer,
392                         gopls, etc.) that take time to initialize and reply to
393                         a "initialize" request message this should be set to
394                         "true". If this is set to true, then a synchronous
395                         call is used to initialize the language server,
396                         otherwise the server is initialized asynchronously.
397                         By default this is set to "false".
398
399                                                 *lsp-cfg-debug*
400         debug           (Optional) log the messages printed by this language
401                         server in stdout and stderr to a file.  Useful for
402                         debugging a language server.  By default the
403                         messages are not logged.  See |lsp-debug| for more
404                         information.
405
406                                                 *lsp-cfg-traceLevel*
407         traceLevel      (Optional) set the debug trace level for this language
408                         server. Â Supported values are: "off", "debug" and
409                         "verbose".  By default this is seto "off".
410
411 The language servers are added using the LspAddServer() function. This
412 function accepts a list of language servers with the above information.
413
414 If you used [vim-plug](https://github.com/junegunn/vim-plug) to install the
415 LSP plugin, then you need to use the VimEnter autocmd to initialize the
416 language server and to set the language server options.  For example: >
417
418     vim9script
419     var lspServers = [
420                      {
421                         name: 'clangd',
422                         filetype: ['c', 'cpp'],
423                         path: '/usr/local/bin/clangd',
424                         args: ['--background-index']
425                       }
426                    ]
427     autocmd VimEnter * LspAddServer(lspServers)
428
429     var lspOpts = {'autoHighlightDiags': true}
430     autocmd VimEnter * LspOptionsSet(lspOpts)
431 <
432                                                 *lsp-options* *LspOptionsSet*
433                                                 *g:LspOptionsSet*
434
435 Some of the LSP plugin features can be enabled or disabled by using the
436 LspOptionsSet() function. This function accepts a dictionary argument with the
437 following optional items:
438
439                                                 *lsp-opt-aleSupport*
440 aleSupport              |Boolean| option. If true, diagnostics will be sent to
441                         Ale, instead of being displayed by this plugin.
442                         This is useful to combine all LSP and linter
443                         diagnostics. By default this is set to false.
444
445                                                 *lsp-opt-autoComplete*
446 autoComplete            |Boolean| option. In insert mode, automatically
447                         complete the current symbol. Otherwise use
448                         omni-completion. By default this is set to true.
449
450                                                 *lsp-opt-autoHighlight*
451 autoHighlight           |Boolean| option. In normal mode, automatically
452                         highlight all the occurrences of the symbol under the
453                         cursor. By default this is set to false.
454
455                                                 *lsp-opt-autoHighlightDiags*
456 autoHighlightDiags      |Boolean| option. Automatically place signs on the
457                         lines with a diagnostic message from the language
458                         server. By default this is set to true.
459
460                                                 *lsp-opt-autoPopulateDiags*
461 autoPopulateDiags       |Boolean| option. Automatically populate the location
462                         list with diagnostics from the language server.
463                         By default this is set to false.
464
465                                                 *lsp-opt-completionMatcher*
466 completionMatcher       |String| option.  Enable fuzzy or case insensitive
467                         completion for language servers that replies with a
468                         full list of completion items.  Some language servers
469                         does completion filtering in the server, while other
470                         relies on the client to do the filtering.
471
472                         This option only works for language servers that
473                         expect the client to filter the completion items.
474
475                         This option accepts one of the following values:
476                             case  - case sensitive matching (default).
477                             fuzzy - fuzzy match completion items.
478                             icase - ignore case when matching items.
479
480                                                 *lsp-opt-completionTextEdit*
481 completionTextEdit      |Boolean| option.  If true, apply the LSP server
482                         supplied text edits after a completion.  If a snippet
483                         plugin is going to apply the text edits, then set
484                         this to false to avoid applying the text edits twice.
485                         By default this is set to true.
486
487                                                 *lsp-opt-completionKinds*
488 completionKinds         |Dictionary| option. See |lsp-custom-kinds| for all
489                         completion kind names.
490
491                                         *lsp-opt-customCompletionKinds*
492 customCompletionKinds   |Boolean| option.  If you set this to true, you can
493                         set custom completion kinds using the option
494                         completionKinds.
495
496                                                 *lsp-opt-diagSignErrorText*
497 diagSignErrorText       |String| option. Change diag sign text for errors
498                         By default 'E>'
499
500                                                 *lsp-opt-diagSignHintText*
501 diagSignHintText        |String| option. Change diag sign text for hints
502                         By default 'H>',
503
504                                                 *lsp-opt-diagSignInfoText*
505 diagSignInfoText        |String| option. Change diag sign text for info
506                         By default 'I>',
507
508                                                 *lsp-opt-diagSignWarningText*
509 diagSignWarningText     |String| option. Change diag sign text for warnings
510                         By default 'W>',
511
512                                                 *lsp-opt-diagVirtualTextAlign*
513 diagVirtualTextAlign    |String| option.   Alignment of diagnostics messages
514                         if |lsp-opt-showDiagWithVirtualText| is set to true.
515                         Allowed values are 'above', 'below' or 'after'
516                         By default this is set to 'above',
517
518                                                 *lsp-opt-echoSignature*
519 echoSignature           |Boolean| option.  In insert mode, echo the current
520                         symbol signature instead of showing it in a popup.
521                         By default this is set to false.
522
523                                         *lsp-opt-hideDisabledCodeActions*
524 hideDisabledCodeActions |Boolean| option. Hide all the disabled code actions.
525                         By default this is set to false.
526
527                                                 *lsp-opt-highlightDiagInline*
528 highlightDiagInline     |Boolean| option.  Highlight the diagnostics inline.
529                         By default this is set to true.
530
531                                                 *lsp-opt-hoverInPreview*
532 hoverInPreview          |Boolean| option. Show |:LspHover| in a preview window
533                         instead of a popup.
534                         By default this is set to false.
535
536                                                 *lsp-opt-ignoreMissingServer*
537 ignoreMissingServer     |Boolean| option.  Do not print a missing language
538                         server executable.  By default this is set to false.
539
540                                                 *lsp-opt-keepFocusInDiags*
541 keepFocusInDiags        |Boolean| option.  Focus on the location list window
542                         after ":LspDiag show".
543                         By default this is set to true.
544
545                                         *lsp-opt-keepFocusInReferences*
546 keepFocusInReferences   |Boolean| option.  Focus on the location list window
547                         after LspShowReferences.
548                         By default this is set to true.
549
550                                         *lsp-opt-noNewlineInCompletion*
551 noNewlineInCompletion   |Boolean| option.  Suppress adding a new line on
552                         completion selection with <CR>.
553                         By default this is set to false.
554
555                                                 *lsp-opt-outlineOnRight*
556 outlineOnRight          |Boolean| option.  Open the outline window on the
557                         right side, by default this is false.
558
559                                                 *lsp-opt-outlineWinSize*
560 outlineWinSize          |Number| option.  The size of the symbol Outline
561                         window.  By default this is set to 20.
562
563                                                 *lsp-opt-showDiagInBalloon*
564 showDiagInBalloon       |Boolean| option.  When the mouse is over a range of
565                         text referenced by a diagnostic, display the
566                         diagnostic text in a balloon.  By default this is set
567                         to true.  In a GUI Vim, this needs the |+balloon_eval|
568                         feature.  In a terminal Vim, this needs the
569                         |+balloon_eval_term| feature.  In a terminal Vim,
570                         'mouse' option should be set to enable mouse.
571                         If this option is set to true, then the 'ballooneval'
572                         and 'balloonevalterm' options are set.
573
574                                                 *lsp-opt-showDiagInPopup*
575 showDiagInPopup         |Boolean| option.  When using the ":LspDiag current"
576                         command to display the diagnostic message for the
577                         current line, use a popup window to display the
578                         message instead of echoing in the status area.
579                         By default this is set to true.
580
581                                                 *lsp-opt-showDiagOnStatusLine*
582 showDiagOnStatusLine    |Boolean| option.  Show a diagnostic message on a
583                         status line.  By default this is set to false.
584
585                                                 *lsp-opt-showDiagWithSign*
586 showDiagWithSign        |Boolean| option.  Place a sign on lines with
587                         diagnostics.  By default this is set to true.  The
588                         "autoHighlightDiags" option should be set to true.
589
590                                         *lsp-opt-showDiagWithVirtualText*
591 showDiagWithVirtualText |Boolean| option.  Show diagnostic message text from
592                         the language server with virtual text.  By default
593                         this is set to false.  The "autoHighlightDiags" option
594                         should be set to true.
595                         Needs Vim version 9.0.1157 or later.
596
597                                                 *lsp-opt-showInlayHints*
598 showInlayHints          |Boolean| option.  Show inlay hints from the language
599                         server.  By default this is set to false.  The inlay
600                         hint text is displayed as a virtual text.  Needs Vim
601                         version 9.0.0178 or later.
602
603                                                 *lsp-opt-showSignature*
604 showSignature           |Boolean| option.  In insert mode, automatically show
605                         the current symbol signature in a popup.
606                         By default this is set to true.
607
608                                                 *lsp-opt-snippetSupport*
609 snippetSupport          |Boolean| option.  Enable snippet completion support.
610                         Need a snippet completion plugin like vim-vsnip.
611                         By default this is set to false.
612
613                                                 *lsp-opt-ultisnipsSupport*
614 ultisnipsSupport        |Boolean| option.  Enable SirVer/ultisnips support.
615                         Need a snippet completion plugin SirVer/ultisnips.
616                         By default this is set to false.
617
618                                                 *lsp-opt-vssnipSupport*
619 vsnipSupport            |Boolean| option.  Enable hrsh7th/vim-vsnip support.
620                         Need snippet completion plugins hrsh7th/vim-vsnip
621                         and hrsh7th/vim-vsnip-integ.  Make sure
622                         ultisnipsSupport is set to false before enabling this.
623                         By default this option is set to false.
624
625                                                 *lsp-opt-usePopupInCodeAction*
626 usePopupInCodeAction    |Boolean| option.  When using the |:LspCodeAction|
627                         command to display the code action for the current
628                         line, use a popup menu instead of echoing.
629                         By default this is set to false.
630
631                                         *lsp-opt-useQuickfixForLocations*
632 useQuickfixForLocations |Boolean| option.  Show |:LspShowReferences| in a
633                         quickfix list instead of a location list.
634                         By default this is set to false.
635
636                                                 *lsp-opt-useBufferCompletion*
637 useBufferCompletion     |Boolean| option. If enabled, the words from the
638                         current buffer are added to the auto completion list.
639                         By default this is set to false.
640
641                                                 *lsp-opt-bufferCompletionTimeout*
642 bufferCompletionTimeout |Number| option. Specifies how long (in milliseconds) 
643                         to wait while processing current buffer for 
644                         autocompletion words.  If set too high Vim performance
645                         may degrade as the current buffer contents are
646                         processed every time the completion menu is displayed.
647                         If set to 0 the entire buffer is processed without
648                         regard to timeout.
649                         By default this is set to 100 ms.
650
651 For example, to disable the automatic placement of signs for the LSP
652 diagnostic messages, you can add the following line to your .vimrc file: >
653
654         LspOptionsSet({'autoHighlightDiags': false})
655 <
656 The LspOptionsGet() function returns a |Dict| of all the LSP plugin options,
657 To get a particular option value you can use the following: >
658
659         echo LspOptionsGet()['autoHighlightDiags']
660 <
661 ==============================================================================
662 5. Commands                                     *lsp-commands*
663
664 A description of the various commands provided by this plugin is below.  You
665 can map these commands to keys and make it easier to invoke them.
666
667                                                 *:LspCodeAction*
668 :LspCodeAction [query]  Apply the code action supplied by the language server
669                         to the diagnostic in the current line. This works only
670                         if there is a diagnostic message for the current line.
671                         You can use the ":LspDiag current" command to display
672                         the diagnostic for the current line.
673
674                         When [query] is given the code action starting with
675                         [query] will be applied. [query] can be a regexp
676                         pattern, or a digit corresponding to the index of the
677                         code actions in the created prompt.
678
679                         When [query] is not given you will be prompted to
680                         select one of the actions supplied by the language
681                         server.
682
683                                                 *:LspCodeLens*
684 :LspCodeLens            Display a list of code lens commands available for the
685                         current buffer and apply the selected code lens
686                         command.
687
688                                                 *:LspDiag-current*
689 :LspDiag current        Displays the diagnostic message (if any) for the
690                         current line.  If the option 'showDiagInPopup' is set
691                         to true (default), then the message is displayed in
692                         a popup window.  Otherwise the message is displayed in
693                         the status message area.
694
695 :LspDiag! current       Only display a diagnostic message if it's directly
696                         under the cursor.  Otherwise works exactly like
697                         ":LspDiag current"
698
699                         To show the current diagnotic under the cursor while
700                         moving around the following autocmd can be used: >
701
702                             augroup LspCustom
703                               au!
704                               au CursorMoved * silent! LspDiag! current
705                             augroup END
706 <
707                                                 *:LspDiag-first*
708 :LspDiag first          Jumps to the location of the first diagnostic message
709                         for the current file.
710
711                                                 *:LspDiag-here*
712 :LspDiag here           Jumps to the location of the diagnostic message in
713                         the current line (start from current column).
714
715 :LspDiag highlight disable                      *:LspDiag-highlight-disable*
716                         Disable highlighting lines with a diagnostic message
717                         for the current Vim session.
718                         To always disable the highlighting, set the
719                         autoHighlightDiags option to false.
720
721 :LspDiag highlight enable                       *:LspDiag-highlight-enable*
722                         Enable highlighting lines with a diagnostic message
723                         for the current Vim session.  Note that highlighting
724                         lines with a diagnostic message is enabled by default.
725
726                                                 *:LspDiag-last*
727 :LspDiag last           Jumps to the location of the first diagnostic message
728                         for the current file.
729
730                                                 *:LspDiag-next*
731 :[count]LspDiag next    Go to the [count] diagnostic message after the current
732                         cursor position.  If [count] is omitted, then 1 is
733                         used.  If [count] exceeds the number of diagnostics
734                         after the current position, then the last diagnostic
735                         is selected.
736
737                                                 *:LspDiag-prev*
738 :[count]LspDiag prev    Go to the [count] diagnostic message before the
739                         current cursor position.  If [count] is omitted, then
740                         1 is used.  If [count] exceeds the number of
741                         diagnostics before the current position, then first
742                         last diagnostic is selected.
743
744                                                 *:LspDiag-show*
745 :LspDiag show           Creates a new location list with the diagnostics
746                         messages (if any) from the language server for the
747                         current file and opens the location list window. You
748                         can use the Vim location list commands to browse the
749                         list.
750
751                                                 *:LspDocumentSymbol*
752 :LspDocumentSymbol      Display the symbols in the current file in a popup
753                         menu.  When a symbol is selected in the popup menu by
754                         pressing <Enter> or <Space>, jump to the location of
755                         the symbol.
756
757                         The <Up>, <Down>, <C-F>, <C-B>, <PageUp>, <PageDown>,
758                         <C-Home>, <C-End>, <C-N>, <C-P> keys can be used to
759                         scroll the popup menu.  The <Esc> or <Ctrl-C> keys can
760                         be used to cancel the popup menu.
761
762                         If one or more keyword characters are typed, then only
763                         the symbols containing the keyword characters are
764                         displayed in the popup menu.  Fuzzy searching is used
765                         to get the list of matching symbols.  The <BS> key can
766                         be used to erase the last typed character.  The <C-U>
767                         key can be used to erase all the characters.
768
769                         When scrolling through the symbols in the popup menu,
770                         the corresponding range of lines is highlighted.
771
772                                                 *:LspFold*
773 :LspFold                Create folds for the current buffer.
774
775                                                 *:LspFormat*
776 :LspFormat              Format the current file using the language server. The
777                         'shiftwidth' and 'expandtab' values set for the
778                         current buffer are used when format is applied.
779
780 :{range}LspFormat       Format the specified range of lines in the current
781                         file using the language server.
782
783                                                 *:LspGotoDeclaration*
784 :[count]LspGotoDeclaration
785                         Jumps to the declaration of the symbol under the
786                         cursor. The behavior of this command is similar to the
787                         |:LspGotoDefinition| command.
788
789                                                 *:LspGotoDefinition*
790 :[count]LspGotoDefinition
791                         Jumps to the [count] definition of the symbol under
792                         the cursor.  If there are multiple matches and [count]
793                         isn't specified, then a location list will be created
794                         with the list of locations.
795
796                         If there is only one location, or [count] is provided
797                         then the following will apply:
798
799                         If the file is already present in a window, then jumps
800                         to that window.  Otherwise, opens the file in a new
801                         window.  If the current buffer is modified and
802                         'hidden' is not set or if the current buffer is a
803                         special buffer, then a new window is opened.  If the
804                         jump is successful, then the current cursor location
805                         is pushed onto the tag stack.  The |CTRL-T| command
806                         can be used to go back up the tag stack.  Also the
807                         |``| mark is set to the position before the jump.
808
809                         This command supports |:command-modifiers|.  You can
810                         use the modifiers to specify whether a new window or
811                         a new tab page is used and where the window is opened.
812                         Example(s): >
813
814                             # Open a horizontally split window
815                             :topleft LspGotoDefinition
816                             # Open a vertically split window
817                             :vert LspGotoDefinition
818                             # Open a new tab page
819                             :tab LspGotoDefinition
820 <
821                         You may want to map a key to invoke this command: >
822
823             nnoremap <buffer> gd <Cmd>LspGotoDefinition<CR>
824             nnoremap <buffer> <C-W>gd <Cmd>topleft LspGotoDefinition<CR>
825 <
826                         Or if you want to support [count]gd >
827
828             nnoremap <buffer> gd <Cmd>execute v:count .. 'LspGotoDefinition'<CR>
829             nnoremap <buffer> <C-W>gd <Cmd>execute 'topleft ' .. v:count .. 'LspGotoDefinition'<CR>
830 <
831                                                 *:LspGotoImpl*
832 :[count]LspGotoImpl     Jumps to the implementation of the symbol under the
833                         cursor. The behavior of this command is similar to the
834                         |:LspGotoDefinition| command. Note that not all the
835                         language servers support this feature.
836
837                         You may want to map a key to invoke this command: >
838
839                             nnoremap <buffer> gi <Cmd>LspGotoImpl<CR>
840 <
841                                                 *:LspGotoTypeDef*
842 :[count]LspGotoTypeDef  Jumps to the type definition of the symbol under the
843                         cursor. The behavior of this command is similar to the
844                         |:LspGotoDefinition| command. Note that not all the
845                         language servers support this feature.
846
847                         You may want to map a key to invoke this command: >
848
849                             nnoremap <buffer> gt <Cmd>LspGotoTypeDef<CR>
850 <
851                                                 *:LspHighlight*
852 :LspHighlight           Highlights all the matches for the symbol under
853                         cursor. The text, read and write references to the
854                         symbol are highlighted using Search, DiffChange and
855                         DiffDelete highlight groups respectively.
856
857                                                 *:LspHighlightClear*
858 :LspHighlightClear      Clears all the symbol matches highlighted by the
859                         |:LspHighlight| command.
860
861                                                 *:LspHover*
862 :LspHover               Show the documentation for the symbol under the cursor
863                         in a popup window. If you want to show the symbol
864                         documentation in the preview window instead of in a
865                         popup set >
866
867                             LspOptionsSet({'hoverInPreview': true})
868 <
869                         You can use the |K| key in normal mode to display the
870                         documentation for the keyword under the cursor by
871                         setting the 'keywordprg' Vim option: >
872
873                             :set keywordprg=:LspHover
874 <
875                                                 *:LspIncomingCalls*
876 :LspIncomingCalls       Display a hierarchy of symbols calling the symbol
877                         under the cursor in a window.  See
878                         |lsp-call-hierarchy| for more information.  Note that
879                         not all the language servers support this feature.
880
881                                                 *:LspInlayHints*
882 :LspInlayHints          Enable or disable inlay hints.  Supports the "enable"
883                         and "disable" arguments.  When "enable" is specified,
884                         enables the inlay hints for all the buffers with a
885                         language server that supports inlay hints.  When
886                         "disable" is specified, disables the inlay hints.
887
888                                                 *:LspOutoingCalls*
889 :LspOutoingCalls        Display a hierarchy of symbols called by the symbol
890                         under the cursor in a window.  See
891                         |lsp-call-hierarchy| for more information.  Note that
892                         not all the language servers support this feature.
893
894                                                 *:LspOutline*
895 :[count]LspOutline      Opens a vertically split window with the list of
896                         symbols defined in the current file. The current
897                         symbol is highlighted. The symbols are grouped by
898                         their type. You can select a symbol and press <Enter>
899                         to jump to the position of the symbol. As you move the
900                         cursor in a file, the current symbol is automatically
901                         highlighted in the outline window. If you open a new
902                         file, the outline window is automatically updated with
903                         the symbols in the new file.  Folds are created in the
904                         outline window for the various group of symbols.
905
906                         You can use |lsp-opt-outlineOnRight| and
907                         |lsp-opt-outlineWinSize| to customize the placement
908                         and size of the window.
909
910                         This command also supports |:command-modifiers|.  You
911                         can use the modifiers specify the position of the
912                         window.  Note that the default is ":vert :topleft" or
913                         ":vert :botright" depending on
914                         |lsp-opt-outlineOnRight|
915
916                         This command also supports providing a [count] to
917                         specify the size of the window.  Note that this
918                         overrides the values defined in
919                         |lsp-opt-outlineWinSize|.
920                         Example: >
921
922                             # Open the outline window just above the current
923                             # window
924                             :aboveleft LspOutline
925
926                             # Open the outline window just next to the current
927                             # window, this is different from the default, when
928                             # you have multiple splits already
929                             :vert aboveleft LspOutline
930
931                             # Same as above, but with a width of 50
932                             :vert aboveleft 50LspOutline
933 <
934                                                 *:LspPeekDeclaration*
935 :[count]LspPeekDeclaration
936                         Displays the line where the symbol under the
937                         cursor is declared in a popup window. The
938                         behavior of this command is similar to the
939                         |:LspPeekDefinition| command.
940
941                                                 *:LspPeekDefinition*
942 :[count]LspPeekDefinition
943                         Displays the line where the symbol under the cursor is
944                         defined in a popup window. The symbol is highlighted
945                         in the popup window. Moving the cursor or pressing
946                         <Esc> will close the popup window.
947                         When more than one symbol is found all of them will be
948                         shown.  The corresponding file for the symbol is
949                         displayed in another popup window.  As the selection
950                         in the symbol popup menu changes, the file in the
951                         popup is updated.
952                         When [count] is provided only the [count] symbol will
953                         be shown.
954
955                                                 *:LspPeekImpl*
956 :[count]LspPeekImpl     Displays the implementation of the symbol under the
957                         cursor in a popup window. The behavior of this
958                         command is similar to the |:LspPeekDefinition|
959                         command. Note that not all the language servers
960                         support this feature.
961
962                                                 *:LspPeekReferences*
963 :LspPeekReferences      Displays the list of references to the symbol under
964                         cursor in a popup menu.  The corresponding file for
965                         the reference is displayed in another popup window.
966                         As the selection in the reference popup menu changes,
967                         the file in the popup is updated.
968
969                                                 *:LspPeekTypeDef*
970 :[count]LspPeekTypeDef  Displays the line where the type of the symbol under
971                         the cursor is defined in a popup window. The
972                         behavior of this command is similar to the
973                         |:LspPeekDefinition| command. Note that not all the
974                         language servers support this feature.
975
976                                                 *:LspRename*
977 :LspRename [newName]    Rename the current symbol.
978
979                         When [newName] is not given, then you will be prompted
980                         to enter the new name for the symbol. You can press
981                         <Esc> or enter an empty string in the prompt to cancel
982                         the operation.
983
984                                                 *:LspSelectionExpand*
985 :LspSelectionExpand     Visually select the region of the symbol under the
986                         cursor.  In visual mode, expands the current symbol
987                         visual region selection to include the next level.
988
989                         For example, if the cursor is on a "for" statement,
990                         this command selects the "for" statement and the body
991                         of the "for" statement.
992
993                         It is useful to create a visual map to use this
994                         command.  Example: >
995
996                         xnoremap <silent> <Leader>e <Cmd>LspSelectionExpand<CR>
997 <
998                         With the above map, you can press "\e" in visual mode
999                         successively to expand the current symbol visual
1000                         region.
1001
1002                                                 *:LspSelectionShrink*
1003 :LspSelectionShrink     Shrink the current symbol range visual selection. It
1004                         is useful to create a visual map to use this command.
1005                         Example: >
1006
1007                         xnoremap <silent> <Leader>s <Cmd>LspSelectionShrink<CR>
1008 <
1009                         With the above map, you can press "\s" in visual mode
1010                         successively to shrink the current symbol visual
1011                         region.
1012
1013                                                 *:LspServer*
1014 :LspServer { debug | restart | show | trace }
1015                         Command to display and control the language server for
1016                         the current buffer.  Each argument has additional
1017                         sub-commands which are described below.
1018
1019                         debug { on | off | messages | errors }
1020                             Command to enable or disable the language server
1021                             debug messages and to display the debug messages
1022                             and error messages received from the language
1023                             server.  The following sub-commands are supported:
1024                                 errors  Open the log file containing the
1025                                         language server error messages.
1026                                 messages
1027                                         Open the log file containing the
1028                                         language server debug messages.
1029                                 off     Disable the logging of the language
1030                                         server messages.
1031                                 on      Enable the logging of the messages
1032                                         emitted by the language server in the
1033                                         standard output and standard error.
1034                             By default, the language server messages are not
1035                             logged.  On a Unix-like system, when enabled,
1036                             these messages are logged to the
1037                             /tmp/lsp-<server-name>.log and
1038                             /tmp/lsp-<server-name>.err file respectively.  On
1039                             MS-Windows, the %TEMP%/lsp-<server-name>.log and
1040                             %TEMP%/lsp-<server-name>.err% files are used. See
1041                             |lsp-debug| for more information.
1042
1043                         restart
1044                             Restart (stop and then start) the language server
1045                             for the current buffer. All the loaded buffers
1046                             with the same filetype as the current buffer are
1047                             added back to the server.
1048
1049                         show {capabilities | initializeRequest | messages
1050                                                                 | status}
1051                             The following sub-commands are supported:
1052                                 capabilities
1053                                         Display the list of language server
1054                                         capabilities for the current buffer.
1055                                         The server capabilities are described
1056                                         in the LSP protocol specification
1057                                         under the "ServerCapabilities"
1058                                         interface.
1059                                 initializeRequest
1060                                         Display the contents of the language
1061                                         server initialization request message
1062                                         (initialize).
1063                                 messages
1064                                         Display the log messages received from
1065                                         the language server.  This includes
1066                                         the messages received using the
1067                                         "window/logMessage" and "$/logTrace"
1068                                         LSP notifications.
1069                                 status
1070                                         Display the language server status for
1071                                         the current buffer.  The output shows
1072                                         the path to the language server
1073                                         executable and the server status.
1074
1075                         trace { off | messages | verbose }
1076                             Set the language server debug trace value using
1077                             the "$/setTrace" command.
1078
1079                                                 *:LspShowAllServers*
1080 :LspShowAllServers      Displays the list of registered language servers and
1081                         their status.  The language servers are registered
1082                         using the LspAddServer() function.  The output is
1083                         displayed in a scratch buffer.  The output shows the
1084                         Vim file type, the corresponding language server
1085                         status and the path to the language server executable.
1086                         The language server information for each buffer is
1087                         also shown.
1088
1089                                                 *:LspShowReferences*
1090 :LspShowReferences      Creates a new location list with the list of locations
1091                         where the symbol under the cursor is referenced and
1092                         opens the location window.  If you want to show the
1093                         references in a quickfix list instead of in a location
1094                         list set >
1095
1096                         LspOptionsSet({'useQuickfixForLocations': true})
1097 <
1098                                                 *:LspShowSignature*
1099 :LspShowSignature       Displays the signature of the symbol (e.g. a function
1100                         or method) before the cursor in a popup.
1101
1102                         The popup is also automatically displayed in insert
1103                         mode after entering a symbol name followed by a
1104                         separator (e.g. a opening parenthesis). To disable
1105                         this, you can set the showSignature option to false in
1106                         your .vimrc file: >
1107
1108                         LspOptionsSet({'showSignature': false})
1109 <
1110                         Default is true.
1111
1112                         You can get the function signature echoed in cmdline
1113                         rather than displayed in popup if you use >
1114
1115                         LspOptionsSet({'echoSignature': true})
1116 <
1117                         Default is false.
1118
1119                                                 *:LspSubTypeHierarchy*
1120 :LspSubTypeHierarchy    Show the sub type hierarchy for the symbol under the
1121                         cursor in a popup window.  The file containing the
1122                         type is shown in another popup window.  You can jump
1123                         to the location where a type is defined by browsing
1124                         the popup menu and selecting an entry.
1125
1126                                                 *:LspSuperTypeHierarchy*
1127 :LspSuperTypeHierarchy  Show the super type hierarchy for the symbol under the
1128                         cursor in a popup window.  The file containing the
1129                         type is shown in another popup window.  As the current
1130                         entry in the type hierarchy popup menu changes, the
1131                         file popup window is updated to show the location
1132                         where the type is defined.  You can jump to the
1133                         location where a type is defined by selecting the
1134                         entry in the popup menu.
1135
1136                         Note that the type hierarchy support is based on the
1137                         protocol supported by clangd.  This is different from
1138                         the one specified in the 3.17 of the LSP standard.
1139
1140                                                 *:LspSwitchSourceHeader*
1141 :LspSwitchSourceHeader  Switch between source and header files. This is a
1142                         Clangd specific extension and only works with C/C++
1143                         source files.
1144
1145                                                 *:LspSymbolSearch*
1146 :LspSymbolSearch <sym>  Perform a workspace wide search for the symbol <sym>.
1147                         If <sym> is not supplied, then you will be prompted to
1148                         enter the symbol name (the keyword under the cursor is
1149                         used as the default).  If there is only one matching
1150                         symbol, then the cursor will be positioned at the
1151                         symbol location.  Otherwise a popup window is opened
1152                         with the list of matching symbols.  You can enter a
1153                         few characters to narrow down the list of matches. The
1154                         displayed symbol name can be erased by pressing
1155                         <Backspace> or <C-U> and a new symbol search pattern
1156                         can be entered.  You can close the popup menu by
1157                         pressing the escape key or by pressing CTRL-C.
1158
1159                         In the popup menu, the following keys can be used:
1160
1161                                 CTRL-F     - Scroll one page forward
1162                                 <PageDown> - idem
1163                                 CTRL-B     - Scroll one page backward
1164                                 <PageUp>   - idem
1165                                 CTRL-Home  - Jump to the first entry
1166                                 CTRL-End   - Jump to the last entry
1167                                 <Up>       - Go up one entry
1168                                 <C-P>      - idem
1169                                 <Down>     - Go down one entry
1170                                 <C-N>      - idem
1171                                 <Enter>    - Open the selected file
1172                                 <Esc>      - Close the popup menu
1173                                 <CTRL-C>   - idem
1174                                 <BS>       - Erase one character from the
1175                                              filter text
1176                                 <C-H>      - idem
1177                                 <C-U>      - Erase the filter text
1178
1179                         Any other alphanumeric key will be used to narrow down
1180                         the list of names displayed in the popup menu. When
1181                         you type a filter string, then only the symbols fuzzy
1182                         matching the string are displayed in the popup menu.
1183                         You can enter a new search pattern to do a workspace
1184                         wide symbol search.
1185
1186                         This command accepts |:command-modifiers| which can be
1187                         used to jump to a symbol in a horizontally or
1188                         vertically split window or a new tab page: >
1189
1190                                 :topleft LspSymbolSearch foo
1191                                 :vert LspSymbolSearch bar
1192                                 :tab LspSymbolSearch baz
1193 <
1194                                                 *:LspWorkspaceAddFolder*
1195 :LspWorkspaceAddFolder {folder}
1196                         Add a folder to the workspace
1197
1198 :LspWorkspaceListFolders                        *:LspWorkspaceListFolders*
1199                         Show the list of folders in the workspace.
1200
1201                                                 *:LspWorkspaceRemoveFolder*
1202 :LspWorkspaceRemoveFolder {folder}
1203                         Remove a folder from the workspace
1204
1205 ==============================================================================
1206 6. Insert mode completion                   *lsp-ins-mode-completion*
1207
1208 By default, in insert mode, the LSP plugin automatically displays the matches
1209 for the symbol under the cursor in an insert-completion popup menu. You can
1210 use the keys described in |popupmenu-keys| with this menu.
1211
1212 To disable the auto-completion for all the files, you can set the
1213 'autoComplete' option to false in your .vimrc file: >
1214
1215         LspOptionsSet({'autoComplete': false})
1216 <
1217 If this variable is set, then the LSP plugin will not automatically start
1218 completion in insert mode and instead supports omni-completion (|compl-omni|).
1219 It sets the 'omnifunc' option for the buffers which have a registered language
1220 server. To complete a symbol in insert mode manually, you can press CTRL-X
1221 CTRL-O to invoke completion using the items suggested by the language server.
1222
1223 You can also enable or disable omni-completion for a specific language
1224 server by setting the 'omnicompl' item to 'false' when registering a lsp
1225 server for the filetype. If this item is not specified, then omni-completion
1226 is enabled by default. The following example disables omni-completion for
1227 python: >
1228
1229     vim9script
1230     var lspServers = [
1231                      {
1232                         filetype: 'python',
1233                         omnicompl: false,
1234                         path: '/usr/local/bin/pyls',
1235                         args: ['--check-parent-process', '-v']
1236                      }
1237                    ]
1238 <
1239 If you want to use omni completion, in addition to the automatic completion,
1240 then you can set the 'omnifunc' option to the "g:LspOmniFunc" function: >
1241
1242         set omnifunc=g:LspOmniFunc
1243 <
1244 To use omni completion, press CTRL-X CTRL-O in insert mode.  Refer to
1245 |compl-omni| for more information.
1246
1247 When doing insert-mode completion, the plugin sends a request message to the
1248 language server to return a list of possible completion matches for the
1249 current cursor position.  The plugin retrieves the keyword before the cursor
1250 (see 'iskeyword') and then filters the returned list of completion items
1251 against this keyword and displays the completion menu.  Some language servers
1252 does completion filtering in the server, while other relies on the client to
1253 do the filtering.  By default, case sensitive comparison is used to filter the
1254 returned items.  You can modify the 'completionMatcher' option to use either
1255 case insensitive or fuzzy comparison.
1256
1257 ==============================================================================
1258 7. Diagnostics                                          *lsp-diagnostics*
1259
1260 When a source file has syntax errors or warnings or static analysis warnings,
1261 the LSP plugin highlights them by placing |signs| in the |sign-column|.  You
1262 can use the ":LspDiag show" command to display all the diagnostic messages for
1263 the current file in a |location-list-window|.  You can use the
1264 ":LspDiag first" command to jump to the line with the first diagnostic
1265 message, the ":LspDiag next" command to jump to the next nearest line with the
1266 diagnostic message, the ":LspDiag prev" command to jump to the previous
1267 nearest line with the diagnostic message, the ":LspDiag here" command to jump
1268 to the diagnostic message in the current line.  You can use the ":LspDiag
1269 current" command to display the entire diagnostic message from the language
1270 server for the current line.
1271
1272 By default, the lines with a diagnostic message have a sign placed on them and
1273 the range of text with the diagnostic is highlighted.  You can disable the
1274 automatic sign placement by setting the "showDiagWithSign" option to v:false.
1275 By default, this option is set to v:true.  You can disable the diagnostic text
1276 highlighting by setting the "highlightDiagInline" option to v:false. The line
1277 with the diagnostics is highlighted using the "LspDiagLine" highlight group.
1278 By default this highlight group is not set.
1279
1280 You can also display the diagnostic message as a virtual text near the
1281 location of the diagnostics by setting the "showDiagWithVirtualText" option to
1282 v:true.  This needs Vim version 9.0.1157 or later.  By default this option is
1283 set to v:false.  The position of the virtual text is controlled by the
1284 "diagVirtualTextAlign" option.  By default, this is set to 'above'.  The other
1285 supported values are 'below' and 'after'.
1286
1287 The range of text for a diagnostic message can be automatically highlighted by
1288 setting the "highlightDiagInline" option to v:true.  By default, this option
1289 is set to v:true.  The text is highlighted using the "LspDiagInlineError" or
1290 "LspDiagInlineHint" or "LspDiagInlineInfo" or "LspDiagInlineWarning" highlight
1291 group.
1292
1293 You can temporarily disable the automatic diagnostic highlighting for the
1294 current Vim session using the ":LspDiag highlight disable" command and
1295 re-enable them using the ":LspDiag highlight enable" command.
1296
1297 To disable the automatic highlighting of the diagnostics, you can set the
1298 'autoHighlightDiags' option to v:false: >
1299
1300         LspOptionsSet({'autoHighlightDiags': false})
1301 <
1302 By default the 'autoHighlightDiags' option is set to v:true.
1303
1304 The function lsp#lsp#ErrorCount() function can be used to get the count of the
1305 diagnostic messages in the current buffer by type.  This function returns a
1306 Dictionary with the following keys: Info, Hint, Warn and Error.  The value for
1307 these keys is the number of diagnostic messages of the corresponding type.
1308 This function can be used to display the number of diagnostics in the current
1309 buffer in a 'statusline'.
1310
1311 For some diagnostic errors/warnings, the language server may provide an
1312 automatic fix.  To apply this fix, you can use the |:LspCodeAction| command.
1313 This command applies the action provided by the language server (if any) for
1314 the current line.
1315
1316 The ":LspDiag show" command creates a new location list with the current list
1317 of diagnostics for the current buffer.  To automatically add the diagnostics
1318 messages to the location list, you can set the 'autoPopulateDiags' option to
1319 true. Â By default this option is set to false. Â When new diagnostics are
1320 received for a buffer, if a location list with the diagnostics is already
1321 present, then it is refreshed with the new diagnostics.
1322
1323 When using GUI Vim or in a terminal Vim with 'balloonevalterm' option set,
1324 when the mouse is moved over the range of text referenced by a diagnostic,
1325 then the diagnostic message is displayed in a popup.  If the
1326 "showDiagInBalloon" option is set to false, then the balloon popup will not be
1327 displayed.  By default, this option is set to true.
1328
1329 To display the diagnostic message for the current line in the status area, you
1330 can set the 'showDiagOnStatusLine' option to true.  By default, this option
1331 is set to false.
1332
1333 By default, the ":LspDiag current" command displays the diagnostic message
1334 for the current line in a popup window.  To display the message in the status
1335 message area instead, you can set the 'showDiagInPopup' option to false.  By
1336 default this is set to true.
1337
1338 The lsp#diag#GetDiagsForBuf() function can be used to get all the LSP
1339 diagnostics in a buffer. Â This function optionally accepts a buffer number.
1340 If the buffer number argument is not specified, then the current buffer is
1341 used. Â This function returns a |List| of diagnostics sorted by their line and
1342 column number. Â Each diagnostic is a |Dict| returned by the language server.
1343
1344 ==============================================================================
1345 8. Tag Function                                 *lsp-tagfunc*
1346
1347 The |:LspGotoDefinition| command can be used jump to the location where a
1348 symbol is defined.  To jump to the symbol definition using the Vim
1349 |tag-commands|, you can set the 'tagfunc' option to the 'lsp#lsp#TagFunc'
1350 function: >
1351
1352         setlocal tagfunc=lsp#lsp#TagFunc
1353 <
1354 After setting the above option, you can use |Ctrl-]| and other tag related
1355 commands to jump to the symbol definition.
1356
1357 Note that most of the language servers return only one symbol location even if
1358 the symbol is defined in multiple places in the code.
1359
1360 ==============================================================================
1361 9. Code Formatting                              *lsp-format*
1362
1363 The |:LspFormat| command can be used to format either the entire file or a
1364 selected range of lines using the language server.  The 'shiftwidth' and
1365 'expandtab' values set for the current buffer are used when format is applied.
1366
1367 To format code using the 'gq' command, you can set the 'formatexpr' option: >
1368
1369     setlocal formatexpr=lsp#lsp#FormatExpr()
1370 <
1371 ==============================================================================
1372 10. Call Hierarchy                              *lsp-call-hierarchy*
1373
1374 The |:LspIncomingCalls| and the |:LspOutoingCalls| commands can be used to
1375 display the call hierarchy of a symbol.  For example, the functions calling a
1376 function or the functions called by a function.  These two commands open a
1377 window containing the call hierarchy tree.  You can use the Vim motion
1378 commands to browse the call hierarchy.
1379
1380 In the call hierarchy tree window, the following keys are supported:
1381
1382 <Enter>                         Jump to the location of the symbol under the
1383                                 cursor.
1384 -                               Expand and show the symbols calling or called
1385                                 by the symbol under the cursor.
1386 +                               Close the call hierarchy for the symbol under
1387                                 the cursor.
1388
1389 You can display either the incoming call hierarchy or the outgoing call
1390 hierarchy in this window.  You cannot display both at the same time.
1391
1392 In the call hierarchy tree window, the following commands are supported:
1393
1394                                                 *:LspCallHierarchyRefresh*
1395 :LspCallHierarchyRefresh        Query the language server again for the top
1396                                 level symbol and refresh the call hierarchy
1397                                 tree.
1398                                                 *:LspCallHierarchyIncoming*
1399 :LspCallHierarchyIncoming       Display the incoming call hierarchy for the
1400                                 top level symbol.  If the window is currently
1401                                 displaying the outgoing calls, then it is
1402                                 refreshed to display the incoming calls.
1403                                                 *:LspCallHierarchyOutgoing*
1404 :LspCallHierarchyOutgoing       Display the outgoing call hierarchy for the
1405                                 top level symbol.  If the window is currently
1406                                 displaying the incoming calls, then it is
1407                                 refreshed to display the outgoing calls.
1408
1409 ==============================================================================
1410 11. Autocommands                                *lsp-autocmds*
1411
1412                                                 *LspAttached*
1413 LspAttached                     A |User| autocommand fired when the LSP client
1414                                 attaches to a buffer. Can be used to configure
1415                                 buffer-local mappings or options.
1416
1417                                                 *LspDiagsUpdated*
1418 LspDiagsUpdated                 A |User| autocommand invoked when new
1419                                 diagnostics are received from the language
1420                                 server.  This is invoked after the LSP client
1421                                 has processed the diagnostics. Â The function
1422                                 lsp#diag#GetDiagsForBuf() can be used to get
1423                                 all the diagnostics for a buffer.
1424
1425 ==============================================================================
1426 12. Highlight Groups                            *lsp-highlight-groups*
1427
1428 The following highlight groups are used by the LSP plugin.  You can define
1429 these highlight groups in your .vimrc file before sourcing this plugin to
1430 override them.
1431
1432 *LspDiagInlineError*            Used to highlight inline error diagnostics.
1433                                 By default, linked to the "SpellBad" highlight
1434                                 group.
1435 *LspDiagInlineHint*             Used to highlight inline hint diagnostics.
1436                                 By default, linked to the "SpellLocal"
1437                                 highlight group.
1438 *LspDiagInlineInfo*             Used to highlight inline info diagnostics.
1439                                 By default, linked to the "SpellRare"
1440                                 highlight group.
1441 *LspDiagInlineWarning*          Used to highlight inline warning diagnostics.
1442                                 By default, linked to the "SpellCap" highlight
1443                                 group.
1444 *LspDiagLine*                   Used to highlight a line with one or more
1445                                 diagnostics.  By default linked to "NONE"
1446                                 (cleared).  You can link this to a highlight
1447                                 group to highlight the line.
1448 *LspDiagSignErrorText*          Used to highlight the sign text for error
1449                                 diags.  By default linked to 'ErrorMsg'.
1450 *LspDiagSignHintText*           Used to highlight the sign text for hint
1451                                 diags.  By default linked to 'Question'.
1452 *LspDiagSignInfoText*           Used to highlight the sign text for info
1453                                 diags.  By default linked to 'Pmenu'.
1454 *LspDiagSignWarningText*        Used to highlight the sign text for warning
1455                                 diags.  By default linked to 'Search'.
1456 *LspDiagVirtualText*            Used to highlight diagnostic virtual text.
1457                                 By default, linked to the "LineNr" highlight
1458                                 group.
1459 *LspDiagVirtualTextError*       Used to highlight virtual text for error diags.
1460                                 By default, linked to the "SpellBad" highlight
1461                                 group.
1462 *LspDiagVirtualTextHint*        Used to highlight virtual text for hint
1463                                 diags.  By default, linked to the "SpellLocal"
1464                                 highlight group.
1465 *LspDiagVirtualTextInfo*        Used to highlight virtual text for info
1466                                 diags.  By default, linked to the "SpellRare"
1467                                 highlight group.
1468 *LspDiagVirtualTextWarning*     Used to highlight virtual text for warning
1469                                 diags.  By default, linked to the "SpellCap"
1470                                 highlight group.
1471 *LspInlayHintsParam*            Used to highlight inlay hints of kind
1472                                 "parameter".  By default, linked to the
1473                                 "Label" highlight group.
1474 *LspInlayHintsType*             Used to highlight inlay hints of kind "type".
1475                                 By default, linked to the "Conceal" highlight
1476                                 group.
1477 *LspSigActiveParameter*         Used to highlight the active signature
1478                                 parameter.  By default, linked to the "LineNr"
1479                                 highlight group.
1480 *LspSymbolName*                 Used to highlight the symbol name when using
1481                                 the |:LspDocumentSymbol| command.  By default,
1482                                 linked to the "Search" highlight group.
1483 *LspSymbolRange*                Used to highlight the range of lines
1484                                 containing a symbol when using the
1485                                 |:LspDocumentSymbol| command.  By default,
1486                                 linked to the "Visual" highlight group.
1487
1488 For example, to override the highlight used for diagnostics virtual text, you
1489 can use the following: >
1490
1491     highlight LspDiagVirtualText ctermfg=Cyan guifg=Blue
1492 <
1493 or >
1494
1495     highlight link LspDiagLine DiffAdd
1496     highlight link LspDiagVirtualText WarningMsg
1497 <
1498 ==============================================================================
1499 13. Debugging                                   *lsp-debug*
1500
1501 To debug this plugin, you can log the language server protocol messages sent
1502 and received by the plugin from the language server.  The following command
1503 enables the logging of the messages from the language server for the current
1504 buffer: >
1505
1506     :LspServer debug on
1507 <
1508 This command also clears the log files.  The following command disables the
1509 logging of the messages from the language server for the current buffer: >
1510
1511     :LspServer debug off
1512 <
1513 By default, the messages are not logged.  Another method to enable the debug
1514 is to set the "debug" field to true when adding a language server
1515 using |LspAddServer()|.
1516
1517 The messages printed by the language server in the stdout are logged to the
1518 lsp-<server-name>.log file and the messages printed in the stderr are logged
1519 to the lsp-<server-name>.err file.  On a Unix-like system, these files are
1520 created in the /tmp directory.  On MS-Windows, these files are created in the
1521 %TEMP% directory.
1522
1523 The following command opens the file containing the messages printed by the
1524 language server in the stdout: >
1525
1526     :LspServer debug messages
1527 <
1528 The following command opens the file containing the messages printed by the
1529 language server in the stderr: >
1530
1531     :LspServer debug errors
1532 <
1533 To debug language server initialization problems, after enabling the above
1534 server debug, you can restart the server for the file type in the current
1535 buffer using the following command: >
1536
1537     :LspServer restart
1538 <
1539 The language servers typically support command line options to enable debug
1540 messages and to increase the verbosity of the messages.  You can refer to the
1541 language server documentation for information about this.  You can include
1542 these options when registering the language server with this plugin.
1543
1544 If a language server supports the "$/logTrace" LSP notification, then you can
1545 use the :LspServerTrace command to set the server trace value: >
1546
1547     :LspServer trace { off | messages | verbose }
1548 <
1549 ==============================================================================
1550 14. Custom Command Handlers                     *lsp-custom-commands*
1551
1552 When applying a code action, the language server may issue a non-standard
1553 command.  For example, the Java language server uses non-standard commands
1554 (e.g. java.apply.workspaceEdit).  To handle these commands, you can register a
1555 callback function for each command using the LspRegisterCmdHandler() function.
1556 For example: >
1557
1558     vim9script
1559     import autoload "lsp/textedit.vim"
1560
1561     def WorkspaceEdit(cmd: dict<any>)
1562       for editAct in cmd.arguments
1563           textedit.ApplyWorkspaceEdit(editAct)
1564       endfor
1565     enddef
1566     g:LspRegisterCmdHandler('java.apply.workspaceEdit', WorkspaceEdit)
1567 <
1568 Place the above code in a file named lsp_java/plugin/lsp_java.vim and load
1569 this plugin.
1570
1571 The callback function should accept a Dict argument.  The Dict argument
1572 contains the LSP Command interface fields.  Refer to the LSP specification for
1573 more information about the "Command" interface.
1574
1575 ==============================================================================
1576 15. Custom LSP Completion Kinds                 *lsp-custom-kinds*
1577
1578 When a completion popup is triggered, the LSP client will use a default kind
1579 list to show in the completion "kind" section, to customize it, you need to
1580 use the option |lsp-opt-customCompletionKinds| and set all custom kinds in the
1581 option |lsp-opt-completionKinds| . There is a table with all default LSP
1582 kinds:
1583
1584  Kind Name              | Value
1585 ------------------------|--------------------
1586  Text                   | t
1587  Method                 | m
1588  Function               | f
1589  Constructor            | C
1590  Field                  | F
1591  Variable               | v
1592  Class                  | c
1593  Interface              | i
1594  Module                 | M
1595  Property               | p
1596  Unit                   | u
1597  Value                  | V
1598  Enum                   | e
1599  Keyword                | k
1600  Snippet                | S
1601  Color                  | C
1602  File                   | f
1603  Reference              | r
1604  Folder                 | F
1605  EnumMember             | E
1606  Constant               | d
1607  Struct                 | s
1608  Event                  | E
1609  Operator               | o
1610  TypeParameter          | T
1611  Buffer                 | B
1612
1613 For example, if you want to change the "Method" kind to the kind "method()": >
1614
1615         vim9script
1616
1617         g:LspOptionsSet({
1618                 customCompletionKinds: true,
1619                 completionKinds: {
1620                         "Method": "method()"
1621                 }
1622         })
1623 <
1624 In the completion popup, will show something like this: >
1625
1626         var file = new File()
1627
1628         file.cre
1629                 | create                method() |
1630                 | createIfNotExists     method() |
1631                 | ...                            |
1632 <
1633 ==============================================================================
1634 16. Multiple Language Servers for a buffer      *lsp-multiple-servers*
1635
1636 It's possible to run multiple language servers for a given buffer.
1637
1638 By default the language server defined first will be used for as much as it
1639 supports, then the next and so on. With the exception that diagnostics from
1640 all running language servers will be combined.
1641
1642 This means that you can define a language server that only supports a subset
1643 of features at first and then define the general purpose language server after
1644 it:
1645 >
1646         vim9script
1647
1648         g:LspAddServer([
1649                 # This language server reports that it only supports
1650                 # textDocument/documentFormatting, so it will be used
1651                 # for :LspFormat but nothing else.
1652                 {
1653                         filetype: ['html'],
1654                         path: 'html-pretty-lsp',
1655                         args: ['--stdio']
1656                 },
1657                 # This language server also supports
1658                 # textDocument/documentFormatting, but since it's been
1659                 # defined later, the one above will be used instead.
1660                 # However this server also supports
1661                 # textDocument/definition, textDocument/declaration,
1662                 # etc, so it will be used for :LspGotoDefinition,
1663                 # :LspGotoDeclaration, etc
1664                 {
1665                         filetype: ['html'],
1666                         path: 'html-language-server',
1667                         args: ['--stdio']
1668                 }
1669         ])
1670 <
1671 As shown in the example above the order of when the language servers are being
1672 defined is taken into account for a given method.  However sometimes the
1673 language server that you want to use for formatting also reports that it
1674 supports other features. In such a case you can do one of two things:
1675
1676 1. change the order of language servers, and specify that a given language
1677 server should be used for a given method.
1678
1679 2. set the unwanted features to |false| in the features |Dictionary| >
1680
1681         features: { 'codeAction': false }
1682 <
1683 For example, if you want to use the efm-langserver for formatting, but the
1684 typescript-language-server for everything else: >
1685
1686         vim9script
1687
1688         g:LspAddServer([
1689                 # this language server will be used by default, as it's defined
1690                 # as the first LSP for 'javascript' and 'typescript'
1691                 {
1692                         filetype: ['javascript', 'typescript'],
1693                         path: '/usr/local/bin/typescript-language-server',
1694                         args: ['--stdio']
1695                 },
1696                 # this language server will be used for documentFormatting
1697                 {
1698                         filetype: ['efm-langserver'],
1699                         path: '/usr/local/bin/efm-langserver',
1700                         args: [],
1701                         features: {
1702                                 documentFormatting: true
1703                         }
1704                 }
1705         ])
1706 <
1707 Another way is to disable the unwanted features: for example if you don't want
1708 diagnostics from the typescript-language-server, but want to use it for
1709 everything else: >
1710
1711         vim9script
1712
1713         g:LspAddServer([
1714                 {
1715                         filetype: ['javascript', 'typescript'],
1716                         path: '/usr/local/bin/typescript-language-server',
1717                         args: ['--stdio'],
1718                         features: {
1719                                 diagnostics: false
1720                         }
1721                 },
1722         ])
1723 <
1724 ==============================================================================
1725 17. Language Server Features                    *lsp-features*
1726
1727 When using multiple language servers for a given file type, by providing the
1728 configuration |lsp-cfg-features| it is possible to specify which language
1729 server should be used for a given method/functionality.  The following feature
1730 flags are supported: See |lsp-multiple-servers| for examples.
1731
1732                                                 *lsp-features-callHierarchy*
1733 callHierarchy                   Used by the|:LspIncomingCalls| and the
1734                                 |:LspOutgoingCalls| commands.
1735                                                 *lsp-features-codeAction*
1736 codeAction                      Used by the |:LspCodeAction| command.
1737                                                 *lsp-features-codeLens*
1738 codeLens                        Used by the |:LspCodeLens| command.
1739                                                 *lsp-features-completion*
1740 completion                      Used by 24/7 Completion and 'omnifunc'
1741                                                 *lsp-features-declaration*
1742 declaration                     Used by the |:LspGotoDeclaration|, and
1743                                 the |:LspPeekDeclaration| commands.
1744                                                 *lsp-features-definition*
1745 definition                      Used by the|:LspGotoDefinition|, and
1746                                 the |:LspPeekDefinition| commands.
1747                                                 *lsp-features-diagnostics*
1748 diagnostics                     Used to disable diagnostics for a single
1749                                 language server, by default diagnostics are
1750                                 combined from all running servers, by setting
1751                                 this to |false| you can ignore diagnostics
1752                                 from a specific server.
1753                                         *lsp-features-documentFormatting*
1754 documentFormatting              Used by the |:LspFormat| command, and
1755                                 'formatexpr'
1756                                         *lsp-features-documentHighlight*
1757 documentHighlight               Used by the |:LspHighlight| and the
1758                                 |:LspHighlightClear| commands.
1759                                         *lsp-features-documentSymbol*
1760 documentSymbol                  Used by the |:LspDocumentSymbol| and the
1761                                 |:LspOutline| commands.
1762                                                 *lsp-features-foldingRange*
1763 foldingRange                    Used by the|:LspFold| command.
1764                                                 *lsp-features-hover*
1765 hover                           Used by the |:LspHover| command.
1766                                                 *lsp-features-implementation*
1767 implementation                  Used by the |:LspGotoImpl| and the
1768                                 |:LspPeekImpl| commands.
1769                                                 *lsp-features-inlayHint*
1770 inlayHint                       Used to show the inlay hints for
1771                                 function/method arguments.
1772                                                 *lsp-features-references*
1773 references                      Used by the |:LspShowReferences| command.
1774                                                 *lsp-features-rename*
1775 rename                          Used by the |:LspRename| command.
1776                                                 *lsp-features-selectionRange*
1777 selectionRange                  Used by the |:LspSelectionExpand| and the
1778                                 |:LspSelectionShrink| commands.
1779                                                 *lsp-features-signatureHelp*
1780 signatureHelp                   Used by the |:LspShowSignature| command.
1781                                                 *lsp-features-typeDefinition*
1782 typeDefinition                  Used by the |:LspGotoTypeDef| and the
1783                                 |:LspPeekTypeDef| commands.
1784 typeHierarchy                   Used by the |:LspSubTypeHierarchy| and the
1785                                 |:LspSuperTypeHiearchy| commands.
1786 workspaceSymbol                 Used by the |:LspSymbolSearch| command.
1787
1788 ==============================================================================
1789                                                 *lsp-license*
1790 License: MIT License
1791 Copyright (c) 2020-2023 Yegappan Lakshmanan
1792
1793 Permission is hereby granted, free of charge, to any person obtaining a copy
1794 of this software and associated documentation files (the "Software"), to
1795 deal in the Software without restriction, including without limitation the
1796 rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
1797 sell copies of the Software, and to permit persons to whom the Software is
1798 furnished to do so, subject to the following conditions:
1799
1800 The above copyright notice and this permission notice shall be included in
1801 all copies or substantial portions of the Software.
1802
1803 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1804 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1805 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1806 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1807 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1808 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
1809 IN THE SOFTWARE.
1810
1811 ==============================================================================
1812
1813 vim:tw=78:ts=8:noet:ft=help:norl: