Previous: Other Variables, Up: Customizing Eglot [Contents][Index]
As explained earlier (see Buffers, Projects, and Eglot), Eglot hooks onto
existing Emacs packages and features by setting special variables in its
special minor mode. To gain finer control of Eglot’s operation, the
eglot-managed-mode-hook should be used to tweak, subdue or
completely override Eglot’s setting of these variables.
eldoc-documentation-functions variable,
adding a number of functions to it:
eglot-hover-eldoc-function, to display general information
about an identifier.
eglot-signature-eldoc-function, to display function
signature information.
eglot-highlight-eldoc-function, to highlight nearby
manifestations of an identifier.
eglot-code-action-suggestion, to retrieve relevant code
actions at point.
A simple tweak to remove at-point identifier information for
hypothetical language Foo may look like:
(add-hook 'foo-mode-hook (lambda () (add-hook 'eglot-managed-mode-hook (lambda () (remove-hook 'eldoc-documentation-functions 'eglot-hover-eldoc-function nil t)) nil t)))
For more sophisticated changes, we can take advantage of ElDoc’s
well-defined protocols. See Programming Language Doc in GNU
Emacs Manual. For instance, the functions in
eldoc-display-functions control displays of the at-point
documentation produced by eldoc-documentation-functions. As an
example, to ensure that hover documentation specifically is never output
into the Echo area (in all programming modes):
(require 'cl-lib) (defun my/special-eglot-hover-function (cb &rest _ignored) "Same as `eglot-hover-eldoc-function`, but skip the echo area." (eglot-hover-eldoc-function (lambda (info &rest _ignore) (funcall cb info :echo 'skip)))) ;; substitute 'eldoc-hover-eldoc-function with our "fixed" variant. (add-hook 'eglot-managed-mode-hook (lambda () (setq-local eldoc-documentation-functions (cl-substitute #'my/special-eglot-hover-function 'eglot-hover-eldoc-function eldoc-documentation-functions))))
flymake-diagnostic-functions variable,
completely replacing its value with Eglot’s own
eglot-flymake-backend function. Additional backends may be added
to work alongside Eglot’s.
(add-hook 'foo-mode-hook (lambda () (add-hook 'eglot-managed-mode-hook (lambda () (add-hook 'flymake-diagnostic-functions #'my/special-foo-mode-backend nil t)) nil t)))
xref-backend-functions variable, adding
its own eglot-xref-backend function to it.
imenu-create-index-function.
completion-at-point-functions.
company-backends variable, ensuring
only the company-capf backend lives there. This ensures the same
set of completions as regular completion-at-point.
yas-minor-mode when needed to expand server-provided snippets.
Previous: Other Variables, Up: Customizing Eglot [Contents][Index]