Though many language servers work well out-of-the-box, most allow fine-grained control of their operation via specific configuration options that are transmitted over the LSP protocol and vary from server to server. A small number of servers require such special configuration to work acceptably, or even to work at all.
After having setup a server executable program in
eglot-server-programs
(see Setting Up LSP Servers) and
ensuring Eglot can invoke it, you may want to take advantage of some
of these options. You should first distinguish two main kinds of
server configuration:
When you have decided which kind you need, the following sections teach how Eglot’s user variables can be used to achieve it:
It’s important to note that not all servers allow both kinds of configuration, nor is it guaranteed that user options can be copied over to project options, and vice-versa. When in doubt, consult your language server’s documentation.
It’s also worth noting that some language servers can read these
settings from configuration files in the user’s HOME
directory
or in a project’s directory. For example, the pylsp
Python
server reads the file ~/.config/pycodestyle for user
configuration. The clangd
C/C++ server reads both
~/.config/clangd/config.yaml for user configuration and
.clangd for project configuration. It may be advantageous to
use these mechanisms instead of Eglot’s, as this will probably work
with other LSP clients and may be easier to debug than options riding
on the LSP wire.