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