Eglot supports (a subset of) the Language Server Protocol. However, there are useful protocol extensions that are not (yet) part of the official protocol specification. Eglot-x adds support for some of them.
Add the following line to your init file to enable eglot-x
(with-eval-after-load 'eglot (require 'eglot-x))
To adjust which extensions are enabled:
M-x customize-group RET eglot-x RET
The extension allows the client and the server to have
separate file systems. For example, the server can run inside a
Docker container, or the source code can be on a remote system
accessed by Tramp. The client can send files to the server only from
the result of project-files
. The list of eligible files can further
limited by eglot-x-files-visible-regexp
and
eglot-x-files-hidden-regexp
. This feature works if project-roots
and project-external-roots
are set correctly.
Enabling extension disables Eglot's built-in support for Tramp files.
The command `eglot-x-find-refs' is the entry point for the extra methods. You can bind it to a key:
(define-key eglot-mode-map (kbd "s-.") #'eglot-x-find-refs)
Currently, the ccls
and rust-analyzer
are the only
servers whose extra reference methods eglot-x supports.
The extension allows the client and the server to negotiate a proper encoding to be used in transmitting column positions.
-
Snippet TextEdits: see variable
eglot-x-enable-snippet-text-edit
. -
Join Lines: see defun
eglot-x-join-lines
. -
Move Item: see defun
eglot-x-move-item-down
andeglot-x-move-item-up
. -
On Enter: see defun
eglot-x-on-enter
. -
Matching Brace: see
eglot-x-matching-brace
. However, emacs' ownbackward-sexp
, andforward-sexp
seem to be more useful. -
Open External Documentation: see defun
eglot-x-open-external-documentation
. -
Structural Search Replace (SSR): see defun
eglot-x-structural-search-replace
.The server checks the correctness of the query while you type:
The replacement process is similar to
query-replace
: -
Workspace Symbols Filtering: see defun
eglot-x-find-workspace-symbol
.The xref buffer shows the current matches while the user iteratively types the query and another buffer shows the location of the first match.
Additional input refines the results and the point in main.rs is changed once again to the location of the new first result:
You can change the search scope and kind with
C-l
andC-M-l
, respectively. See variableeglot-x-ws-keymap
. The non-default settings are shown between braces:Currently, the xref buffer shows the first lines of the matches. This is not always helpful.
-
Runnables: see defun
eglot-x-ask-runnables
.Results for the whole buffer:
Selecting the first "runnable":
The "runnable" is executed as a
compile-command
: -
Server Status: see variable
eglot-x-enable-server-status
. The mode-line displays the status unless it is "permanently OK". -
Inlay Hints: for an initial, basic support see defun
eglot-x-insert-inlay-hint-at-point
.
-
Expand Macro: see defun
eglot-x-expand-macro
. -
Related Tests: see defun
eglot-x-ask-related-tests
. -
Reload Workspace: see defun
eglot-x-reload-workspace
. -
View Crate Graph: see variable
eglot-x-graph-type
and defuneglot-x-view-crate-graph
.You can also jump to the crate (Cargo.toml) if the graph-type is not 'svg':
-
Analyzer Status: see defun
eglot-x-analyzer-status
. -
Syntax Tree: see defun
eglot-x-show-syntax-tree
. -
View Hir: see defun
eglot-x-view-hir
. -
(Memory Usage): see defun
eglot-x-memory-usage
.