Skip to content

Eglot Features

While Eglot is enabled in a buffer, it is said to be managing it, using LSP and the specific capabilities of the language server to activate and enhance modern IDE features in Emacs. Some of these features are provided via other Emacs packages, and some via Eglot directly (see Eglot Commands).

Here’s an overview of the main features that Eglot provides:

  • At-point documentation: when point is at or near a symbol or an identifier, the information about the symbol/identifier, such as the signature of a function or class method and server-generated diagnostics, is made available via the ElDoc package (see Programming Language Doc in GNU Emacs Manual). This allows major modes to provide extensive help and documentation about the program identifiers.
  • On-the-fly diagnostic annotations, via the Flymake package (see GNU Flymake manual). Eglot’s Flymake backend replaces other Flymake backends while it is managing a buffer, and enhances diagnostics with interactive server-suggested fixes (so-called code actions, see Eglot Commands)
  • Finding definitions and uses of identifiers, via Xref (see Xref in GNU Emacs Manual). Eglot provides a backend for the Xref capabilities which uses the language-server understanding of the program source. In particular, it eliminates the need to generate tags tables (see Tags tables in GNU Emacs Manual) for languages which are only supported by the etags backend.
  • Buffer navigation by name of function, class, method, etc., via Imenu (see Imenu in GNU Emacs Manual). Eglot provides its own variant of imenu-create-index-function, which generates the index for the buffer based on language-server program source analysis.
  • Enhanced completion of symbol at point by the completion-at-point command (see Symbol Completion in GNU Emacs Manual). This uses the language-server’s parser data for the completion candidates.
  • Automatic reformatting of source code as you type it. This is similar to what the eglot-format command does (see below), but is activated automatically as you type.
  • If a completion package such as company-mode, a popular third-party completion package (or any other completion package), is installed, Eglot enhances it by providing completion candidates based on the language-server analysis of the source code. (company-mode can be installed from GNU ELPA.)
  • If yasnippet, a popular third-party package for automatic insertion of code templates (snippets), is installed, and the language server supports snippet completion candidates, Eglot arranges for the completion package to instantiate these snippets using yasnippet. (yasnippet can be installed from GNU ELPA.)
  • If the popular third-party package markdown-mode is installed, and the server provides at-point documentation formatted as Markdown in addition to plain text, Eglot arranges for the ElDoc package to enrich this text with fontifications and other nice formatting before displaying it to the user. This makes the documentation shown by ElDoc look nicer on display.
  • In addition to enabling and enhancing other features and packages, Eglot also provides a number of user commands based on the capabilities of language servers. Examples include renaming symbols with eglot-rename and asking to automatically correct problems with eglot-code-actions. See Eglot Commands.

Not all servers support the full set of LSP capabilities, but most of them support enough to enable the basic set of features mentioned above.

Conversely, some servers offer capabilities for which no equivalent Emacs package exists yet, and so Eglot cannot (yet) expose these capabilities to Emacs users. However, See Extending Eglot.

Finally, it’s worth noting that, by default, Eglot generally turns on all features that it can turn on. It’s possible to opt out of some features via user options (see Customizing Eglot) and a hook that runs after Eglot starts managing a buffer (see Buffers, Projects, and Eglot).