diff options
| -rw-r--r-- | modules/prog-lsp.el | 9 | ||||
| -rw-r--r-- | tests/test-prog-lsp--add-file-watch-ignored-extras.el | 28 |
2 files changed, 36 insertions, 1 deletions
diff --git a/modules/prog-lsp.el b/modules/prog-lsp.el index a6037db8..8e889678 100644 --- a/modules/prog-lsp.el +++ b/modules/prog-lsp.el @@ -10,9 +10,12 @@ ;; Forward declarations for byte-compile and let-binding under lexical scope. ;; Real definitions are lsp-mode's defcustoms. +(defvar eldoc-documentation-functions) (defvar lsp-file-watch-ignored-directories) (defvar lsp-enable-remote) +(declare-function lsp-eldoc-function "lsp-mode") + ;;;;; --------------------- File-Watch Ignore Patterns --------------------- ;; lsp-mode prompts when a workspace exceeds `lsp-file-watch-threshold' (1000) ;; directories. Real source repos cross that line easily once node_modules, @@ -45,6 +48,10 @@ Idempotent — `add-to-list' skips patterns already present." (dolist (pattern cj/lsp-file-watch-ignored-extras) (add-to-list 'lsp-file-watch-ignored-directories pattern))) +(defun cj/lsp--disable-eldoc-hover () + "Remove lsp-mode's Eldoc hover provider in the current buffer." + (remove-hook 'eldoc-documentation-functions #'lsp-eldoc-function t)) + ;;;;; ---------------------------- LSP Mode --------------------------- (use-package lsp-mode @@ -65,7 +72,7 @@ Idempotent — `add-to-list' skips patterns already present." (setq lsp-enable-on-type-formatting nil) (setq lsp-signature-auto-activate nil) (setq lsp-signature-render-documentation nil) - (setq lsp-eldoc-hook nil) + (add-hook 'lsp-managed-mode-hook #'cj/lsp--disable-eldoc-hover) (setq lsp-modeline-code-actions-enable nil) (setq lsp-modeline-diagnostics-enable nil) (setq lsp-headerline-breadcrumb-enable nil) diff --git a/tests/test-prog-lsp--add-file-watch-ignored-extras.el b/tests/test-prog-lsp--add-file-watch-ignored-extras.el index 255832e4..6213b58c 100644 --- a/tests/test-prog-lsp--add-file-watch-ignored-extras.el +++ b/tests/test-prog-lsp--add-file-watch-ignored-extras.el @@ -16,6 +16,10 @@ ;; activates lsp-mode. In the test environment, this stub provides the value ;; cell `add-to-list' needs. (defvar lsp-file-watch-ignored-directories nil) +(defvar eldoc-documentation-functions nil) + +(defun lsp-eldoc-function (&rest _args) + "Stub lsp-mode Eldoc function for tests.") (require 'prog-lsp) @@ -83,5 +87,29 @@ (should-error (cj/lsp--add-file-watch-ignored-extras) :type 'wrong-type-argument))) +(ert-deftest test-prog-lsp--disable-eldoc-hover-removes-lsp-provider-locally () + "Normal: remove lsp-mode's Eldoc provider from the buffer-local hook." + (with-temp-buffer + (setq-local eldoc-documentation-functions + '(lsp-eldoc-function eldoc-documentation-default)) + (cj/lsp--disable-eldoc-hover) + (should-not (memq #'lsp-eldoc-function eldoc-documentation-functions)) + (should (memq 'eldoc-documentation-default eldoc-documentation-functions)))) + +(ert-deftest test-prog-lsp--disable-eldoc-hover-does-not-touch-default-value () + "Boundary: disabling LSP Eldoc in one buffer leaves the default hook alone." + (let ((eldoc-documentation-functions '(lsp-eldoc-function))) + (with-temp-buffer + (setq-local eldoc-documentation-functions '(lsp-eldoc-function)) + (cj/lsp--disable-eldoc-hover) + (should-not (memq #'lsp-eldoc-function eldoc-documentation-functions))) + (should (memq #'lsp-eldoc-function eldoc-documentation-functions)))) + +(ert-deftest test-prog-lsp--module-no-obsolete-lsp-eldoc-hook-reference () + "Regression: prog-lsp should not reference obsolete `lsp-eldoc-hook'." + (with-temp-buffer + (insert-file-contents (expand-file-name "modules/prog-lsp.el" user-emacs-directory)) + (should-not (re-search-forward "\\_<lsp-eldoc-hook\\_>" nil t)))) + (provide 'test-prog-lsp--add-file-watch-ignored-extras) ;;; test-prog-lsp--add-file-watch-ignored-extras.el ends here |
