-
Notifications
You must be signed in to change notification settings - Fork 61
/
lsp.txt
2030 lines (1736 loc) · 79.9 KB
/
lsp.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
*lsp.txt* Language Server Protocol (LSP) Plugin for Vim9
Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
For Vim version 9.0 and above
Last change: Sep 30, 2024
==============================================================================
CONTENTS *lsp-contents*
1. Overview ................................. |lsp-overview|
2. Requirements ............................. |lsp-installation|
3. Usage .................................... |lsp-usage|
4. Configuration............................. |lsp-configuration|
5. Commands ................................. |lsp-commands|
6. Insert Mode Completion ................... |lsp-ins-mode-completion|
7. Diagnostics .............................. |lsp-diagnostics|
8. Tag Function ............................. |lsp-tagfunc|
9. LSP Formatting ........................... |lsp-format|
10. Call Hierarchy ........................... |lsp-call-hierarchy|
11. Autocommands ............................. |lsp-autocmds|
12. Highlight Groups ......................... |lsp-highlight-groups|
13. Debugging ................................ |lsp-debug|
14. Custom Command Handlers .................. |lsp-custom-commands|
15. Custom LSP Completion Kinds .............. |lsp-custom-kinds|
16. Multiple Language Servers for a buffer ... |lsp-multiple-servers|
17. Language Servers Features ................ |lsp-features|
18. License .................................. |lsp-license|
==============================================================================
1. Overview *lsp-overview*
The Language Server Protocol (LSP) plugin implements a LSP client for Vim9.
Refer to the following pages for more information about LSP:
https://microsoft.github.io/language-server-protocol/
https://langserver.org/
This plugin needs Vim version 9.0 and after. You will need a programming
language specific server in your system to use this plugin. Refer to the above
pages for a list of available language servers for the various programming
languages.
The Github repository for this plugin is available at:
http://github.com/yegappan/lsp
==============================================================================
2. Installation *lsp-installation*
You can install this plugin directly from github using the following steps:
$ mkdir -p $HOME/.vim/pack/downloads/opt
$ cd $HOME/.vim/pack/downloads/opt
$ git clone https://github.com/yegappan/lsp
$ vim -u NONE -c "helptags $HOME/.vim/pack/downloads/opt/lsp/doc" -c q
or you can use any one of the Vim plugin managers (dein.vim, pathogen, vam,
vim-plug, volt, Vundle, etc.) to install and manage this plugin.
To uninstall the LSP plugin, either use the uninstall command provided by the
plugin manager or manually remove the $HOME/.vim/pack/downloads/lsp directory.
To use this plugin, add the following line to your .vimrc file:
packadd lsp
==============================================================================
3. Usage *lsp-usage*
The following commands are provided:
:LspCodeAction Apply the code action supplied by the language server
to the diagnostic in the current line.
:LspCodeLens Display all the code lens commands available for the
current file and apply the selected command.
:LspDiag current Display the diagnostic message for the current line.
:LspDiag first Jump to the first diagnostic message for the current
buffer.
:LspDiag here Jump to the next diagnostic message in the current
line.
:LspDiag highlight disable
Disable highlighting lines with a diagnostic message
for the current Vim session.
:LspDiag highlight enable
Enable highlighting lines with a diagnostic message
for the current Vim session.
:LspDiag highlight toggle
Toggle highlighting lines with a diagnostic message
for the current Vim session.
:LspDiag last Jump to the last diagnostic message for the current
buffer.
:LspDiag next Jump to the next diagnostic message for the current
buffer after the current cursor position.
:LspDiag nextWrap Jump to the next diagnostic message for the current
buffer after the current cursor position.
Wrap back to the first message when no more messages
are found.
:LspDiag prev Jump to the previous diagnostic message for the
current buffer before the current cursor position.
:LspDiag prevWrap Jump to the previous diagnostic message for the
current buffer before the current cursor position.
Wrap back to the last message when no previous
messages are found.
:LspDiag show Display the diagnostics messages from the language
server for the current buffer in a location list.
:LspDocumentSymbol Display the symbols in the current file in a popup
menu and jump to the location of a selected symbol.
:LspFold Fold the current file
:LspFormat Format a range of lines in the current file using the
language server. The default range is the entire
file. See |lsp-format| for more information.
:LspGotoDeclaration Go to the declaration of the symbol under cursor
:LspGotoDefinition Go to the definition of the symbol under cursor
:LspGotoImpl Go to the implementation of the symbol under cursor
:LspGotoTypeDef Go to the type definition of the symbol under cursor
:LspHighlight Highlight all the matches for the keyword under cursor
:LspHighlightClear Clear all the matches highlighted by :LspHighlight
:LspHover Show the documentation for the symbol under the cursor
in a popup window.
:LspIncomingCalls Display the list of symbols calling the current symbol
in a window.
:LspInlayHints Enable or disable or toggle inlay hints.
:LspOutgoingCalls Display the list of symbols called by the current
symbol in a window.
:LspOutline Show the list of symbols defined in the current file
in a separate window.
:LspPeekDeclaration Open the declaration of the symbol under cursor in a
popup window.
:LspPeekDefinition Open the definition of the symbol under cursor in a
popup window.
:LspPeekImpl Open the implementation of the symbol under cursor in
a popup window.
:LspPeekReferences Display the list of references to the symbol under
cursor in a popup window.
:LspPeekTypeDef Open the type definition of the symbol under cursor in
a popup window.
:LspRename Rename the current symbol
:LspSelectionExpand Expand the current symbol range visual selection
:LspSelectionShrink Shrink the current symbol range visual selection
:LspServer Command to display the status and messages from a
language server and to restart the language server.
:LspShowAllServers Display the status of all the registered language
servers.
:LspShowReferences Display the list of references to the keyword under
cursor in a new location list.
:LspShowSignature Display the signature of the symbol under cursor.
:LspSubTypeHierarchy Display the sub type hierarchy in a popup window.
:LspSuperTypeHierarchy Display the super type hierarchy in a popup window.
:LspSwitchSourceHeader Switch between a source and a header file.
:LspSymbolSearch Perform a workspace wide search for a symbol
:LspWorkspaceAddFolder {folder}
Add a folder to the workspace
:LspWorkspaceListFolders
Show the list of folders in the workspace
:LspWorkspaceRemoveFolder {folder}
Remove a folder from the workspace
==============================================================================
4. Configuration *lsp-configuration*
*LspAddServer()* *g:LspAddServer()*
To use the plugin features with a particular file type(s), you need to first
register a language server for that file type(s).
To register one or more language servers, use the LspAddServer() function with
a list of lanaguge server details in the .vimrc file.
To register a language server, add the following lines to your .vimrc file
(use only the language servers that you need from the below list).
If you used [vim-plug](https://github.com/junegunn/vim-plug) to install the
LSP plugin, the steps are described later in this section: >
vim9script
var lspServers = [
{
name: 'typescriptls',
filetype: ['javascript', 'typescript'],
path: '/usr/local/bin/typescript-language-server',
args: ['--stdio']
},
{
name: 'pythonls',
filetype: 'python',
path: '/usr/local/bin/pyls',
args: ['--check-parent-process', '-v']
}
]
LspAddServer(lspServers)
<
Depending on the location of the typescript and python pyls language servers
installed in your system, update the "path" in the above snippet
appropriately.
Another example, for adding the language servers for the C, C++, Golang, Rust,
Shell script, Vim script and PHP file types: >
vim9script
var lspServers = [
{
name: 'clangd',
filetype: ['c', 'cpp'],
path: '/usr/local/bin/clangd',
args: ['--background-index']
},
{
name: 'golang',
filetype: ['go', 'gomod', 'gohtmltmpl', 'gotexttmpl'],
path: '/path/to/.go/bin/gopls',
args: [],
syncInit: true,
},
{
name: 'rustls',
filetype: ['rust'],
path: '/path/to/.cargo/bin/rust-analyzer',
args: [],
syncInit: true,
},
{
name: 'bashls',
filetype: 'sh',
path: '/usr/local/bin/bash-language-server',
args: ['start']
},
{
name: 'vimls',
filetype: ['vim'],
path: '/usr/local/bin/vim-language-server',
args: ['--stdio']
},
{
name: 'phpls',
filetype: ['php'],
path': '/usr/local/bin/intelephense',
args: ['--stdio'],
syncInit: true,
initializationOptions: {
licenceKey: 'xxxxxxxxxxxxxxx'
}
}
]
LspAddServer(lspServers)
<
To add a language server, the following information is needed:
*lsp-cfg-name*
name (Optional) name of the language server. Can by any
string. Used in LSP messages and log files.
*lsp-cfg-path*
path complete path to the language server executable
(without any arguments).
*lsp-cfg-args*
args a |List| of command-line arguments passed to the
language server. Each space separated language server
command-line argument is a separate List item.
*lsp-cfg-filetype*
filetype One or more file types supported by the language
server. This can be a |String| or a |List|. To
specify multiple file types, use a List.
*lsp-cfg-initializationOptions*
initializationOptions
(Optional) for lsp servers (e.g. intelephense) some
additional initialization options may be required
or useful for initialization. Those can be provided in
this dictionary and if present will be transmitted to
the lsp server.
*lsp-cfg-workspaceConfig*
workspaceConfig (Optional) a json encodable value that will be sent to
the language server after initialization as the
"settings" in a "workspace/didChangeConfiguration"
notification. Refer to the language server
documentation for the values that will be accepted in
this notification. This configuration is also used to
respond to the "workspace/configuration" request
message from the language server.
*lsp-cfg-rootSearch*
rootSearch (Optional) a List of file and directory names used to
locate the root path or uri of the workspace. The
directory names in "rootSearch" must end in "/" or
"\". Each file and directory name in "rootSearch" is
searched upwards in all the parent directories. If
multiple directories are found, then the directory
closest to the directory of the current buffer is used
as the workspace root.
If this parameter is not specified or the files are
not found, then the current working directory is used
as the workspace root for decendent files, for any
other files the parent directory of the file is used.
*lsp-cfg-runIfSearch*
runIfSearch (Optional) a List of file and directory names used to
determinate if a server should run or not. The
directory names in "runIfSearch" must end in "/" or
"\". Each file and directory name in "runIfSearch" is
searched upwards in all the parent directories.
Exactly like |lsp-cfg-rootSearch|.
If a file or directory is found then the server will
be started, otherwise it will not.
If this parameter is not specified or is an empty
list, then the server will be started unless
|lsp-cfg-runUnlessSearch| prevents it.
*lsp-cfg-runUnlessSearch*
runUnlessSearch (Optional) Opposite of |lsp-cfg-runIfSearch|.
Additionally the following configurations can be made:
*lsp-cfg-customNotificationHandlers*
customNotificationHandlers
(Optional) some lsp servers (e.g.
typescript-language-server) will send additional
notifications which you might want to silence or
handle. The provided notification handlers will be
called with a reference to the "lspserver" and the
"reply". >
vim9script
g:LspAddServer([{
filetype: ['javascript', 'typescript'],
path: '/usr/local/bin/typescript-language-server',
args: ['--stdio'],
customNotificationHandlers: {
'$/typescriptVersion': (lspserver, reply) => {
echom printf("TypeScript Version = %s",
reply.params.version)
}
}
}])
<
*lsp-cfg-customRequestHandlers*
customRequestHandlers
(Optional) some lsp servers will send additional
request replies which you might want to silence or
handle. The provided request handlers will be called
with a reference to the "lspserver" and the "request".
features *lsp-cfg-features*
(Optional) toggle which features should be enabled for
a given language server. See |lsp-multiple-servers|
and |lsp-features| for more information.
forceOffsetEncoding *lsp-cfg-forceOffsetEncoding*
(Optional) a |String| value that forces the use of a
specific offset encoding in LSP messages. If this
option is not specified, then the UTF offset encoding
is negotiated with the server during initialization.
Supported values are 'utf-8' or 'utf-16' or 'utf-32'.
The Vim native offset encoding is 'utf-32'. For the
'utf-8' and 'utf-16' encodings, the offsets need to be
encoded and decoded in every LSP message and will
incur some overhead.
*lsp-cfg-omnicompl*
omnicompl (Optional) a boolean value that enables (true)
or disables (false) omni-completion for these file
types. By default this is set to "v:true". This value
is applicable only if auto completion is disabled
(|lsp-opt-autoComplete|).
*lsp-cfg-processDiagHandler*
processDiagHandler
(Optional) A |Funcref| or |lambda| that takes a list
of language server diagnostics and returns a new list
of filtered, or otherwise changed diagnostics. Can be
used to remove unwanted diagnostics, prefix the
diagnostics text, etc. The following example will
remove all but errors and warnings: >
vim9script
g:LspAddServer([{
filetype: ['javascript', 'typescript'],
path: '/usr/local/bin/typescript-language-server',
args: ['--stdio'],
processDiagHandler: (diags: list<dict<any>>) => {
# Only include errors and warnings
return diags->filter((diag, ix) => {
return diag.severity <= 2
})
},
}])
<
And this example will prefix the diagnostic message
with the string "TypeScript: ": >
vim9script
g:LspAddServer([{
filetype: ['javascript', 'typescript'],
path: '/usr/local/bin/typescript-language-server',
args: ['--stdio'],
processDiagHandler: (diags: list<dict<any>>) => {
return diags->map((diag, ix) => {
diag.message = $'TypeScript: {diag.message}'
return diag
})
},
}])
<
*lsp-cfg-syncInit*
syncInit (Optional) for language servers (e.g. rust analyzer,
gopls, etc.) that take time to initialize and reply to
a "initialize" request message this should be set to
"true". If this is set to true, then a synchronous
call is used to initialize the language server,
otherwise the server is initialized asynchronously.
By default this is set to "false".
*lsp-cfg-debug*
debug (Optional) log the messages printed by this language
server in stdout and stderr to a file. Useful for
debugging a language server. By default the
messages are not logged. See |lsp-debug| for more
information.
*lsp-cfg-traceLevel*
traceLevel (Optional) set the debug trace level for this language
server. Supported values are: "off", "debug" and
"verbose". By default this is seto "off".
The language servers are added using the LspAddServer() function. This
function accepts a list of language servers with the above information.
If you used [vim-plug](https://github.com/junegunn/vim-plug) to install the
LSP plugin, then you need to use the LspSetup User autocmd to initialize the
language server and to set the language server options. For example: >
vim9script
var lspOpts = {autoHighlightDiags: true}
autocmd User LspSetup LspOptionsSet(lspOpts)
var lspServers = [
{
name: 'clangd',
filetype: ['c', 'cpp'],
path: '/usr/local/bin/clangd',
args: ['--background-index']
}
]
autocmd User LspSetup LspAddServer(lspServers)
<
*lsp-options* *LspOptionsSet()*
*g:LspOptionsSet()*
Some of the LSP plugin features can be enabled or disabled by using the
LspOptionsSet() function. This function accepts a dictionary argument with the
following optional items:
*lsp-opt-aleSupport*
aleSupport |Boolean| option. If true, diagnostics will be sent to
Ale, instead of being displayed by this plugin.
This is useful to combine all LSP and linter
diagnostics. By default this is set to false.
*lsp-opt-autoComplete*
autoComplete |Boolean| option. In insert mode, automatically
complete the current symbol. Otherwise use
omni-completion. By default this is set to true.
*lsp-opt-autoHighlight*
autoHighlight |Boolean| option. In normal mode, automatically
highlight all the occurrences of the symbol under the
cursor. By default this is set to false.
*lsp-opt-autoHighlightDiags*
autoHighlightDiags |Boolean| option. Automatically place signs on the
lines with a diagnostic message from the language
server. By default this is set to true.
*lsp-opt-autoPopulateDiags*
autoPopulateDiags |Boolean| option. Automatically populate the location
list with diagnostics from the language server.
By default this is set to false.
*lsp-opt-completionMatcher*
completionMatcher |String| option. Enable fuzzy or case insensitive
completion for language servers that replies with a
full list of completion items. Some language servers
does completion filtering in the server, while other
relies on the client to do the filtering.
This option only works for language servers that
expect the client to filter the completion items.
This option accepts one of the following values:
case - case sensitive matching (default).
fuzzy - fuzzy match completion items.
icase - ignore case when matching items.
*lsp-opt-completionTextEdit*
completionTextEdit |Boolean| option. If true, apply the LSP server
supplied text edits after a completion. If a snippet
plugin is going to apply the text edits, then set
this to false to avoid applying the text edits twice.
By default this is set to true.
*lsp-opt-completionKinds*
completionKinds |Dictionary| option. See |lsp-custom-kinds| for all
completion kind names.
*lsp-opt-customCompletionKinds*
customCompletionKinds |Boolean| option. If you set this to true, you can
set custom completion kinds using the option
completionKinds.
*lsp-opt-diagSignErrorText*
diagSignErrorText |String| option. Change diag sign text for errors
By default 'E>'
*lsp-opt-diagSignHintText*
diagSignHintText |String| option. Change diag sign text for hints
By default 'H>',
*lsp-opt-diagSignInfoText*
diagSignInfoText |String| option. Change diag sign text for info
By default 'I>',
*lsp-opt-diagSignWarningText*
diagSignWarningText |String| option. Change diag sign text for warnings
By default 'W>',
*lsp-opt-diagVirtualTextAlign*
diagVirtualTextAlign |String| option. Alignment of diagnostics messages
if |lsp-opt-showDiagWithVirtualText| is set to true.
Allowed values are 'above', 'below' or 'after'
By default this is set to 'above',
*lsp-opt-diagVirtualTextWrap*
diagVirtualTextWrap |String| option. Wrapping of diagnostics messages
if |lsp-opt-showDiagWithVirtualText| is set to true.
Allowed values are 'default', 'wrap' or 'truncate'
By default this is set to 'default',
*lsp-opt-echoSignature*
echoSignature |Boolean| option. In insert mode, echo the current
symbol signature instead of showing it in a popup.
By default this is set to false.
*lsp-opt-hideDisabledCodeActions*
hideDisabledCodeActions |Boolean| option. Hide all the disabled code actions.
By default this is set to false.
*lsp-opt-highlightDiagInline*
highlightDiagInline |Boolean| option. Highlight the diagnostics inline.
By default this is set to true.
*lsp-opt-hoverInPreview*
hoverInPreview |Boolean| option. Show |:LspHover| in a preview window
instead of a popup.
By default this is set to false.
*lsp-opt-ignoreMissingServer*
ignoreMissingServer |Boolean| option. Do not print a missing language
server executable. By default this is set to false.
*lsp-opt-keepFocusInDiags*
keepFocusInDiags |Boolean| option. Focus on the location list window
after ":LspDiag show".
By default this is set to true.
*lsp-opt-keepFocusInReferences*
keepFocusInReferences |Boolean| option. Focus on the location list window
after LspShowReferences.
By default this is set to true.
*lsp-opt-noNewlineInCompletion*
noNewlineInCompletion |Boolean| option. Suppress adding a new line on
completion selection with <CR>.
By default this is set to false.
*lsp-opt-omniComplete*
omniComplete |Boolean| option. Enables or disables omni-completion.
By default this is set to v:false. If "autoComplete"
is set to v:false, then omni-completion is enabled by
default. By setting "omniComplete" option to v:false,
omni-completion can also be disabled.
*lsp-opt-outlineOnRight*
outlineOnRight |Boolean| option. Open the outline window on the
right side, by default this is false.
*lsp-opt-outlineWinSize*
outlineWinSize |Number| option. The size of the symbol Outline
window. By default this is set to 20.
*lsp-opt-semanticHighlight*
semanticHighlight |Boolean| option. Enables or disables semantic
highlighting.
By default this is set to false.
*lsp-opt-showDiagInBalloon*
showDiagInBalloon |Boolean| option. When the mouse is over a range of
text referenced by a diagnostic, display the
diagnostic text in a balloon. By default this is set
to true. In a GUI Vim, this needs the |+balloon_eval|
feature. In a terminal Vim, this needs the
|+balloon_eval_term| feature. In a terminal Vim,
'mouse' option should be set to enable mouse.
If this option is set to true, then the 'ballooneval'
and 'balloonevalterm' options are set.
*lsp-opt-showDiagInPopup*
showDiagInPopup |Boolean| option. When using the ":LspDiag current"
command to display the diagnostic message for the
current line, use a popup window to display the
message instead of echoing in the status area.
By default this is set to true.
*lsp-opt-showDiagOnStatusLine*
showDiagOnStatusLine |Boolean| option. Show a diagnostic message on a
status line. By default this is set to false.
*lsp-opt-showDiagWithSign*
showDiagWithSign |Boolean| option. Place a sign on lines with
diagnostics. By default this is set to true. The
"autoHighlightDiags" option should be set to true.
*lsp-opt-showDiagWithVirtualText*
showDiagWithVirtualText |Boolean| option. Show diagnostic message text from
the language server with virtual text. By default
this is set to false. The "autoHighlightDiags" option
should be set to true.
Needs Vim version 9.0.1157 or later.
*lsp-opt-showInlayHints*
showInlayHints |Boolean| option. Show inlay hints from the language
server. By default this is set to false. The inlay
hint text is displayed as a virtual text. Needs Vim
version 9.0.0178 or later.
*lsp-opt-showSignature*
showSignature |Boolean| option. In insert mode, automatically show
the current symbol signature in a popup.
By default this is set to true.
*lsp-opt-snippetSupport*
snippetSupport |Boolean| option. Enable snippet completion support.
Need a snippet completion plugin like vim-vsnip.
By default this is set to false.
*lsp-opt-ultisnipsSupport*
ultisnipsSupport |Boolean| option. Enable SirVer/ultisnips support.
Need a snippet completion plugin SirVer/ultisnips.
By default this is set to false.
*lsp-opt-vssnipSupport*
vsnipSupport |Boolean| option. Enable hrsh7th/vim-vsnip support.
Need snippet completion plugins hrsh7th/vim-vsnip
and hrsh7th/vim-vsnip-integ. Make sure
ultisnipsSupport is set to false before enabling this.
By default this option is set to false.
*lsp-opt-usePopupInCodeAction*
usePopupInCodeAction |Boolean| option. When using the |:LspCodeAction|
command to display the code action for the current
line, use a popup menu instead of echoing.
By default this is set to false.
*lsp-opt-useQuickfixForLocations*
useQuickfixForLocations |Boolean| option. Show |:LspShowReferences| in a
quickfix list instead of a location list.
By default this is set to false.
*lsp-opt-useBufferCompletion*
useBufferCompletion |Boolean| option. If enabled, the words from the
current buffer are added to the auto completion list.
By default this is set to false.
*lsp-opt-bufferCompletionTimeout*
bufferCompletionTimeout |Number| option. Specifies how long (in milliseconds)
to wait while processing current buffer for
autocompletion words. If set too high Vim performance
may degrade as the current buffer contents are
processed every time the completion menu is displayed.
If set to 0 the entire buffer is processed without
regard to timeout.
By default this is set to 100 ms.
*lsp-opt-filterCompletionDuplicates*
filterCompletionDuplicates |Boolean| option. If enabled, duplicate completion
items sent from the server will be filtered to only
include one instance of the duplicates.
For example, to disable the automatic placement of signs for the LSP
diagnostic messages, you can add the following line to your .vimrc file: >
call LspOptionsSet({'autoHighlightDiags': false})
<
*LspOptionsGet()*
The LspOptionsGet() function returns a |Dict| of all the LSP plugin options,
To get a particular option value you can use the following: >
echo LspOptionsGet()['autoHighlightDiags']
<
==============================================================================
5. Commands *lsp-commands*
A description of the various commands provided by this plugin is below. You
can map these commands to keys and make it easier to invoke them.
*:LspCodeAction*
:LspCodeAction [query] Apply the code action supplied by the language server
to the diagnostic in the current line. This works only
if there is a diagnostic message for the current line.
You can use the ":LspDiag current" command to display
the diagnostic for the current line.
When [query] is given the code action starting with
[query] will be applied. [query] can be a regexp
pattern, or a digit corresponding to the index of the
code actions in the created prompt.
When [query] is not given you will be prompted to
select one of the actions supplied by the language
server.
*:LspCodeLens*
:LspCodeLens Display a list of code lens commands available for the
current buffer and apply the selected code lens
command.
*:LspDiag-current*
:LspDiag current Displays the diagnostic message (if any) for the
current line. If the option 'showDiagInPopup' is set
to true (default), then the message is displayed in
a popup window. Otherwise the message is displayed in
the status message area.
:LspDiag! current Only display a diagnostic message if it's directly
under the cursor. Otherwise works exactly like
":LspDiag current"
To show the current diagnotic under the cursor while
moving around the following autocmd can be used: >
augroup LspCustom
au!
au CursorMoved * silent! LspDiag! current
augroup END
<
*:LspDiag-first*
:LspDiag first Jumps to the location of the first diagnostic message
for the current file.
*:LspDiag-here*
:LspDiag here Jumps to the location of the diagnostic message in
the current line (start from current column).
:LspDiag highlight disable *:LspDiag-highlight-disable*
Disable highlighting lines with a diagnostic message
for the current Vim session.
To always disable the highlighting, set the
autoHighlightDiags option to false.
:LspDiag highlight enable *:LspDiag-highlight-enable*
Enable highlighting lines with a diagnostic message
for the current Vim session. Note that highlighting
lines with a diagnostic message is enabled by default.
:LspDiag highlight toggle *:LspDiag-highlight-toggle*
Toggle (enable or disable) highlighting lines with a
diagnostic message for the current Vim session in all
the buffers.
*:LspDiag-last*
:LspDiag last Jumps to the location of the first diagnostic message
for the current file.
*:LspDiag-next*
:[count]LspDiag next Go to the [count] diagnostic message after the current
cursor position. If [count] is omitted, then 1 is
used. If [count] exceeds the number of diagnostics
after the current position, then the last diagnostic
is selected.
*:LspDiag-prev*
:[count]LspDiag prev Go to the [count] diagnostic message before the
current cursor position. If [count] is omitted, then
1 is used. If [count] exceeds the number of
diagnostics before the current position, then first
last diagnostic is selected.
*:LspDiag-show*
:LspDiag show Creates a new location list with the diagnostics
messages (if any) from the language server for the
current file and opens the location list window. You
can use the Vim location list commands to browse the
list.
*:LspDocumentSymbol*
:LspDocumentSymbol Display the symbols in the current file in a popup
menu. When a symbol is selected in the popup menu by
pressing <Enter> or <Space>, jump to the location of
the symbol.
The <Up>, <Down>, <Tab>, <S-Tab>, <C-N>, <C-P>,
<ScrollWheelUp>, ScrollWheelDown> keys can be used to
scroll popup menu one item at a time. <PageUp> and
<PageDown> can be used to scroll a page of popup
window, while <C-F> and <C-B> can be used to scroll a
page of underlying window. The <Esc> or <Ctrl-C> keys
can be used to cancel the popup menu.
If one or more keyword characters are typed, then only
the symbols containing the keyword characters are
displayed in the popup menu. Fuzzy searching is used
to get the list of matching symbols. The <BS> key can
be used to erase the last typed character. The <C-U>
key can be used to erase all the characters.
When scrolling through the symbols in the popup menu,
the corresponding range of lines is highlighted.
*:LspFold*
:LspFold Create folds for the current buffer.
*:LspFormat*
:LspFormat Format the current file using the language server. The
'shiftwidth' and 'expandtab' values set for the
current buffer are used when format is applied.
:{range}LspFormat Format the specified range of lines in the current
file using the language server. Map <plug>(LspFormat)
in normal mode to operate on text objects.
*:LspGotoDeclaration*
:[count]LspGotoDeclaration
Jumps to the declaration of the symbol under the
cursor. The behavior of this command is similar to the
|:LspGotoDefinition| command.
*:LspGotoDefinition*
:[count]LspGotoDefinition
Jumps to the [count] definition of the symbol under
the cursor. If there are multiple matches and [count]
isn't specified, then a location list will be created
with the list of locations.
If there is only one location, or [count] is provided
then the following will apply:
If the file is already present in a window, then jumps
to that window. Otherwise, opens the file in a new
window. If the current buffer is modified and
'hidden' is not set or if the current buffer is a
special buffer, then a new window is opened. If the
jump is successful, then the current cursor location
is pushed onto the tag stack. The |CTRL-T| command
can be used to go back up the tag stack. Also the
|``| mark is set to the position before the jump.
This command supports |:command-modifiers|. You can
use the modifiers to specify whether a new window or
a new tab page is used and where the window is opened.
Example(s): >
# Open a horizontally split window
:topleft LspGotoDefinition
# Open a vertically split window
:vert LspGotoDefinition
# Open a new tab page
:tab LspGotoDefinition
<
You may want to map a key to invoke this command: >
nnoremap <buffer> gd <Cmd>LspGotoDefinition<CR>
nnoremap <buffer> <C-W>gd <Cmd>topleft LspGotoDefinition<CR>
<
Or if you want to support [count]gd >
nnoremap <buffer> gd <Cmd>execute v:count .. 'LspGotoDefinition'<CR>
nnoremap <buffer> <C-W>gd <Cmd>execute 'topleft ' .. v:count .. 'LspGotoDefinition'<CR>
<
*:LspGotoImpl*
:[count]LspGotoImpl Jumps to the implementation of the symbol under the
cursor. The behavior of this command is similar to the
|:LspGotoDefinition| command. Note that not all the
language servers support this feature.
You may want to map a key to invoke this command: >
nnoremap <buffer> gi <Cmd>LspGotoImpl<CR>
<
*:LspGotoTypeDef*
:[count]LspGotoTypeDef Jumps to the type definition of the symbol under the
cursor. The behavior of this command is similar to the
|:LspGotoDefinition| command. Note that not all the
language servers support this feature.
You may want to map a key to invoke this command: >
nnoremap <buffer> gt <Cmd>LspGotoTypeDef<CR>
<
*:LspHighlight*
:LspHighlight Highlights all the matches for the symbol under
cursor. The text, read and write references to the
symbol are highlighted using Search, DiffChange and
DiffDelete highlight groups respectively.
*:LspHighlightClear*
:LspHighlightClear Clears all the symbol matches highlighted by the
|:LspHighlight| command.
*:LspHover*
:LspHover Show the documentation for the symbol under the cursor
in a popup window. The following keys can be used to
scroll the popup window:
<CTRL-E> - Scroll window downwards by a line.
<CTRL-D> - Scroll window downwards by 'scroll'
lines.
<CTRL-F> - Scroll window downards by a page.
<PageDown> - ditto.
<CTRL-Y> - Scroll window upwards by a line.
<CTRL-U> - Scroll window upwards by 'scroll'
lines.
<CTRL-B> - Scroll window upwards by a page.
<PageUp> - ditto.
<CTRL-Home> - Goto the first line
<CTRL-End> - Goto the last line
Pressing any other key will close the popup window.
If you want to show the symbol documentation in the
|preview-window| instead of in a popup window set >
LspOptionsSet({'hoverInPreview': true})
<
You can use the |:pclose| command to close the preview
window.
You can use the |K| key in normal mode to display the
documentation for the keyword under the cursor by
setting the 'keywordprg' Vim option: >
:set keywordprg=:LspHover
<
*:LspIncomingCalls*
:LspIncomingCalls Display a hierarchy of symbols calling the symbol
under the cursor in a window. See
|lsp-call-hierarchy| for more information. Note that
not all the language servers support this feature.
*:LspInlayHints*
:LspInlayHints Enable or disable inlay hints. Supports the "enable",
"disable" and "toggle" arguments. When "enable" is
specified, enables the inlay hints for all the buffers
with a language server that supports inlay hints.
When "disable" is specified, disables the inlay hints.
When "toggle" is specified, either enables or disables
the inlay hints.
*:LspOutoingCalls*
:LspOutgoingCalls Display a hierarchy of symbols called by the symbol
under the cursor in a window. See
|lsp-call-hierarchy| for more information. Note that
not all the language servers support this feature.
*:LspOutline*
:[count]LspOutline Opens a vertically split window with the list of
symbols defined in the current file. The current
symbol is highlighted. The symbols are grouped by
their type. You can select a symbol and press <Enter>
to jump to the position of the symbol. As you move the
cursor in a file, the current symbol is automatically
highlighted in the outline window. If you open a new
file, the outline window is automatically updated with
the symbols in the new file. Folds are created in the
outline window for the various group of symbols.
You can use |lsp-opt-outlineOnRight| and
|lsp-opt-outlineWinSize| to customize the placement
and size of the window.
This command also supports |:command-modifiers|. You
can use the modifiers specify the position of the
window. Note that the default is ":vert :topleft" or
":vert :botright" depending on
|lsp-opt-outlineOnRight|
This command also supports providing a [count] to
specify the size of the window. Note that this
overrides the values defined in
|lsp-opt-outlineWinSize|.
Example: >
# Open the outline window just above the current
# window
:aboveleft LspOutline
# Open the outline window just next to the current
# window, this is different from the default, when
# you have multiple splits already
:vert aboveleft LspOutline
# Same as above, but with a width of 50
:vert aboveleft 50LspOutline