@@ -34,6 +34,11 @@ The hook will receive two parameters list of added and removed folders."
3434 :type 'hook
3535 :group 'lsp-mode )
3636
37+ (defcustom lsp-eldoc-hook '(lsp-document-highlight lsp-hover)
38+ " Hooks to run for eldoc."
39+ :type 'hook
40+ :group 'lsp-mode )
41+
3742(defconst lsp--file-change-type
3843 `((created . 1 )
3944 (changed . 2 )
@@ -332,12 +337,6 @@ whitelist, or does not match any pattern in the blacklist."
332337 :type '(repeat regexp)
333338 :group 'lsp-mode )
334339
335- ;;;### autoload
336- (defcustom lsp-enable-eldoc t
337- " Enable `eldoc-mode' integration."
338- :type 'boolean
339- :group 'lsp-mode )
340-
341340(defcustom lsp-auto-execute-action t
342341 " Auto-execute single action."
343342 :type 'boolean
@@ -352,18 +351,6 @@ the symbol information."
352351 :type 'boolean
353352 :group 'lsp-mode )
354353
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-
367354;;;### autoload
368355(defcustom lsp-enable-completion-at-point t
369356 " Enable `completion-at-point' integration."
@@ -394,15 +381,6 @@ before saving a document."
394381 :type 'boolean
395382 :group 'lsp-mode )
396383
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-
406384;;;### autoload
407385(defface lsp-face-highlight-textual
408386 '((t :inherit highlight ))
@@ -1066,11 +1044,8 @@ remove."
10661044 (lsp--capability " documentRangeFormattingProvider" ))
10671045 (setq-local indent-region-function #'lsp-format-region ))
10681046
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 )
10741049
10751050 (add-hook 'after-change-functions #'lsp-on-change nil t )
10761051 (add-hook 'after-revert-hook #'lsp-on-revert nil t )
@@ -1253,7 +1228,7 @@ interface TextDocumentEdit {
12531228
12541229(defun lsp--text-edit-sort-predicate (e1 e2 )
12551230 (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)))))
12571232 (if (= start1 start2)
12581233 (let ((end1 (lsp--position-to-point (gethash " end" (gethash " range" e1))))
12591234 (end2 (lsp--position-to-point (gethash " end" (gethash " range" e2)))))
@@ -1780,19 +1755,16 @@ Returns xref-item(s)."
17801755 (lsp--send-notification (lsp--make-notification " $/cancelRequest"
17811756 `(:id , id )))))
17821757
1783- (defun lsp--on-hover ()
1758+ (defun lsp-eldoc-function ()
17841759 ; ; This function is used as ‘eldoc-documentation-function’, so it’s important
17851760 ; ; 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 )
17961768
17971769(defun lsp-describe-thing-at-point ()
17981770 " 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."
19281900 (cl-check-type renderer function)
19291901 (setf (lsp--client-default-renderer client) renderer))
19301902
1931- (defun lsp-info-under-point ()
1903+ (defun lsp-hover ()
19321904 " Show relevant documentation for the thing under point."
19331905 (interactive )
19341906 (lsp--text-document-hover-string))
19351907
19361908(defvar-local lsp--current-signature-help-request-id nil )
19371909
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" )))
19631914 (when lsp--current-signature-help-request-id
19641915 (lsp--cancel-request lsp--current-signature-help-request-id))
19651916 (let (bounds body)
@@ -2148,14 +2099,16 @@ interface DocumentRangeFormattingParams {
21482099 (delete-overlay overlay))
21492100 (remhash buf overlays)))
21502101
2151- (defun lsp-symbol -highlight ()
2102+ (defun lsp-document -highlight ()
21522103 " Highlight all relevant references to the symbol under point."
21532104 (interactive )
2105+ (unless (lsp--capability " documentHighlightProvider" )
2106+ (signal 'lsp-capability-not-supported (list " documentHighlightProvider" )))
21542107 (lsp--send-request-async (lsp--make-request " textDocument/documentHighlight"
21552108 (lsp--text-document-position-params))
2156- (lsp--make-symbol -highlight-callback (current-buffer ))))
2109+ (lsp--make-document -highlight-callback (current-buffer ))))
21572110
2158- (defun lsp--make-symbol -highlight-callback (buf )
2111+ (defun lsp--make-document -highlight-callback (buf )
21592112 " Create a callback to process the reply of a
21602113'textDocument/documentHightlight' message for the buffer BUF.
21612114A reference is highlighted only if it is visible in a window."
0 commit comments