this:
@lisp
-(add-to-list 'eglot-server-programs
- '(foo-mode . ("fools" "--stdio")))
+(with-eval-after-load 'eglot
+ (add-to-list 'eglot-server-programs
+ '(foo-mode . ("fools" "--stdio"))))
@end lisp
This will invoke the program @command{fools} with the command-line
Creation,,, elisp, GNU Emacs Lisp Reference Manual}), for Eglot to be
able to find it.
+Sometimes, multiple servers are acceptable alternatives for handling a
+given major-mode. In those cases, you may combine the helper function
+@code{eglot-alternatives} with the funcional form of
+@code{eglot-server-programs}.
+
+@lisp
+(with-eval-after-load 'eglot
+ (add-to-list 'eglot-server-programs
+ `(foo-mode . ,(eglot-alternatives
+ '(("fools" "--stdio")
+ ("phewls" "--fast"))))))
+@end lisp
+
+If you have @command{fools} and @command{phewls} installed, the
+function produced by @code{eglot-alternatives} will prompt for the
+server to use in @code{foo-mode} buffers. Else it will use whichever
+is available.
+
@node Starting Eglot
@section Starting Eglot
@cindex starting Eglot
Here's an example:
@lisp
+(require 'eglot)
+
(add-to-list 'eglot-server-programs
- '((c++ mode c-mode) . (eglot-cquery "cquery")))
+ '((c++-mode c-mode) . (eglot-cquery "cquery")))
(defclass eglot-cquery (eglot-lsp-server) ()
:documentation "A custom class for cquery's C/C++ langserver.")
the call is interactive, the function can ask the user for
hints on finding the required programs, etc. Otherwise, it
should not ask the user for any input, and return nil or signal
- an error if it can't produce a valid CONTACT.")
+ an error if it can't produce a valid CONTACT. The helper
+ function `eglot-alternatives' (which see) can be used to
+ produce a function that offers more than one server for a given
+ MAJOR-MODE.")
(defface eglot-highlight-symbol-face
'((t (:inherit bold)))