Skip to content

Commit e83c78b

Browse files
committed
Eglot: respect user's Eldoc configuration by default
This change addresses the problems reported in many Elglot reports dating back to early 2021 at least: joaotavora/eglot#648 joaotavora/eglot#894 joaotavora/eglot#920 joaotavora/eglot#1031 joaotavora/eglot#1171 In one form or another, the reports point out that the multiple pieces of information about the "thing at point" made available by the LSP server are not all being considered by the ElDoc system. The reason for this is Eglot setting/trampling the variables 'eldoc-documentation-strategy' and 'eldoc-documentation-functions' in its minor more entry function. The reason it did that is historical and is partially described in the issues above. But, evidently, it never made much sense, because so many people want to override it, which requires setting 'eldoc-documentation-strategy' to the non-default value 'eldoc-documentation-compose'. The problem was made worse by the fact that setting it as usual in either the Customize menu or their init file didn't work, requiring a fairly complex Elisp snippet. That is now solved as of this commit. If the user does not do any setting, then Eglot works basically the same as before (i.e. shows only one piece of information). It is arguable that the default value for 'eldoc-documentation-strategy' should change globally to 'eldoc-documentation-compose', but that has other subtle implications and is not part of this commit. * lisp/progmodes/eglot.el (eglot--managed-mode): Don't set Eldoc variables greedily.
1 parent 5d0b45c commit e83c78b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lisp/progmodes/eglot.el

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,11 +1760,6 @@ Use `eglot-managed-p' to determine if current buffer is managed.")
17601760
(add-hook 'change-major-mode-hook #'eglot--managed-mode-off nil t)
17611761
(add-hook 'post-self-insert-hook 'eglot--post-self-insert-hook nil t)
17621762
(add-hook 'pre-command-hook 'eglot--pre-command-hook nil t)
1763-
(eglot--setq-saving eldoc-documentation-functions
1764-
'(eglot-signature-eldoc-function
1765-
eglot-hover-eldoc-function))
1766-
(eglot--setq-saving eldoc-documentation-strategy
1767-
#'eldoc-documentation-enthusiast)
17681763
(eglot--setq-saving xref-prompt-for-identifier nil)
17691764
(eglot--setq-saving flymake-diagnostic-functions '(eglot-flymake-backend))
17701765
(eglot--setq-saving company-backends '(company-capf))
@@ -1773,7 +1768,12 @@ Use `eglot-managed-p' to determine if current buffer is managed.")
17731768
(add-function :before-until (local 'imenu-create-index-function)
17741769
#'eglot-imenu))
17751770
(unless (eglot--stay-out-of-p 'flymake) (flymake-mode 1))
1776-
(unless (eglot--stay-out-of-p 'eldoc) (eldoc-mode 1))
1771+
(unless (eglot--stay-out-of-p 'eldoc)
1772+
(add-hook 'eldoc-documentation-functions #'eglot-hover-eldoc-function
1773+
nil t)
1774+
(add-hook 'eldoc-documentation-functions #'eglot-signature-eldoc-function
1775+
nil t)
1776+
(eldoc-mode 1))
17771777
(cl-pushnew (current-buffer) (eglot--managed-buffers (eglot-current-server))))
17781778
(t
17791779
(remove-hook 'after-change-functions 'eglot--after-change t)

0 commit comments

Comments
 (0)