-
-
Notifications
You must be signed in to change notification settings - Fork 895
/
lsp-mode.el
9999 lines (8847 loc) · 428 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-2024 emacs-lsp maintainers
;; Author: Vibhav Pant, Fangrui Song, Ivan Yonchovski
;; Keywords: languages
;; Package-Requires: ((emacs "27.1") (dash "2.18.0") (f "0.20.0") (ht "2.3") (spinner "1.7.3") (markdown-mode "2.3") (lv "0") (eldoc "1.11"))
;; Version: 9.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 'help-mode)
(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 . "9.0.0"))
(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-ansible lsp-asm lsp-astro
lsp-autotools lsp-awk lsp-bash lsp-beancount lsp-bufls lsp-clangd
lsp-clojure lsp-cmake lsp-cobol lsp-credo lsp-crystal lsp-csharp lsp-css
lsp-copilot lsp-cucumber lsp-cypher lsp-d lsp-dart lsp-dhall lsp-docker lsp-dockerfile
lsp-earthly lsp-elixir lsp-elm lsp-emmet lsp-erlang lsp-eslint lsp-fortran lsp-futhark
lsp-fsharp lsp-gdscript lsp-gleam lsp-glsl lsp-go lsp-golangci-lint lsp-grammarly
lsp-graphql lsp-groovy lsp-hack lsp-haskell lsp-haxe lsp-idris lsp-java
lsp-javascript lsp-jq lsp-json lsp-kotlin lsp-latex lsp-lisp lsp-ltex
lsp-lua lsp-fennel lsp-magik lsp-markdown lsp-marksman lsp-mdx lsp-meson lsp-metals lsp-mint
lsp-mojo lsp-move lsp-mssql lsp-nextflow lsp-nginx lsp-nim lsp-nix lsp-nushell lsp-ocaml
lsp-openscad lsp-pascal lsp-perl lsp-perlnavigator lsp-php lsp-pls
lsp-purescript lsp-pwsh lsp-pyls lsp-pylsp lsp-pyright lsp-python-ms
lsp-qml lsp-r lsp-racket lsp-remark lsp-rf lsp-roslyn lsp-rubocop lsp-ruby-lsp
lsp-ruby-syntax-tree lsp-ruff lsp-rust lsp-semgrep lsp-shader
lsp-solargraph lsp-solidity lsp-sonarlint lsp-sorbet lsp-sourcekit
lsp-sql lsp-sqls lsp-steep lsp-svelte lsp-tailwindcss lsp-terraform
lsp-tex lsp-tilt lsp-toml lsp-trunk lsp-ttcn3 lsp-typeprof lsp-typespec lsp-v
lsp-vala lsp-verilog lsp-vetur lsp-vhdl lsp-vimscript lsp-volar lsp-wgsl
lsp-xml lsp-yaml lsp-yang 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)
(defcustom lsp-progress-spinner-type 'progress-bar
"Holds the type of spinner to be used in the mode-line.
Takes a value accepted by `spinner-start'."
:group 'lsp-mode
:type `(choice :tag "Choose a spinner by name"
,@(mapcar (lambda (c) (list 'const (car c)))
spinner-types)))
(defvar-local lsp-use-workspace-root-for-server-default-directory nil
"Use `lsp-workspace-root' for `default-directory' when starting LSP process.")
(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-guess-root-without-session nil
"Ignore the session file when calculating the project root.
You almost always want to set lsp-auto-guess-root too.
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/blocklisted 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\\'"
"[/\\\\]\\.gitlab\\'"
"[/\\\\]\\.circleci\\'"
"[/\\\\]\\.hg\\'"
"[/\\\\]\\.bzr\\'"
"[/\\\\]_darcs\\'"
"[/\\\\]\\.svn\\'"
"[/\\\\]_FOSSIL_\\'"
;; IDE or build tools
"[/\\\\]\\.idea\\'"
"[/\\\\]\\.ensime_cache\\'"
"[/\\\\]\\.eunit\\'"
"[/\\\\]node_modules"
"[/\\\\]\\.yarn\\'"
"[/\\\\]\\.fslckout\\'"
"[/\\\\]\\.tox\\'"
"[/\\\\]\\.nox\\'"
"[/\\\\]dist\\'"
"[/\\\\]dist-newstyle\\'"
"[/\\\\]\\.stack-work\\'"
"[/\\\\]\\.bloop\\'"
"[/\\\\]\\.metals\\'"
"[/\\\\]target\\'"
"[/\\\\]\\.ccls-cache\\'"
"[/\\\\]\\.vs\\'"
"[/\\\\]\\.vscode\\'"
"[/\\\\]\\.venv\\'"
"[/\\\\]\\.mypy_cache\\'"
"[/\\\\]\\.pytest_cache\\'"
;; Swift Package Manager
"[/\\\\]\\.build\\'"
;; Python
"[/\\\\]__pycache__\\'"
"[/\\\\]site-packages\\'"
"[/\\\\].pyenv\\'"
;; Autotools output
"[/\\\\]\\.deps\\'"
"[/\\\\]build-aux\\'"
"[/\\\\]autom4te.cache\\'"
"[/\\\\]\\.reference\\'"
;; Bazel
"[/\\\\]bazel-[^/\\\\]+\\'"
;; CSharp
"[/\\\\]\\.cache[/\\\\]lsp-csharp\\'"
"[/\\\\]\\.meta\\'"
"[/\\\\]\\.nuget\\'"
;; Unity
"[/\\\\]Library\\'"
;; Clojure
"[/\\\\]\\.lsp\\'"
"[/\\\\]\\.clj-kondo\\'"
"[/\\\\]\\.shadow-cljs\\'"
"[/\\\\]\\.babel_cache\\'"
"[/\\\\]\\.cpcache\\'"
"[/\\\\]\\checkouts\\'"
;; Gradle
"[/\\\\]\\.gradle\\'"
;; Maven
"[/\\\\]\\.m2\\'"
;; .Net Core build-output
"[/\\\\]bin/Debug\\'"
"[/\\\\]obj\\'"
;; OCaml and Dune
"[/\\\\]_opam\\'"
"[/\\\\]_build\\'"
;; Elixir
"[/\\\\]\\.elixir_ls\\'"
;; Elixir Credo
"[/\\\\]\\.elixir-tools\\'"
;; terraform and terragrunt
"[/\\\\]\\.terraform\\'"
"[/\\\\]\\.terragrunt-cache\\'"
;; nix-direnv
"[/\\\\]\\result"
"[/\\\\]\\result-bin"
"[/\\\\]\\.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
;;;###autoload(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
;;;###autoload(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-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 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 textDocument/hover.
If this is set to nil, `eldoc' will show only the symbol information."
:type 'boolean
:group 'lsp-mode)
(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)
(define-obsolete-variable-alias
'lsp-references-exclude-definition
'lsp-references-exclude-declaration
"9.0.1")
(defcustom lsp-references-exclude-declaration nil
"If non-nil, exclude declarations when finding references."
: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-apply-edits-after-file-operations t
"Whether to apply edits returned by server after file operations if any.
Applicable only if server supports workspace.fileOperations for operations:
`workspace/willRenameFiles', `workspace/willCreateFiles' and
`workspace/willDeleteFiles'."
:group 'lsp-mode
:type 'boolean)
(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)
(define-obsolete-variable-alias 'lsp-eldoc-hook 'eldoc-documentation-functions "lsp-mode 9.0.0")
(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" Constructor)
(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. Nil if no timeout."
:type '(choice
(number :tag "Seconds")
(const :tag "No timeout" nil))
: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 . "9.0.0"))
(defvar lsp-language-id-configuration
'(("\\(^CMakeLists\\.txt\\|\\.cmake\\)\\'" . "cmake")
("\\(^Dockerfile\\(?:\\..*\\)?\\|\\.[Dd]ockerfile\\)\\'" . "dockerfile")
("\\.astro$" . "astro")
("\\.cs\\'" . "csharp")
("\\.css$" . "css")
("\\.cypher$" . "cypher")
("Earthfile" . "earthfile")
("\\.ebuild$" . "shellscript")
("\\.go\\'" . "go")
("\\.html$" . "html")
("\\.hx$" . "haxe")
("\\.hy$" . "hy")
("\\.java\\'" . "java")
("\\.jq$" . "jq")
("\\.js$" . "javascript")
("\\.json$" . "json")
("\\.jsonc$" . "jsonc")
("\\.jsonnet$" . "jsonnet")
("\\.jsx$" . "javascriptreact")
("\\.lua$" . "lua")
("\\.fnl$" . "fennel")
("\\.mdx\\'" . "mdx")
("\\.nu$" . "nushell")
("\\.php$" . "php")
("\\.ps[dm]?1\\'" . "powershell")
("\\.rs\\'" . "rust")
("\\.spec\\'" . "rpm-spec")
("\\.sql$" . "sql")
("\\.svelte$" . "svelte")
("\\.toml\\'" . "toml")
("\\.ts$" . "typescript")
("\\.tsp$" . "typespec")
("\\.tsx$" . "typescriptreact")
("\\.ttcn3$" . "ttcn3")
("\\.vue$" . "vue")
("\\.xml$" . "xml")
("\\ya?ml$" . "yaml")
("^PKGBUILD$" . "shellscript")
("^go\\.mod\\'" . "go.mod")
("^settings\\.json$" . "jsonc")
("^yang\\.settings$" . "jsonc")
("^meson\\(_options\\.txt\\|\\.\\(build\\|format\\)\\)\\'" . "meson")
(ada-mode . "ada")
(ada-ts-mode . "ada")
(gpr-mode . "gpr")
(gpr-ts-mode . "gpr")
(awk-mode . "awk")
(awk-ts-mode . "awk")
(nxml-mode . "xml")
(sql-mode . "sql")
(vimrc-mode . "vim")
(vimscript-ts-mode . "vim")
(sh-mode . "shellscript")
(bash-ts-mode . "shellscript")
(ebuild-mode . "shellscript")
(pkgbuild-mode . "shellscript")
(envrc-file-mode . "shellscript")
(scala-mode . "scala")
(scala-ts-mode . "scala")
(julia-mode . "julia")
(julia-ts-mode . "julia")
(clojure-mode . "clojure")
(clojurec-mode . "clojure")
(clojurescript-mode . "clojurescript")
(clojure-ts-mode . "clojure")
(clojure-ts-clojurec-mode . "clojure")
(clojure-ts-clojurescript-mode . "clojurescript")
(java-mode . "java")
(java-ts-mode . "java")
(jdee-mode . "java")
(groovy-mode . "groovy")
(nextflow-mode . "nextflow")
(python-mode . "python")
(python-ts-mode . "python")
(cython-mode . "python")
("\\(\\.mojo\\|\\.🔥\\)\\'" . "mojo")
(lsp--render-markdown . "markdown")
(move-mode . "move")
(rust-mode . "rust")
(rust-ts-mode . "rust")
(rustic-mode . "rust")
(kotlin-mode . "kotlin")
(kotlin-ts-mode . "kotlin")
(css-mode . "css")
(css-ts-mode . "css")
(less-mode . "less")
(less-css-mode . "less")
(lua-mode . "lua")
(lua-ts-mode . "lua")
(sass-mode . "sass")
(ssass-mode . "sass")
(scss-mode . "scss")
(scad-mode . "openscad")
(xml-mode . "xml")
(c-mode . "c")
(c-ts-mode . "c")
(c++-mode . "cpp")
(c++-ts-mode . "cpp")
(cuda-mode . "cuda")
(objc-mode . "objective-c")
(html-mode . "html")
(html-ts-mode . "html")
(sgml-mode . "html")
(mhtml-mode . "html")
(mint-mode . "mint")
(go-dot-mod-mode . "go.mod")
(go-mod-ts-mode . "go.mod")
(go-mode . "go")
(go-ts-mode . "go")
(graphql-mode . "graphql")
(haskell-mode . "haskell")
(haskell-ts-mode . "haskell")
(hack-mode . "hack")
(php-mode . "php")
(php-ts-mode . "php")
(powershell-mode . "powershell")
(powershell-mode . "PowerShell")
(powershell-ts-mode . "powershell")
(json-mode . "json")
(json-ts-mode . "json")
(jsonc-mode . "jsonc")
(rjsx-mode . "javascript")
(js2-mode . "javascript")
(js-mode . "javascript")
(js-ts-mode . "javascript")
(typescript-mode . "typescript")
(typescript-ts-mode . "typescript")
(typespec-mode . "typespec")
(tsx-ts-mode . "typescriptreact")
(svelte-mode . "svelte")
(fsharp-mode . "fsharp")
(reason-mode . "reason")
(caml-mode . "ocaml")
(tuareg-mode . "ocaml")
(futhark-mode . "futhark")
(swift-mode . "swift")
(elixir-mode . "elixir")
(elixir-ts-mode . "elixir")
(heex-ts-mode . "elixir")
(conf-javaprop-mode . "spring-boot-properties")
(yaml-mode . "yaml")
(yaml-ts-mode . "yaml")
(ruby-mode . "ruby")
(enh-ruby-mode . "ruby")
(ruby-ts-mode . "ruby")
(feature-mode . "cucumber")
(fortran-mode . "fortran")
(f90-mode . "fortran")
(elm-mode . "elm")
(dart-mode . "dart")
(erlang-mode . "erlang")
(dockerfile-mode . "dockerfile")
(dockerfile-ts-mode . "dockerfile")
(csharp-mode . "csharp")
(csharp-tree-sitter-mode . "csharp")
(csharp-ts-mode . "csharp")
(plain-tex-mode . "plaintex")
(context-mode . "context")
(cypher-mode . "cypher")
(latex-mode . "latex")
(LaTeX-mode . "latex")
(v-mode . "v")
(vhdl-mode . "vhdl")
(vhdl-ts-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")
(cmake-ts-mode . "cmake")
(purescript-mode . "purescript")
(gdscript-mode . "gdscript")
(gdscript-ts-mode . "gdscript")
(perl-mode . "perl")
(cperl-mode . "perl")
(robot-mode . "robot")
(racket-mode . "racket")
(nix-mode . "nix")
(nix-ts-mode . "nix")
(prolog-mode . "prolog")
(vala-mode . "vala")
(actionscript-mode . "actionscript")
(d-mode . "d")
(zig-mode . "zig")
(zig-ts-mode . "zig")
(text-mode . "plaintext")
(markdown-mode . "markdown")
(gfm-mode . "markdown")
(beancount-mode . "beancount")
(conf-toml-mode . "toml")
(toml-ts-mode . "toml")
(org-mode . "org")
(org-journal-mode . "org")
(nginx-mode . "nginx")
(magik-mode . "magik")
(magik-ts-mode . "magik")
(idris-mode . "idris")
(idris2-mode . "idris2")
(gleam-mode . "gleam")
(gleam-ts-mode . "gleam")
(graphviz-dot-mode . "dot")
(tiltfile-mode . "tiltfile")
(solidity-mode . "solidity")
(bibtex-mode . "bibtex")
(rst-mode . "restructuredtext")
(glsl-mode . "glsl")
(shader-mode . "shaderlab")
(wgsl-mode . "wgsl")
(jq-mode . "jq")
(jq-ts-mode . "jq")
(protobuf-mode . "protobuf")
(nushell-mode . "nushell")
(nushell-ts-mode . "nushell")
(meson-mode . "meson")
(yang-mode . "yang"))
"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?
(lsp--capability-for-method "textDocument/codeAction")))))
("textDocument/codeLens" :capability :codeLensProvider)
("textDocument/completion" :capability :completionProvider)
("completionItem/resolve"