@@ -34,6 +34,11 @@ The hook will receive two parameters list of added and removed folders."
34
34
:type 'hook
35
35
:group 'lsp-mode )
36
36
37
+ (defcustom lsp-eldoc-hook '(lsp-document-highlight lsp-hover)
38
+ " Hooks to run for eldoc."
39
+ :type 'hook
40
+ :group 'lsp-mode )
41
+
37
42
(defconst lsp--file-change-type
38
43
`((created . 1 )
39
44
(changed . 2 )
@@ -332,12 +337,6 @@ whitelist, or does not match any pattern in the blacklist."
332
337
:type '(repeat regexp)
333
338
:group 'lsp-mode )
334
339
335
- ;;;### autoload
336
- (defcustom lsp-enable-eldoc t
337
- " Enable `eldoc-mode' integration."
338
- :type 'boolean
339
- :group 'lsp-mode )
340
-
341
340
(defcustom lsp-auto-execute-action t
342
341
" Auto-execute single action."
343
342
:type 'boolean
@@ -352,18 +351,6 @@ the symbol information."
352
351
:type 'boolean
353
352
:group 'lsp-mode )
354
353
355
- ;;;### autoload
356
- (defcustom lsp-highlight-symbol-at-point t
357
- " Highlight the symbol under the point."
358
- :type 'boolean
359
- :group 'lsp-mode )
360
-
361
- ;;;### autoload
362
- (defcustom lsp-enable-codeaction t
363
- " Enable code action processing."
364
- :type 'boolean
365
- :group 'lsp-mode )
366
-
367
354
;;;### autoload
368
355
(defcustom lsp-enable-completion-at-point t
369
356
" Enable `completion-at-point' integration."
@@ -394,15 +381,6 @@ before saving a document."
394
381
:type 'boolean
395
382
:group 'lsp-mode )
396
383
397
- ;;;### autoload
398
- (defcustom lsp-hover-text-function 'lsp--text-document-hover-string
399
- " The LSP method to use to display text on hover."
400
- :type '(choice (function :tag " textDocument/hover"
401
- lsp--text-document-hover-string)
402
- (function :tag " textDocument/signatureHelp"
403
- lsp--text-document-signature-help))
404
- :group 'lsp-mode )
405
-
406
384
;;;### autoload
407
385
(defface lsp-face-highlight-textual
408
386
'((t :inherit highlight ))
@@ -1066,11 +1044,8 @@ remove."
1066
1044
(lsp--capability " documentRangeFormattingProvider" ))
1067
1045
(setq-local indent-region-function #'lsp-format-region ))
1068
1046
1069
- (when lsp-enable-eldoc
1070
- ; ; XXX: The documentation for `eldoc-documentation-function' suggests
1071
- ; ; using `add-function' for modifying its value, use that instead?
1072
- (setq-local eldoc-documentation-function #'lsp--on-hover )
1073
- (eldoc-mode 1 ))
1047
+ (add-function :before-until (local 'eldoc-documentation-function ) #'lsp-eldoc-function )
1048
+ (eldoc-mode 1 )
1074
1049
1075
1050
(add-hook 'after-change-functions #'lsp-on-change nil t )
1076
1051
(add-hook 'after-revert-hook #'lsp-on-revert nil t )
@@ -1253,7 +1228,7 @@ interface TextDocumentEdit {
1253
1228
1254
1229
(defun lsp--text-edit-sort-predicate (e1 e2 )
1255
1230
(let ((start1 (lsp--position-to-point (gethash " start" (gethash " range" e1))))
1256
- (start2 (lsp--position-to-point (gethash " start" (gethash " range" e2)))))
1231
+ (start2 (lsp--position-to-point (gethash " start" (gethash " range" e2)))))
1257
1232
(if (= start1 start2)
1258
1233
(let ((end1 (lsp--position-to-point (gethash " end" (gethash " range" e1))))
1259
1234
(end2 (lsp--position-to-point (gethash " end" (gethash " range" e2)))))
@@ -1780,19 +1755,16 @@ Returns xref-item(s)."
1780
1755
(lsp--send-notification (lsp--make-notification " $/cancelRequest"
1781
1756
`(:id , id )))))
1782
1757
1783
- (defun lsp--on-hover ()
1758
+ (defun lsp-eldoc-function ()
1784
1759
; ; This function is used as ‘eldoc-documentation-function’, so it’s important
1785
1760
; ; that it doesn’t fail.
1786
- (with-demoted-errors " Error in ‘lsp--on-hover’: %S"
1787
- (when (and (lsp--capability " documentHighlightProvider" )
1788
- lsp-highlight-symbol-at-point)
1789
- (lsp-symbol-highlight))
1790
- (when (and (or (lsp--capability " codeActionProvider" )
1791
- (lsp--registered-capability " textDocument/codeAction" ))
1792
- lsp-enable-codeaction)
1793
- (lsp--text-document-code-action))
1794
- (when (and (lsp--capability " hoverProvider" ) lsp-enable-eldoc)
1795
- (funcall lsp-hover-text-function))))
1761
+ (run-hook-wrapped 'lsp-eldoc-hook
1762
+ (lambda (fn )
1763
+ (condition-case nil
1764
+ (funcall fn)
1765
+ (lsp-capability-not-supported nil ))
1766
+ nil ))
1767
+ nil )
1796
1768
1797
1769
(defun lsp-describe-thing-at-point ()
1798
1770
" Display the full documentation of the thing at point."
@@ -1928,38 +1900,17 @@ It will be used when no language has been specified in document/onHover result."
1928
1900
(cl-check-type renderer function)
1929
1901
(setf (lsp--client-default-renderer client) renderer))
1930
1902
1931
- (defun lsp-info-under-point ()
1903
+ (defun lsp-hover ()
1932
1904
" Show relevant documentation for the thing under point."
1933
1905
(interactive )
1934
1906
(lsp--text-document-hover-string))
1935
1907
1936
1908
(defvar-local lsp--current-signature-help-request-id nil )
1937
1909
1938
- (defun lsp--text-document-signature-help ()
1939
- " interface SignatureHelp {
1940
- signatures: SignatureInformation[];
1941
- activeSignature?: number;
1942
- activeParameter?: number;
1943
- };
1944
-
1945
- interface SignatureInformation {
1946
- label: string;
1947
- documentation?: string | MarkupContent;
1948
- parameters?: ParameterInformation[];
1949
- };
1950
-
1951
- interface ParameterInformation {
1952
- label: string;
1953
- documentation?: string | MarkupContent;
1954
- };
1955
-
1956
- interface MarkupContent {
1957
- kind: MarkupKind;
1958
- value: string;
1959
- };
1960
-
1961
- type MarkupKind = 'plaintext' | 'markdown';"
1962
- (lsp--cur-workspace-check)
1910
+ (defun lsp-signature-help ()
1911
+ (interactive )
1912
+ (unless (lsp--capability " signatureHelpProvider" )
1913
+ (signal 'lsp-capability-not-supported (list " signatureHelpProvider" )))
1963
1914
(when lsp--current-signature-help-request-id
1964
1915
(lsp--cancel-request lsp--current-signature-help-request-id))
1965
1916
(let (bounds body)
@@ -2148,14 +2099,16 @@ interface DocumentRangeFormattingParams {
2148
2099
(delete-overlay overlay))
2149
2100
(remhash buf overlays)))
2150
2101
2151
- (defun lsp-symbol -highlight ()
2102
+ (defun lsp-document -highlight ()
2152
2103
" Highlight all relevant references to the symbol under point."
2153
2104
(interactive )
2105
+ (unless (lsp--capability " documentHighlightProvider" )
2106
+ (signal 'lsp-capability-not-supported (list " documentHighlightProvider" )))
2154
2107
(lsp--send-request-async (lsp--make-request " textDocument/documentHighlight"
2155
2108
(lsp--text-document-position-params))
2156
- (lsp--make-symbol -highlight-callback (current-buffer ))))
2109
+ (lsp--make-document -highlight-callback (current-buffer ))))
2157
2110
2158
- (defun lsp--make-symbol -highlight-callback (buf )
2111
+ (defun lsp--make-document -highlight-callback (buf )
2159
2112
" Create a callback to process the reply of a
2160
2113
'textDocument/documentHightlight' message for the buffer BUF.
2161
2114
A reference is highlighted only if it is visible in a window."
0 commit comments