|
4 | 4 |
|
5 | 5 | ;; Author: Vibhav Pant, Fangrui Song, Ivan Yonchovski
|
6 | 6 | ;; Keywords: languages
|
7 |
| -;; 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")) |
| 7 | +;; Package-Requires: ((emacs "26.3") (dash "2.18.0") (f "0.20.0") (ht "2.3") (spinner "1.7.3") (markdown-mode "2.3") (lv "0") (eldoc "1.11")) |
8 | 8 | ;; Version: 8.0.1
|
9 | 9 |
|
10 | 10 | ;; URL: https://github.com/emacs-lsp/lsp-mode
|
@@ -607,10 +607,7 @@ The hook will receive two parameters list of added and removed folders."
|
607 | 607 | :type 'hook
|
608 | 608 | :group 'lsp-mode)
|
609 | 609 |
|
610 |
| -(defcustom lsp-eldoc-hook '(lsp-hover) |
611 |
| - "Hooks to run for eldoc." |
612 |
| - :type 'hook |
613 |
| - :group 'lsp-mode) |
| 610 | +(define-obsolete-variable-alias 'lsp-eldoc-hook 'eldoc-documentation-functions "lsp-mode 8.0.1") |
614 | 611 |
|
615 | 612 | (defcustom lsp-before-apply-edits-hook nil
|
616 | 613 | "Hooks to run before applying edits."
|
@@ -1190,17 +1187,6 @@ See #2049"
|
1190 | 1187 | "Display lsp error message with FORMAT with ARGS."
|
1191 | 1188 | (lsp--message "%s :: %s" (propertize "LSP" 'face 'error) (apply #'format format args)))
|
1192 | 1189 |
|
1193 |
| -(defun lsp--eldoc-message (&optional msg) |
1194 |
| - "Show MSG in eldoc." |
1195 |
| - (setq lsp--eldoc-saved-message msg) |
1196 |
| - (run-with-idle-timer 0 nil (lambda () |
1197 |
| - ;; XXX: new eldoc in Emacs 28 |
1198 |
| - ;; recommends running the hook variable |
1199 |
| - ;; `eldoc-documentation-functions' |
1200 |
| - ;; instead of using eldoc-message |
1201 |
| - (with-no-warnings |
1202 |
| - (eldoc-message msg))))) |
1203 |
| - |
1204 | 1190 | (defun lsp-log (format &rest args)
|
1205 | 1191 | "Log message to the ’*lsp-log*’ buffer.
|
1206 | 1192 |
|
@@ -3972,13 +3958,23 @@ yet."
|
3972 | 3958 | (lsp-disconnect)
|
3973 | 3959 | (lsp))
|
3974 | 3960 |
|
| 3961 | +;; TODO remove those eldoc workarounds when dropping support for Emacs 27 |
| 3962 | +;; https://github.com/emacs-lsp/lsp-mode/issues/3295#issuecomment-1308994099 |
| 3963 | +(defvar eldoc-documentation-default) ; CI |
| 3964 | +(when (< emacs-major-version 28) |
| 3965 | + (unless (boundp 'eldoc-documentation-functions) |
| 3966 | + (load "eldoc")) |
| 3967 | + (when (memq (default-value 'eldoc-documentation-function) '(nil ignore)) |
| 3968 | + ;; actually `eldoc-documentation-strategy', but CI was failing |
| 3969 | + (setq-default eldoc-documentation-function 'eldoc-documentation-default))) |
| 3970 | + |
3975 | 3971 | (define-minor-mode lsp-managed-mode
|
3976 | 3972 | "Mode for source buffers managed by lsp-mode."
|
3977 | 3973 | :lighter nil
|
3978 | 3974 | (cond
|
3979 | 3975 | (lsp-managed-mode
|
3980 | 3976 | (when (lsp-feature? "textDocument/hover")
|
3981 |
| - (add-function :before-until (local 'eldoc-documentation-function) #'lsp-eldoc-function) |
| 3977 | + (add-hook 'eldoc-documentation-functions #'lsp-eldoc-function nil t) |
3982 | 3978 | (eldoc-mode 1))
|
3983 | 3979 |
|
3984 | 3980 | (add-hook 'after-change-functions #'lsp-on-change nil t)
|
@@ -4013,8 +4009,8 @@ yet."
|
4013 | 4009 | (lsp--on-idle buffer)))))))
|
4014 | 4010 | (t
|
4015 | 4011 | (lsp-unconfig-buffer)
|
4016 |
| - (remove-function (local 'eldoc-documentation-function) #'lsp-eldoc-function) |
4017 | 4012 |
|
| 4013 | + (remove-hook 'eldoc-documentation-functions #'lsp-eldoc-function t) |
4018 | 4014 | (remove-hook 'post-command-hook #'lsp--post-command t)
|
4019 | 4015 | (remove-hook 'after-change-functions #'lsp-on-change t)
|
4020 | 4016 | (remove-hook 'after-revert-hook #'lsp-on-revert t)
|
@@ -5078,10 +5074,32 @@ If EXCLUDE-DECLARATION is non-nil, request the server to include declarations."
|
5078 | 5074 | (->> lsp--cur-workspace lsp--workspace-client lsp--client-response-handlers (remhash id))
|
5079 | 5075 | (lsp-notify "$/cancelRequest" `(:id ,id))))
|
5080 | 5076 |
|
5081 |
| -(defun lsp-eldoc-function () |
5082 |
| - "`lsp-mode' eldoc function." |
5083 |
| - (run-hooks 'lsp-eldoc-hook) |
5084 |
| - eldoc-last-message) |
| 5077 | +(defvar-local lsp--hover-saved-bounds nil) |
| 5078 | + |
| 5079 | +(defun lsp-eldoc-function (cb &rest _ignored) |
| 5080 | + "`lsp-mode' eldoc function to display hover info (based on `textDocument/hover')." |
| 5081 | + (if (and lsp--hover-saved-bounds |
| 5082 | + (lsp--point-in-bounds-p lsp--hover-saved-bounds)) |
| 5083 | + lsp--eldoc-saved-message |
| 5084 | + (setq lsp--hover-saved-bounds nil |
| 5085 | + lsp--eldoc-saved-message nil) |
| 5086 | + (if (looking-at "[[:space:]\n]") |
| 5087 | + (setq lsp--eldoc-saved-message nil) ; And returns nil. |
| 5088 | + (when (and lsp-eldoc-enable-hover (lsp--capability :hoverProvider)) |
| 5089 | + (lsp-request-async |
| 5090 | + "textDocument/hover" |
| 5091 | + (lsp--text-document-position-params) |
| 5092 | + (-lambda ((hover &as &Hover? :range? :contents)) |
| 5093 | + (setq lsp--hover-saved-bounds (when range? |
| 5094 | + (lsp--range-to-region range?))) |
| 5095 | + (funcall cb (setq lsp--eldoc-saved-message |
| 5096 | + (when contents |
| 5097 | + (lsp--render-on-hover-content |
| 5098 | + contents |
| 5099 | + lsp-eldoc-render-all))))) |
| 5100 | + :error-handler #'ignore |
| 5101 | + :mode 'tick |
| 5102 | + :cancel-token :eldoc-hover))))) |
5085 | 5103 |
|
5086 | 5104 | (defun lsp--point-on-highlight? ()
|
5087 | 5105 | (-some? (lambda (overlay)
|
@@ -5675,36 +5693,6 @@ It will show up only if current point has signature help."
|
5675 | 5693 | :mode 'unchanged
|
5676 | 5694 | :cancel-token :document-color-token)))
|
5677 | 5695 |
|
5678 |
| - |
5679 |
| -;; hover |
5680 |
| - |
5681 |
| -(defvar-local lsp--hover-saved-bounds nil) |
5682 |
| - |
5683 |
| -(defun lsp-hover () |
5684 |
| - "Display hover info (based on `textDocument/signatureHelp')." |
5685 |
| - (if (and lsp--hover-saved-bounds |
5686 |
| - (lsp--point-in-bounds-p lsp--hover-saved-bounds)) |
5687 |
| - (lsp--eldoc-message lsp--eldoc-saved-message) |
5688 |
| - (setq lsp--hover-saved-bounds nil |
5689 |
| - lsp--eldoc-saved-message nil) |
5690 |
| - (if (looking-at "[[:space:]\n]") |
5691 |
| - (lsp--eldoc-message nil) |
5692 |
| - (when (and lsp-eldoc-enable-hover (lsp-feature? "textDocument/hover")) |
5693 |
| - (lsp-request-async |
5694 |
| - "textDocument/hover" |
5695 |
| - (lsp--text-document-position-params) |
5696 |
| - (-lambda ((hover &as &Hover? :range? :contents)) |
5697 |
| - (when hover |
5698 |
| - (when range? |
5699 |
| - (setq lsp--hover-saved-bounds (lsp--range-to-region range?))) |
5700 |
| - (lsp--eldoc-message (and contents |
5701 |
| - (lsp--render-on-hover-content |
5702 |
| - contents |
5703 |
| - lsp-eldoc-render-all))))) |
5704 |
| - :error-handler #'ignore |
5705 |
| - :mode 'tick |
5706 |
| - :cancel-token :eldoc-hover))))) |
5707 |
| - |
5708 | 5696 |
|
5709 | 5697 |
|
5710 | 5698 | (defun lsp--action-trigger-parameter-hints (_command)
|
|
0 commit comments