Top Related Projects
Emacs client/library for the Language Server Protocol
On the fly syntax checking for GNU Emacs
Emacs :heart: Debug Adapter Protocol
🍀 Next-generation, purely functional package manager for the Emacs hacker.
A blazingly fast LSP client for Emacs
Quick Overview
Eglot is an Emacs LSP client that aims to be minimal, simple, and easy to use. It provides IDE-like features such as code completion, documentation, and error checking by leveraging the Language Server Protocol (LSP) in Emacs.
Pros
- Lightweight and fast compared to other LSP clients for Emacs
- Easy to set up and configure with minimal configuration required
- Integrates well with built-in Emacs features and other popular packages
- Supports a wide range of programming languages through various language servers
Cons
- May lack some advanced features found in more complex LSP clients
- Documentation can be sparse for some advanced use cases
- Occasional stability issues with certain language servers
- Limited customization options compared to some alternatives
Getting Started
To get started with Eglot, follow these steps:
- Install Eglot using your preferred package manager (e.g., use-package, straight.el):
(use-package eglot
:ensure t
:hook ((python-mode . eglot-ensure)
(rust-mode . eglot-ensure)))
-
Install the necessary language servers for your programming languages.
-
Open a file in a supported language, and Eglot will automatically start the appropriate language server.
-
Use Emacs commands like
M-x eglot-rename
for refactoring,M-x xref-find-definitions
for navigation, and enjoy autocompletion and diagnostics out of the box.
Competitor Comparisons
Emacs client/library for the Language Server Protocol
Pros of lsp-mode
- More feature-rich with extensive customization options
- Supports a wider range of language servers and configurations
- Integrates well with other Emacs packages like company, flycheck, and treemacs
Cons of lsp-mode
- Heavier and potentially slower, especially on older hardware
- Configuration can be complex and overwhelming for new users
- May require more manual setup for some language servers
Code Comparison
lsp-mode configuration example:
(use-package lsp-mode
:hook ((python-mode . lsp)
(rust-mode . lsp))
:commands lsp
:config
(setq lsp-prefer-flymake nil))
eglot configuration example:
(use-package eglot
:hook ((python-mode . eglot-ensure)
(rust-mode . eglot-ensure))
:config
(add-to-list 'eglot-server-programs '(rust-mode . ("rust-analyzer"))))
Both lsp-mode and eglot aim to provide Language Server Protocol (LSP) support for Emacs. lsp-mode offers a more comprehensive set of features and integrations, while eglot focuses on simplicity and lightweight implementation. The choice between them often depends on user preferences, system resources, and specific language server requirements.
On the fly syntax checking for GNU Emacs
Pros of Flycheck
- Supports a wide range of programming languages and linters
- Highly customizable with extensive configuration options
- Well-established project with a large user base and community support
Cons of Flycheck
- Requires manual setup and configuration for each language/linter
- Can be resource-intensive, especially with multiple linters enabled
- May have slower performance compared to Eglot's LSP-based approach
Code Comparison
Flycheck configuration example:
(use-package flycheck
:ensure t
:init (global-flycheck-mode))
(setq flycheck-python-pylint-executable "pylint")
(setq flycheck-python-flake8-executable "flake8")
Eglot configuration example:
(use-package eglot
:ensure t
:hook (python-mode . eglot-ensure))
(add-to-list 'eglot-server-programs '(python-mode . ("pylsp")))
Summary
Flycheck is a versatile syntax checking tool with broad language support and extensive customization options. It's well-established but requires more manual setup. Eglot, on the other hand, leverages the Language Server Protocol for a more streamlined, potentially faster experience with less configuration needed. The choice between them depends on specific needs and preferences for syntax checking in Emacs.
Emacs :heart: Debug Adapter Protocol
Pros of dap-mode
- More comprehensive debugging features, including support for breakpoints, watch expressions, and step-through debugging
- Integrates well with lsp-mode, providing a unified experience for development and debugging
- Supports a wider range of debug adapters, allowing for debugging in multiple languages and environments
Cons of dap-mode
- Steeper learning curve due to more complex configuration and setup
- Heavier resource usage, which may impact performance on older or less powerful machines
- Requires additional setup and configuration for each language or debug adapter
Code Comparison
Eglot configuration:
(use-package eglot
:ensure t
:config
(add-to-list 'eglot-server-programs '(python-mode . ("pyls"))))
dap-mode configuration:
(use-package dap-mode
:ensure t
:after lsp-mode
:config
(require 'dap-python)
(dap-mode 1)
(dap-ui-mode 1))
Both Eglot and dap-mode offer LSP integration for Emacs, but they serve different purposes. Eglot focuses on providing a lightweight, easy-to-configure LSP client, while dap-mode extends lsp-mode with advanced debugging capabilities. The choice between them depends on the user's needs for debugging features and their preference for simplicity versus comprehensive functionality.
🍀 Next-generation, purely functional package manager for the Emacs hacker.
Pros of straight.el
- Provides a more flexible and customizable package management system
- Allows for reproducible Emacs configurations across different machines
- Supports multiple package sources and version control systems
Cons of straight.el
- Steeper learning curve compared to built-in package management
- May require more manual configuration and maintenance
- Can potentially slow down Emacs startup time with large configurations
Code Comparison
eglot
(use-package eglot
:ensure t
:config
(add-to-list 'eglot-server-programs '(python-mode . ("pyls"))))
straight.el
(straight-use-package 'eglot)
(require 'eglot)
(add-to-list 'eglot-server-programs '(python-mode . ("pyls")))
Summary
While eglot focuses on providing a lightweight LSP client for Emacs, straight.el is a package management system that offers more control over package installation and versioning. eglot is easier to set up and use out of the box, while straight.el provides greater flexibility and reproducibility at the cost of increased complexity. The choice between the two depends on the user's needs for package management and LSP functionality in their Emacs configuration.
A blazingly fast LSP client for Emacs
Pros of lsp-bridge
- Faster performance due to its asynchronous design and use of Python for backend processing
- More extensive features, including code actions, signature help, and hover documentation
- Better support for multi-root workspaces
Cons of lsp-bridge
- More complex setup and configuration compared to Eglot's simpler approach
- Requires Python to be installed and configured on the system
- Less integrated with Emacs' built-in features and packages
Code Comparison
lsp-bridge:
(use-package lsp-bridge
:config
(global-lsp-bridge-mode)
(setq lsp-bridge-python-command "python3"))
Eglot:
(use-package eglot
:config
(add-to-list 'eglot-server-programs '(python-mode . ("pyls")))
(add-hook 'python-mode-hook 'eglot-ensure))
Both packages aim to provide Language Server Protocol (LSP) support for Emacs, but they differ in their implementation and feature set. lsp-bridge offers more advanced features and potentially better performance, especially for larger projects. However, it comes with a more complex setup and external dependencies. Eglot, on the other hand, provides a simpler, more integrated solution that works well out of the box for many users, but may lack some advanced features and performance optimizations found in lsp-bridge.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
M-x Eglot
Emacs Polyglot is the Emacs LSP client that stays out of your way:
- ð½ Scroll down this README for some pretty gifs
- ð Read Eglot's manual and release notes
- ð Folks over at Google seem to like it. Thanks!
- ð¾ Eglot now lives in Emacs itself!
See also eglot-x for non-standard protocol extensions support.
Get stable GNU ELPA version
Just type M-x package-install RET eglot RET
into Emacs 26.3+.
Now find some source file, any source file, and type M-x eglot
.
That's it. If you're lucky, this guesses the LSP program to start for the language you're using. Otherwise, it prompts you to enter one.
Get latest development version from GNU-Devel ELPA
First, configure this repository.
(add-to-list 'package-archives '("gnu-devel" . "https://elpa.gnu.org/devel/"))
Then, use M-x package-install
or M-x package-update
to install
an ELPA package from the latest upstream.
Contribute to Eglot's development
Eglot is now in Emacs's core! Upcoming Emacs 29 will have M-x eglot
built-in.
The recommended way to experiment with changes to the latest Eglot is to compile Emacs yourself.
From a development perspective, moving to core allows us to work on Eglot in tandem with other related packages already in Emacs, such as Flymake, ElDoc, Xref, Project.
This means adding or tweaking an Emacs LSP feature is a matter of submitting a single patch targetting multiple relevant packages, not just Eglot.
These :core
packages (Eglot included) are then released periodically
to GNU ELPA, so users of other Emacs's versions can get them via
M-x package-install
.
Status of this GitHub repository
This repository is not the development upstream anymore, but it's not dead (yet):
-
It may be used to start discussions.
Sometimes, it's possible the discussion or bug report will be moved to Emacs's bug tracker. You may take the initiative and start discussion there using
M-x report-emacs-bug
or simply sending mail tobug-gnu-emacs@gnu.org
.Please the Eglot-specific bug-reporting instructions.
-
The
eglot.el
file here is periodically updated to mirror the Emacs upstream -
The existing tests of
eglot-tests.el
, also periodically updated, may be used to rehearse and validate patches using GitHub CI infrastructure.
Connecting to a server
These are just some of the servers that M-x eglot
can use out of the
box. The full list can be consulted in the eglot-server-programs
variable, where you can easily add your own servers.
- Ada's ada_language_server
- Bash's bash-language-server
- C/C++'s clangd or ccls
- C#'s omnisharp
- Clojure's clojure-lsp
- CMake's cmake-language-server
- CSS's css-languageserver
- Dart's analysis_server
- Dockerfile's docker-langserver
- Elixir's elixir-ls
- Elm's elm-language-server
- Erlang's erlang_ls
- Fortran's fortls
- Futhark's futhark lsp
- Go's gopls
- Godot Engine's built-in LSP
- HTML html-languageserver
- Haskell's haskell-language-server
- JSON's vscode-json-languageserver
- Java's Eclipse JDT Language Server
- Javascript's TS & JS Language Server
- Kotlin's kotlin-language-server
- Lua's lua-lsp
- Markdown's marksman
- Mint's mint-ls
- Nix's rnix-lsp
- Ocaml's ocaml-lsp
- Perl's Perl::LanguageServer
- PHP's php-language-server
- PureScript's purescript-language-server
- Python's pylsp, pyls pyright, or jedi-language-server
- R's languageserver
- Racket's racket-langserver
- Ruby's solargraph
- Rust's rust-analyzer
- Scala's metals
- TeX/LaTeX's Digestif ot texlab
- VimScript's vim-language-server
- YAML's yaml-language-server
- Zig's zls
Obligatory animated gif section
Completion
The animation shows company-mode presenting the completion
candidates to the user, but Eglot works with the built-in
completion-at-point
function as well, which is usually bound to
C-M-i
.
Snippet completion
Eglot provides template based completion if the server supports
snippet completion and yasnippet is enabled before
Eglot connects to the server. The animation shows
company-mode, but completion-at-point
also works with
snippets.
Diagnostics
Eglot relays the diagnostics information received from the LSP server
to Emacs's Flymake, which annotates/underlines the
problematic parts of the buffer. The information is shared with the
ElDoc system, meaning that the commands eldoc
and
eldoc-doc-buffer
(the latter bound to C-h-.
for convenience) show
diagnostics along with other documentation under point.
Flymake provides other convenient ways to view and manage diagnostic errors. These are described in its manual.
When Eglot manages a buffer, it disables pre-existing Flymake
backends. See variable eglot-stay-out-of
to change that.
Code Actions
The LSP server may provide code actions, for example, to fix a
diagnostic error or to suggest refactoring edits. The commands are
frequently associating with Flymake diagnostic annotations, so that
left-clicking them shows a menu. Additionally, the command
eglot-code-actions
asks the server for any code spanning a given
region.
Sometimes, these code actions are initiated by the server. See
eglot-confirm-server-initiated-edits
to control that behaviour.
Hover on symbol /function signature
Here, too, the LSP server's view of a given symbol or function
signature is relayed to the ElDoc system. The commands
eldoc
and eldoc-doc-buffer
commands access that information.
There are customization variables to help adjust ElDoc's
liberal use of the lower "echo area", among other options. If you
still find the solicitous nature of this LSP feature too distracing,
you can use eglot-ignored-server-capabilities
to turn it off.
Rename
Type M-x eglot-rename RET
to rename the symbol at point.
Find definition
To jump to the definition of a symbol, use the built-in
xref-find-definitions
command, which is bound to M-.
.
Find references
Eglot here relies on Emacs' built-in functionality as well.
xref-find-references
is bound to M-?
. Additionally, Eglot
provides the following similar commands: eglot-find-declaration
,
eglot-find-implementation
, eglot-find-typeDefinition
.
Historical differences to lsp-mode.el
Around May 2018, I wrote a comparison of Eglot to lsp-mode.el
, and
was discussed with its then-maintainer. That mode has since been
refactored/rewritten and now
purports to support
a lot of features that differentiated Eglot from it. It may now be
very different or very similar to Eglot, or even sing with the birds
in the trees, so go check it out. That said, here's the
original comparison, which I will not be updating any more.
"Eglot is considerably less code and hassle than lsp-mode.el. In most cases, there's nothing to configure. It's a minimalist approach focused on user experience and performance.
User-visible differences:
-
The single most visible difference is the friendly entry point
M-x eglot
, notM-x eglot-<language>
. Also, there are noeglot-<language>
extra packages. -
There's no "whitelisting" or "blacklisting" directories to languages.
M-x eglot
starts servers to handle file of a major mode inside a specific project, using Emacs's built-inproject.el
library to discover projects. Then it automatically detects current and future opened files under that project and syncs with server; -
Easy way to quit/restart a server, just middle/right click on the connection name;
-
Pretty interactive mode-line section for live tracking of server communication;
-
Automatically restarts frequently crashing servers;
-
Slow-to-start servers start asynchronously in the background;
-
Server-initiated edits are confirmed with the user;
-
Diagnostics work out-of-the-box (no
flycheck.el
needed); -
Smoother/more responsive (read below).
Under the hood:
- Message parser is much simpler.
- Defers signature requests like
textDocument/hover
until server is ready. - Sends
textDocument/didChange
for groups of edits, not one per each tiny change. - Easier to read and maintain elisp. Yeah I know, very subjective, so judge for yourself.
- Doesn't require anything other than Emacs, but will automatically
upgrade to work with stuff outside Emacs, like
company
,markdown-mode
, if you happen to have these installed. - Has automated tests that check against actual LSP servers."
Copyright Assignment
Eglot
is subject to the same copyright assignment
policy as GNU Emacs
.
Any legally significant contributions can only be merged after the author has completed their paperwork. Please ask for the request form, and we'll send it to you.
Top Related Projects
Emacs client/library for the Language Server Protocol
On the fly syntax checking for GNU Emacs
Emacs :heart: Debug Adapter Protocol
🍀 Next-generation, purely functional package manager for the Emacs hacker.
A blazingly fast LSP client for Emacs
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot