-
-
Notifications
You must be signed in to change notification settings - Fork 890
/
lsp-mode.el
8818 lines (7787 loc) · 383 KB
/
lsp-mode.el
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-mode.el --- LSP mode -*- lexical-binding: t; -*-
;; Copyright (C) 2020 emacs-lsp maintainers
;; Author: Vibhav Pant, Fangrui Song, Ivan Yonchovski
;; Keywords: languages
;; Package-Requires: ((emacs "26.1") (dash "2.18.0") (f "0.20.0") (ht "2.3") (spinner "1.7.3") (markdown-mode "2.3") (lv "0"))
;; Version: 8.0.1
;; URL: https://github.com/emacs-lsp/lsp-mode
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; Emacs client/library for the Language Server Protocol
;;; Code:
(require 'cl-generic)
(require 'cl-lib)
(require 'compile)
(require 'dash)
(require 'epg)
(require 'ewoc)
(require 'f)
(require 'filenotify)
(require 'files)
(require 'ht)
(require 'imenu)
(require 'inline)
(require 'json)
(require 'lv)
(require 'markdown-mode)
(require 'network-stream)
(require 'pcase)
(require 'rx)
(require 's)
(require 'seq)
(require 'spinner)
(require 'subr-x)
(require 'tree-widget)
(require 'url-parse)
(require 'url-util)
(require 'widget)
(require 'xref)
(require 'minibuffer)
(require 'yasnippet nil t)
(require 'lsp-protocol)
(defgroup lsp-mode nil
"Language Server Protocol client."
:group 'tools
:tag "Language Server (lsp-mode)")
(declare-function evil-set-command-property "ext:evil-common")
(declare-function projectile-project-root "ext:projectile")
(declare-function yas-expand-snippet "ext:yasnippet")
(declare-function dap-mode "ext:dap-mode")
(declare-function dap-auto-configure-mode "ext:dap-mode")
(defvar yas-inhibit-overlay-modification-protection)
(defvar yas-indent-line)
(defvar yas-wrap-around-region)
(defvar yas-also-auto-indent-first-line)
(defvar dap-auto-configure-mode)
(defvar dap-ui-menu-items)
(defvar company-minimum-prefix-length)
(defconst lsp--message-type-face
`((1 . ,compilation-error-face)
(2 . ,compilation-warning-face)
(3 . ,compilation-message-face)
(4 . ,compilation-info-face)))
(defconst lsp--errors
'((-32700 "Parse Error")
(-32600 "Invalid Request")
(-32601 "Method not Found")
(-32602 "Invalid Parameters")
(-32603 "Internal Error")
(-32099 "Server Start Error")
(-32000 "Server End Error")
(-32002 "Server Not Initialized")
(-32001 "Unknown Error Code")
(-32800 "Request Cancelled"))
"Alist of error codes to user friendly strings.")
(defconst lsp--empty-ht (make-hash-table))
(eval-and-compile
(defun dash-expand:&lsp-wks (key source)
`(,(intern-soft (format "lsp--workspace-%s" (eval key))) ,source))
(defun dash-expand:&lsp-cln (key source)
`(,(intern-soft (format "lsp--client-%s" (eval key))) ,source)))
(define-obsolete-variable-alias 'lsp-print-io 'lsp-log-io "lsp-mode 6.1")
(defcustom lsp-log-io nil
"If non-nil, log all messages from the language server to a *lsp-log* buffer."
:group 'lsp-mode
:type 'boolean)
(defcustom lsp-log-io-allowlist-methods '()
"The methods to filter before print to lsp-log-io."
:group 'lsp-mode
:type '(repeat string)
:package-version '(lsp-mode . "8.0.1"))
(defcustom lsp-log-max message-log-max
"Maximum number of lines to keep in the log buffer.
If nil, disable message logging. If t, log messages but don’t truncate
the buffer when it becomes large."
:group 'lsp-mode
:type '(choice (const :tag "Disable" nil)
(integer :tag "lines")
(const :tag "Unlimited" t))
:package-version '(lsp-mode . "6.1"))
(defcustom lsp-io-messages-max t
"Maximum number of messages that can be locked in a `lsp-io' buffer."
:group 'lsp-mode
:type '(choice (const :tag "Unlimited" t)
(integer :tag "Messages"))
:package-version '(lsp-mode . "6.1"))
(defcustom lsp-keep-workspace-alive t
"If non nil keep workspace alive when the last workspace buffer is closed."
:group 'lsp-mode
:type 'boolean)
(defcustom lsp-enable-snippet t
"Enable/disable snippet completion support."
:group 'lsp-completion
:type 'boolean)
(defcustom lsp-enable-folding t
"Enable/disable code folding support."
:group 'lsp-mode
:type 'boolean
:package-version '(lsp-mode . "6.1"))
(define-obsolete-variable-alias 'lsp-enable-semantic-highlighting 'lsp-semantic-tokens-enable "lsp-mode 8.0.0")
(defcustom lsp-semantic-tokens-enable nil
"Enable/disable support for semantic tokens.
As defined by the Language Server Protocol 3.16."
:group 'lsp-semantic-tokens
:type 'boolean)
(defcustom lsp-folding-range-limit nil
"The maximum number of folding ranges to receive from the language server."
:group 'lsp-mode
:type '(choice (const :tag "No limit." nil)
(integer :tag "Number of lines."))
:package-version '(lsp-mode . "6.1"))
(defcustom lsp-folding-line-folding-only nil
"If non-nil, only fold complete lines."
:group 'lsp-mode
:type 'boolean
:package-version '(lsp-mode . "6.1"))
(defcustom lsp-client-packages
'(ccls lsp-actionscript lsp-ada lsp-angular lsp-bash lsp-beancount lsp-clangd lsp-clojure lsp-cmake
lsp-crystal lsp-csharp lsp-css lsp-d lsp-dart lsp-dhall lsp-dockerfile lsp-elm
lsp-elixir lsp-erlang lsp-eslint lsp-fortran lsp-fsharp lsp-gdscript lsp-go lsp-graphql
lsp-hack lsp-grammarly lsp-groovy lsp-haskell lsp-haxe lsp-java lsp-javascript lsp-json
lsp-kotlin lsp-ltex lsp-lua lsp-markdown lsp-nim lsp-nix lsp-metals lsp-ocaml lsp-perl lsp-php lsp-pwsh
lsp-pyls lsp-pylsp lsp-python-ms lsp-purescript lsp-r lsp-rf lsp-rust lsp-solargraph lsp-sorbet
lsp-tex lsp-terraform lsp-toml lsp-v lsp-vala lsp-verilog lsp-vetur lsp-vhdl lsp-vimscript lsp-xml
lsp-yaml lsp-sqls lsp-svelte lsp-steep lsp-zig)
"List of the clients to be automatically required."
:group 'lsp-mode
:type '(repeat symbol))
(defcustom lsp-progress-via-spinner t
"If non-nil, display LSP $/progress reports via a spinner in the modeline."
:group 'lsp-mode
:type 'boolean)
(defvar-local lsp--cur-workspace nil)
(defvar-local lsp--cur-version 0)
(defvar-local lsp--virtual-buffer-connections nil)
(defvar-local lsp--virtual-buffer nil)
(defvar lsp--virtual-buffer-mappings (ht))
(defvar lsp--uri-file-prefix (pcase system-type
(`windows-nt "file:///")
(_ "file://"))
"Prefix for a file-uri.")
(defvar-local lsp-buffer-uri nil
"If set, return it instead of calculating it using `buffer-file-name'.")
(define-error 'lsp-error "Unknown lsp-mode error")
(define-error 'lsp-empty-response-error
"Empty response from the language server" 'lsp-error)
(define-error 'lsp-timed-out-error
"Timed out while waiting for a response from the language server" 'lsp-error)
(define-error 'lsp-capability-not-supported
"Capability not supported by the language server" 'lsp-error)
(define-error 'lsp-file-scheme-not-supported
"Unsupported file scheme" 'lsp-error)
(define-error 'lsp-client-already-exists-error
"A client with this server-id already exists" 'lsp-error)
(define-error 'lsp-no-code-actions
"No code actions" 'lsp-error)
(defcustom lsp-auto-guess-root nil
"Automatically guess the project root using projectile/project.
Do *not* use this setting unless you are familiar with `lsp-mode'
internals and you are sure that all of your projects are
following `projectile'/`project.el' conventions."
:group 'lsp-mode
:type 'boolean)
(defcustom lsp-restart 'interactive
"Defines how server-exited events must be handled."
:group 'lsp-mode
:type '(choice (const interactive)
(const auto-restart)
(const ignore)))
(defcustom lsp-session-file (expand-file-name (locate-user-emacs-file ".lsp-session-v1"))
"File where session information is stored."
:group 'lsp-mode
:type 'file)
(defcustom lsp-auto-configure t
"Auto configure `lsp-mode' main features.
When set to t `lsp-mode' will auto-configure completion,
code-actions, breadcrumb, `flycheck', `flymake', `imenu', symbol highlighting,
lenses, links, and so on.
For finer granularity you may use `lsp-enable-*' properties."
:group 'lsp-mode
:type 'boolean
:package-version '(lsp-mode . "6.1"))
(defcustom lsp-disabled-clients nil
"A list of disabled/blacklisted clients.
Each entry in the list can be either:
a symbol, the server-id for the LSP client, or
a cons pair (MAJOR-MODE . CLIENTS), where MAJOR-MODE is the major-mode,
and CLIENTS is either a client or a list of clients.
This option can also be used as a file- or directory-local variable to
disable a language server for individual files or directories/projects
respectively."
:group 'lsp-mode
:type '(repeat (symbol))
:safe 'listp
:package-version '(lsp-mode . "6.1"))
(defvar lsp-clients (make-hash-table :test 'eql)
"Hash table server-id -> client.
It contains all of the clients that are currently registered.")
(defvar lsp-enabled-clients nil
"List of clients allowed to be used for projects.
When nil, all registered clients are considered candidates.")
(defvar lsp-last-id 0
"Last request id.")
(defcustom lsp-before-initialize-hook nil
"List of functions to be called before a Language Server has been initialized
for a new workspace."
:type 'hook
:group 'lsp-mode)
(defcustom lsp-after-initialize-hook nil
"List of functions to be called after a Language Server has been initialized
for a new workspace."
:type 'hook
:group 'lsp-mode)
(defcustom lsp-before-open-hook nil
"List of functions to be called before a new file with LSP support is opened."
:type 'hook
:group 'lsp-mode)
(defcustom lsp-after-open-hook nil
"List of functions to be called after a new file with LSP support is opened."
:type 'hook
:group 'lsp-mode)
(defcustom lsp-enable-file-watchers t
"If non-nil lsp-mode will watch the files in the workspace if
the server has requested that."
:type 'boolean
:group 'lsp-mode
:package-version '(lsp-mode . "6.1"))
;;;###autoload(put 'lsp-enable-file-watchers 'safe-local-variable #'booleanp)
(define-obsolete-variable-alias 'lsp-file-watch-ignored 'lsp-file-watch-ignored-directories "8.0.0")
(defcustom lsp-file-watch-ignored-directories
'(; SCM tools
"[/\\\\]\\.git\\'"
"[/\\\\]\\.github\\'"
"[/\\\\]\\.circleci\\'"
"[/\\\\]\\.hg\\'"
"[/\\\\]\\.bzr\\'"
"[/\\\\]_darcs\\'"
"[/\\\\]\\.svn\\'"
"[/\\\\]_FOSSIL_\\'"
;; IDE or build tools
"[/\\\\]\\.idea\\'"
"[/\\\\]\\.ensime_cache\\'"
"[/\\\\]\\.eunit\\'"
"[/\\\\]node_modules"
"[/\\\\]\\.yarn\\'"
"[/\\\\]\\.fslckout\\'"
"[/\\\\]\\.tox\\'"
"[/\\\\]dist\\'"
"[/\\\\]dist-newstyle\\'"
"[/\\\\]\\.stack-work\\'"
"[/\\\\]\\.bloop\\'"
"[/\\\\]\\.metals\\'"
"[/\\\\]target\\'"
"[/\\\\]\\.ccls-cache\\'"
"[/\\\\]\\.vscode\\'"
"[/\\\\]\\.venv\\'"
;; Autotools output
"[/\\\\]\\.deps\\'"
"[/\\\\]build-aux\\'"
"[/\\\\]autom4te.cache\\'"
"[/\\\\]\\.reference\\'"
;; Clojure
"[/\\\\]\\.lsp\\'"
"[/\\\\]\\.clj-kondo\\'"
"[/\\\\]\\.shadow-cljs\\'"
"[/\\\\]\\.babel_cache\\'"
"[/\\\\]\\.cpcache\\'"
"[/\\\\]\\checkouts\\'"
;; Maven
"[/\\\\]\\.m2\\'"
;; .Net Core build-output
"[/\\\\]bin/Debug\\'"
"[/\\\\]obj\\'"
;; OCaml and Dune
"[/\\\\]_opam\\'"
"[/\\\\]_build\\'"
;; nix-direnv
"[/\\\\]\\.direnv\\'")
"List of regexps matching directory paths which won't be monitored when
creating file watches. Customization of this variable is only honored at
the global level or at a root of an lsp workspace."
:group 'lsp-mode
:type '(repeat string)
:package-version '(lsp-mode . "8.0.0"))
(define-obsolete-function-alias 'lsp-file-watch-ignored 'lsp-file-watch-ignored-directories "7.0.1")
(defun lsp-file-watch-ignored-directories ()
lsp-file-watch-ignored-directories)
;; Allow lsp-file-watch-ignored-directories as a file or directory-local variable
(put 'lsp-file-watch-ignored-directories 'safe-local-variable 'lsp--string-listp)
(defcustom lsp-file-watch-ignored-files
'(
;; Flycheck tempfiles
"[/\\\\]flycheck_[^/\\\\]+\\'"
;; lockfiles
"[/\\\\]\\.#[^/\\\\]+\\'"
;; backup files
"[/\\\\][^/\\\\]+~\\'" )
"List of regexps matching files for which change events will
not be sent to the server.
This setting has no impact on whether a file-watch is created for
a directory; it merely prevents notifications pertaining to
matched files from being sent to the server. To prevent a
file-watch from being created for a directory, customize
`lsp-file-watch-ignored-directories'
Customization of this variable is only honored at the global
level or at a root of an lsp workspace."
:group 'lsp-mode
:type '(repeat string)
:package-version '(lsp-mode . "8.0.0"))
;; Allow lsp-file-watch-ignored-files as a file or directory-local variable
(put 'lsp-file-watch-ignored-files 'safe-local-variable 'lsp--string-listp)
(defcustom lsp-after-uninitialized-functions nil
"List of functions to be called after a Language Server has been uninitialized."
:type 'hook
:group 'lsp-mode
:package-version '(lsp-mode . "6.3"))
(defconst lsp--sync-none 0)
(defconst lsp--sync-full 1)
(defconst lsp--sync-incremental 2)
(defcustom lsp-debounce-full-sync-notifications t
"If non-nil debounce full sync events.
This flag affects only servers which do not support incremental updates."
:type 'boolean
:group 'lsp-mode
:package-version '(lsp-mode . "6.1"))
(defcustom lsp-debounce-full-sync-notifications-interval 1.0
"Time to wait before sending full sync synchronization after buffer modification."
:type 'float
:group 'lsp-mode
:package-version '(lsp-mode . "6.1"))
(defvar lsp--stderr-index 0)
(defvar lsp--delayed-requests nil)
(defvar lsp--delay-timer nil)
(defcustom lsp-document-sync-method nil
"How to sync the document with the language server."
:type '(choice (const :tag "Documents should not be synced at all." nil)
(const :tag "Documents are synced by always sending the full content of the document." lsp--sync-full)
(const :tag "Documents are synced by always sending incremental changes to the document." lsp--sync-incremental)
(const :tag "Use the method recommended by the language server." nil))
:group 'lsp-mode)
(defcustom lsp-auto-execute-action t
"Auto-execute single action."
:type 'boolean
:group 'lsp-mode)
(defcustom lsp-enable-links t
"If non-nil, all references to links in a file will be made clickable, if
supported by the language server."
:type 'boolean
:group 'lsp-mode
:package-version '(lsp-mode . "6.1"))
(defcustom lsp-enable-imenu t
"If non-nil, automatically enable `imenu' integration when server provides
`textDocument/documentSymbol'."
:type 'boolean
:group 'lsp-mode
:package-version '(lsp-mode . "6.2"))
(defcustom lsp-enable-dap-auto-configure t
"If non-nil, enable `dap-auto-configure-mode`."
:type 'boolean
:group 'lsp-mode
:package-version '(lsp-mode . "7.0"))
(defcustom lsp-eldoc-enable-hover t
"If non-nil, `eldoc' will display hover info when it is present."
:type 'boolean
:group 'lsp-mode)
(defcustom lsp-eldoc-render-all nil
"Display all of the info returned by document/onHover.
If this is set to nil, `eldoc' will show only the symbol information."
:type 'boolean
:group 'lsp-mode)
(define-obsolete-variable-alias 'lsp-enable-completion-at-point
'lsp-completion-enable "lsp-mode 7.0.1")
(defcustom lsp-completion-enable t
"Enable `completion-at-point' integration."
:type 'boolean
:group 'lsp-completion)
(defcustom lsp-enable-symbol-highlighting t
"Highlight references of the symbol at point."
:type 'boolean
:group 'lsp-mode)
(defcustom lsp-enable-xref t
"Enable xref integration."
:type 'boolean
:group 'lsp-mode)
(defcustom lsp-enable-indentation t
"Indent regions using the file formatting functionality provided by the
language server."
:type 'boolean
:group 'lsp-mode)
(defcustom lsp-enable-on-type-formatting t
"Enable `textDocument/onTypeFormatting' integration."
:type 'boolean
:group 'lsp-mode)
(defcustom lsp-enable-text-document-color t
"Enable `textDocument/documentColor' integration."
:type 'boolean
:group 'lsp-mode)
(defcustom lsp-before-save-edits t
"If non-nil, `lsp-mode' will apply edits suggested by the language server
before saving a document."
:type 'boolean
:group 'lsp-mode)
(defcustom lsp-after-apply-edits-hook nil
"Hooks to run when text edit is applied.
It contains the operation source."
:type 'hook
:group 'lsp-mode
:package-version '(lsp-mode . "8.0.0"))
(defcustom lsp-modeline-code-actions-enable t
"Whether to show code actions on modeline."
:type 'boolean
:group 'lsp-modeline)
(defcustom lsp-modeline-diagnostics-enable t
"Whether to show diagnostics on modeline."
:type 'boolean
:group 'lsp-modeline)
(defcustom lsp-modeline-workspace-status-enable t
"Whether to show workspace status on modeline."
:type 'boolean
:group 'lsp-modeline
:package-version '(lsp-mode . "8.0.0"))
(defcustom lsp-headerline-breadcrumb-enable t
"Whether to enable breadcrumb on headerline."
:type 'boolean
:group 'lsp-headerline)
(defcustom lsp-configure-hook nil
"Hooks to run when `lsp-configure-buffer' is called."
:type 'hook
:group 'lsp-mode)
(defcustom lsp-unconfigure-hook nil
"Hooks to run when `lsp-unconfig-buffer' is called."
:type 'hook
:group 'lsp-mode)
(defcustom lsp-after-diagnostics-hook nil
"Hooks to run after diagnostics are received.
Note: it runs only if the receiving buffer is open. Use
`lsp-diagnostics-updated-hook'if you want to be notified when
diagnostics have changed."
:type 'hook
:group 'lsp-mode)
(define-obsolete-variable-alias 'lsp-after-diagnostics-hook
'lsp-diagnostics-updated-hook "lsp-mode 6.4")
(defcustom lsp-diagnostics-updated-hook nil
"Hooks to run after diagnostics are received."
:type 'hook
:group 'lsp-mode)
(define-obsolete-variable-alias 'lsp-workspace-folders-changed-hook
'lsp-workspace-folders-changed-functions "lsp-mode 6.3")
(defcustom lsp-workspace-folders-changed-functions nil
"Hooks to run after the folders has changed.
The hook will receive two parameters list of added and removed folders."
:type 'hook
:group 'lsp-mode)
(defcustom lsp-eldoc-hook '(lsp-hover)
"Hooks to run for eldoc."
:type 'hook
:group 'lsp-mode)
(defcustom lsp-before-apply-edits-hook nil
"Hooks to run before applying edits."
:type 'hook
:group 'lsp-mode)
(defgroup lsp-imenu nil
"LSP Imenu."
:group 'lsp-mode
:tag "LSP Imenu")
(defcustom lsp-imenu-show-container-name t
"Display the symbol's container name in an imenu entry."
:type 'boolean
:group 'lsp-imenu)
(defcustom lsp-imenu-container-name-separator "/"
"Separator string to use to separate the container name from the symbol while
displaying imenu entries."
:type 'string
:group 'lsp-imenu)
(defcustom lsp-imenu-sort-methods '(kind name)
"How to sort the imenu items.
The value is a list of `kind' `name' or `position'. Priorities
are determined by the index of the element."
:type '(repeat (choice (const name)
(const position)
(const kind)))
:group 'lsp-imenu)
(defcustom lsp-imenu-index-symbol-kinds nil
"Which symbol kinds to show in imenu."
:type '(repeat (choice (const :tag "Miscellaneous" nil)
(const :tag "File" File)
(const :tag "Module" Module)
(const :tag "Namespace" Namespace)
(const :tag "Package" Package)
(const :tag "Class" Class)
(const :tag "Method" Method)
(const :tag "Property" Property)
(const :tag "Field" Field)
(const :tag "Constructor" Constuctor)
(const :tag "Enum" Enum)
(const :tag "Interface" Interface)
(const :tag "Function" Function)
(const :tag "Variable" Variable)
(const :tag "Constant" Constant)
(const :tag "String" String)
(const :tag "Number" Number)
(const :tag "Boolean" Boolean)
(const :tag "Array" Array)
(const :tag "Object" Object)
(const :tag "Key" Key)
(const :tag "Null" Null)
(const :tag "Enum Member" EnumMember)
(const :tag "Struct" Struct)
(const :tag "Event" Event)
(const :tag "Operator" Operator)
(const :tag "Type Parameter" TypeParameter)))
:group 'lsp-imenu)
;; vibhavp: Should we use a lower value (5)?
(defcustom lsp-response-timeout 10
"Number of seconds to wait for a response from the language server before
timing out."
:type 'number
:group 'lsp-mode)
(defcustom lsp-tcp-connection-timeout 2
"The timeout for tcp connection in seconds."
:type 'number
:group 'lsp-mode
:package-version '(lsp-mode . "6.2"))
(defconst lsp--imenu-compare-function-alist
(list (cons 'name #'lsp--imenu-compare-name)
(cons 'kind #'lsp--imenu-compare-kind)
(cons 'position #'lsp--imenu-compare-line-col))
"An alist of (METHOD . FUNCTION).
METHOD is one of the symbols accepted by
`lsp-imenu-sort-methods'.
FUNCTION takes two hash tables representing DocumentSymbol. It
returns a negative number, 0, or a positive number indicating
whether the first parameter is less than, equal to, or greater
than the second parameter.")
(defcustom lsp-diagnostic-clean-after-change nil
"When non-nil, clean the diagnostics on change.
Note that when that setting is nil, `lsp-mode' will show stale
diagnostics until server publishes the new set of diagnostics"
:type 'boolean
:group 'lsp-diagnostics
:package-version '(lsp-mode . "7.0.1"))
(defcustom lsp-server-trace nil
"Request tracing on the server side.
The actual trace output at each level depends on the language server in use.
Changes take effect only when a new session is started."
:type '(choice (const :tag "Disabled" "off")
(const :tag "Messages only" "messages")
(const :tag "Verbose" "verbose")
(const :tag "Default (disabled)" nil))
:group 'lsp-mode
:package-version '(lsp-mode . "6.1"))
(defcustom lsp-auto-touch-files t
"If non-nil ensure the files exist before sending
`textDocument/didOpen' notification."
:type 'boolean
:group 'lsp-mode
:package-version '(lsp-mode . "8.0.1"))
(defvar lsp-language-id-configuration '((".*\\.vue$" . "vue")
(".*\\.tsx$" . "typescriptreact")
(".*\\.ts$" . "typescript")
(".*\\.jsx$" . "javascriptreact")
(".*\\.js$" . "javascript")
(".*\\.xml$" . "xml")
(".*\\.hx$" . "haxe")
(".*\\.lua$" . "lua")
(".*\\.sql$" . "sql")
(".*\\.html$" . "html")
(".*\\.css" . "css")
(".*/settings.json$" . "jsonc")
(".*\\.json$" . "json")
(".*\\.jsonc$" . "jsonc")
(".*\\.php$" . "php")
(".*\\.svelte$" . "svelte")
(ada-mode . "ada")
(nxml-mode . "xml")
(sql-mode . "sql")
(vimrc-mode . "vim")
(sh-mode . "shellscript")
(scala-mode . "scala")
(julia-mode . "julia")
(clojure-mode . "clojure")
(clojurec-mode . "clojure")
(clojurescript-mode . "clojurescript")
(java-mode . "java")
(jdee-mode . "java")
(groovy-mode . "groovy")
(python-mode . "python")
(cython-mode . "python")
(lsp--render-markdown . "markdown")
(rust-mode . "rust")
(rustic-mode . "rust")
(kotlin-mode . "kotlin")
(css-mode . "css")
(less-mode . "less")
(less-css-mode . "less")
(lua-mode . "lua")
(sass-mode . "sass")
(ssass-mode . "sass")
(scss-mode . "scss")
(xml-mode . "xml")
(c-mode . "c")
(c++-mode . "cpp")
(objc-mode . "objective-c")
(html-mode . "html")
(sgml-mode . "html")
(mhtml-mode . "html")
(go-dot-mod-mode . "go.mod")
(go-mode . "go")
(graphql-mode . "graphql")
(haskell-mode . "haskell")
(hack-mode . "hack")
(php-mode . "php")
(powershell-mode . "powershell")
(powershell-mode . "PowerShell")
(json-mode . "json")
(jsonc-mode . "jsonc")
(rjsx-mode . "javascript")
(js2-mode . "javascript")
(js-mode . "javascript")
(typescript-mode . "typescript")
(fsharp-mode . "fsharp")
(reason-mode . "reason")
(caml-mode . "ocaml")
(tuareg-mode . "ocaml")
(swift-mode . "swift")
(elixir-mode . "elixir")
(conf-javaprop-mode . "spring-boot-properties")
(yaml-mode . "spring-boot-properties-yaml")
(ruby-mode . "ruby")
(enh-ruby-mode . "ruby")
(fortran-mode . "fortran")
(f90-mode . "fortran")
(elm-mode . "elm")
(dart-mode . "dart")
(erlang-mode . "erlang")
(dockerfile-mode . "dockerfile")
(csharp-mode . "csharp")
(csharp-tree-sitter-mode . "csharp")
(plain-tex-mode . "plaintex")
(latex-mode . "latex")
(v-mode . "v")
(vhdl-mode . "vhdl")
(verilog-mode . "verilog")
(terraform-mode . "terraform")
(ess-julia-mode . "julia")
(ess-r-mode . "r")
(crystal-mode . "crystal")
(nim-mode . "nim")
(dhall-mode . "dhall")
(cmake-mode . "cmake")
(purescript-mode . "purescript")
(gdscript-mode . "gdscript")
(perl-mode . "perl")
(cperl-mode . "perl")
(robot-mode . "robot")
(racket-mode . "racket")
(nix-mode . "nix")
(prolog-mode . "prolog")
(vala-mode . "vala")
(actionscript-mode . "actionscript")
(d-mode . "d")
(zig-mode . "zig")
(text-mode . "plaintext")
(markdown-mode . "markdown")
(gfm-mode . "markdown")
(beancount-mode . "beancount")
(conf-toml-mode . "toml"))
"Language id configuration.")
(defvar lsp--last-active-workspaces nil
"Keep track of last active workspace.
We want to try the last workspace first when jumping into a library
directory")
(defvar lsp-method-requirements
'(("textDocument/callHierarchy" :capability :callHierarchyProvider)
("textDocument/codeAction" :capability :codeActionProvider)
("codeAction/resolve"
:check-command (lambda (workspace)
(with-lsp-workspace workspace
(lsp:code-action-options-resolve-provider?
(or (lsp--capability :codeActionProvider)
(when-let ((maybe-capability (lsp--registered-capability "textDocument/codeAction"))
(capability-options (lsp--registered-capability-options maybe-capability)))
capability-options))))))
("textDocument/codeLens" :capability :codeLensProvider)
("textDocument/completion" :capability :completionProvider)
("completionItem/resolve"
:check-command (lambda (wk)
(with-lsp-workspace wk
(lsp:completion-options-resolve-provider?
(lsp--capability :completionProvider)))))
("textDocument/declaration" :capability :declarationProvider)
("textDocument/definition" :capability :definitionProvider)
("textDocument/documentColor" :capability :colorProvider)
("textDocument/documentLink" :capability :documentLinkProvider)
("textDocument/documentHighlight" :capability :documentHighlightProvider)
("textDocument/documentSymbol" :capability :documentSymbolProvider)
("textDocument/foldingRange" :capability :foldingRangeProvider)
("textDocument/formatting" :capability :documentFormattingProvider)
("textDocument/hover" :capability :hoverProvider)
("textDocument/implementation" :capability :implementationProvider)
("textDocument/linkedEditingRange" :capability :linkedEditingRangeProvider)
("textDocument/onTypeFormatting" :capability :documentOnTypeFormattingProvider)
("textDocument/prepareRename"
:check-command (lambda (workspace)
(with-lsp-workspace workspace
(lsp:rename-options-prepare-provider?
(or (lsp--capability :renameProvider)
(when-let ((maybe-capability (lsp--registered-capability "textDocument/rename")))
(lsp--registered-capability-options maybe-capability)))))))
("textDocument/rangeFormatting" :capability :documentRangeFormattingProvider)
("textDocument/references" :capability :referencesProvider)
("textDocument/rename" :capability :renameProvider)
("textDocument/selectionRange" :capability :selectionRangeProvider)
("textDocument/semanticTokens" :capability :semanticTokensProvider)
("textDocument/semanticTokensFull"
:check-command (lambda (workspace)
(with-lsp-workspace workspace
(lsp-get (lsp--capability :semanticTokensProvider) :full))))
("textDocument/semanticTokensFull/Delta"
:check-command (lambda (workspace)
(with-lsp-workspace workspace
(let ((capFull (lsp-get (lsp--capability :semanticTokensProvider) :full)))
(and (not (booleanp capFull)) (lsp-get capFull :delta))))))
("textDocument/semanticTokensRangeProvider"
:check-command (lambda (workspace)
(with-lsp-workspace workspace
(lsp-get (lsp--capability :semanticTokensProvider) :range))))
("textDocument/signatureHelp" :capability :signatureHelpProvider)
("textDocument/typeDefinition" :capability :typeDefinitionProvider)
("workspace/executeCommand" :capability :executeCommandProvider)
("workspace/symbol" :capability :workspaceSymbolProvider))
"Map methods to requirements.
It is used by request-sending functions to determine which server
must be used for handling a particular message.")
(defconst lsp--file-change-type
`((created . 1)
(changed . 2)
(deleted . 3)))
(defconst lsp--watch-kind
`((create . 1)
(change . 2)
(delete . 4)))
(defvar lsp-window-body-width 40
"Window body width when rendering doc.")
(defface lsp-face-highlight-textual
'((t :inherit highlight))
"Face used for textual occurrences of symbols."
:group 'lsp-mode)
(defface lsp-face-highlight-read
'((t :inherit highlight :underline t))
"Face used for highlighting symbols being read."
:group 'lsp-mode)
(defface lsp-face-highlight-write
'((t :inherit highlight :weight bold))
"Face used for highlighting symbols being written to."
:group 'lsp-mode)
(define-obsolete-variable-alias 'lsp-lens-auto-enable
'lsp-lens-enable "lsp-mode 7.0.1")
(defcustom lsp-lens-enable t
"Auto enable lenses if server supports."
:group 'lsp-lens
:type 'boolean
:package-version '(lsp-mode . "6.3"))
(defcustom lsp-symbol-highlighting-skip-current nil
"If non-nil skip current symbol when setting symbol highlights."
:group 'lsp-mode
:type 'boolean)
(defcustom lsp-file-watch-threshold 1000
"Show warning if the files to watch are more than.
Set to nil to disable the warning."
:type 'number
:group 'lsp-mode)
;;;###autoload(put 'lsp-file-watch-threshold 'safe-local-variable (lambda (i) (or (numberp i) (not i))))
(defvar lsp-custom-markup-modes
'((rust-mode "no_run" "rust,no_run" "rust,ignore" "rust,should_panic"))
"Mode to uses with markdown code blocks.
They are added to `markdown-code-lang-modes'")
(defcustom lsp-signature-render-documentation t
"Display signature documentation in `eldoc'."
:type 'boolean
:group 'lsp-mode
:package-version '(lsp-mode . "6.2"))
(defcustom lsp-signature-auto-activate '(:on-trigger-char :on-server-request)
"Auto activate signature conditions."
:type '(repeat (choice (const :tag "On trigger chars pressed." :on-trigger-char)
(const :tag "After selected completion." :after-completion)
(const :tag "When the server has sent show signature help." :on-server-request)))
:group 'lsp-mode
:package-version '(lsp-mode . "6.2"))
(defcustom lsp-signature-doc-lines 20
"If number, limit the number of lines to show in the docs."
:type 'number
:group 'lsp-mode
:package-version '(lsp-mode . "6.3"))
(defcustom lsp-signature-function 'lsp-lv-message
"The function used for displaying signature info.
It will be called with one param - the signature info. When
called with nil the signature info must be cleared."
:type 'function
:group 'lsp-mode
:package-version '(lsp-mode . "6.3"))
(defcustom lsp-keymap-prefix "s-l"
"LSP-mode keymap prefix."
:group 'lsp-mode
:type 'string
:package-version '(lsp-mode . "6.3"))
(defvar-local lsp--buffer-workspaces ()
"List of the buffer workspaces.")
(defvar lsp--session nil
"Contain the `lsp-session' for the current Emacs instance.")
(defvar lsp--tcp-port 10000)
(defvar lsp--client-packages-required nil
"If nil, `lsp-client-packages' are yet to be required.")
(defvar lsp--tcp-server-port 0
"The server socket which is opened when using `lsp-tcp-server' (a server
socket is opened in Emacs and the language server connects to it). The
default value of 0 ensures that a random high port is used. Set it to a positive
integer to use a specific port.")
(defvar lsp--tcp-server-wait-seconds 10
"Wait this amount of time for the client to connect to our server socket
when using `lsp-tcp-server'.")
(defvar-local lsp--document-symbols nil
"The latest document symbols.")
(defvar-local lsp--document-selection-range-cache nil
"The document selection cache.")
(defvar-local lsp--document-symbols-request-async nil
"If non-nil, request document symbols asynchronously.")
(defvar-local lsp--document-symbols-tick -1
"The value of `buffer-chars-modified-tick' when document
symbols were last retrieved.")
(defvar-local lsp--have-document-highlights nil
"Set to `t' on symbol highlighting, cleared on