3.4 Eglot Variables

This section provides a reference for the Eglot user options.


This option controls the ability to reconnect automatically to the language server when Eglot detects that the server process terminated unexpectedly. The default value 3 means to attempt reconnection only if the previous successful connection lasted for more than that number of seconds; a different positive value changes the minimal length of the connection to trigger reconnection. A value of t means always reconnect automatically, and nil means never reconnect (in which case you will need to reconnect manually using M-x eglot).


This specifies the number of seconds before connection attempt to a language server times out. The value of nil means never time out. The default is 30 seconds.


This setting is mainly important for connections which are slow to establish. Whereas the variable eglot-connect-timeout controls how long to wait for, this variable controls whether to block Emacs’s user interface while waiting. The default value is 3; a positive value means block for that many seconds, then wait for the connection in the background. The value of t means block during the whole waiting period. The value of nil or 0 means don’t block at all during the waiting period.


This determines the size of the Eglot events buffer. See eglot-events-buffer, for how to display that buffer. If the value is changed, for it to take effect the connection should be restarted using M-x eglot-reconnect. See Troubleshooting Eglot, for when this could be useful.


If this is non-nil, Eglot shuts down a language server when the last buffer managed by it is killed. See Shutting Down LSP Servers. The default is nil; if you want to shut down a server, use M-x eglot-shutdown (see Eglot Commands).


Various Eglot commands and code actions result in the language server sending editing commands to Emacs. If this option’s value is non-nil (the default), Eglot will ask for confirmation before performing edits initiated by the server or edits whose scope affects buffers other than the one where the user initiated the request.


This variable’s value is a list of language server capabilities that Eglot should not use. The default is nil: Eglot uses all of the capabilities supported by each server.


If this is non-nil, and M-. (xref-find-definitions) lands you in a file outside of your project, such as a system-installed library or header file, transiently consider that file as managed by the same language server. That file is still outside your project (i.e. project-find-file won’t find it), but Eglot and the server will consider it to be part of the workspace. The default is nil.


This variable is the keymap for binding Eglot-related command. It is in effect only as long as the buffer is managed by Eglot. By default, it is empty, with the single exception: C-h . is remapped to invoke eldoc-doc-buffer. You can bind additional commands in this map. For example:

  (define-key eglot-mode-map (kbd "C-c r") 'eglot-rename)
  (define-key eglot-mode-map (kbd "C-c o") 'eglot-code-action-organize-imports)
  (define-key eglot-mode-map (kbd "C-c h") 'eldoc)
  (define-key eglot-mode-map (kbd "<f6>") 'xref-find-definitions)

Additional variables, which are relevant for customizing the server connections, are documented in Customizing Eglot.