• Stars
    star
    2,256
  • Rank 20,411 (Top 0.5 %)
  • Language
    Emacs Lisp
  • License
    GNU General Publi...
  • Created over 7 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A client for Language Server Protocol servers

Build status GNU ELPA MELPA

M-x Eglot

Emacs Polyglot is the Emacs LSP client that stays out of your way:

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):

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.

Obligatory animated gif section

Completion

eglot-completions

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-snippets-on-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-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

eglot-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

eglot-hover-on-symbol

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

eglot-rename

Type M-x eglot-rename RET to rename the symbol at point.

Find definition

eglot-xref-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-xref-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, not M-x eglot-<language>. Also, there are no eglot-<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-in project.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.

More Repositories

1

yasnippet

A template system for Emacs
Emacs Lisp
2,770
star
2

sly

Sylvester the Cat's Common Lisp IDE
Common Lisp
1,256
star
3

autopair

Automagically pair braces and quotes in emacs like TextMate
Emacs Lisp
208
star
4

snooze

Common Lisp RESTful web development
Common Lisp
206
star
5

breadcrumb

Emacs headerline indication of where you are in a large project
Emacs Lisp
189
star
6

darkroom

Simple distraction-free editing
Emacs Lisp
147
star
7

hunchensocket

RFC6455 compliant WebSockets for Common Lisp
Common Lisp
109
star
8

beardbolt

Compiler Explorer clone
Emacs Lisp
86
star
9

fiasco

A test framework for Common Lisp
Common Lisp
55
star
10

snippet

A rewrite of Yasnippet's engine (incomplete, but many parts done)
Emacs Lisp
30
star
11

sly-quicklisp

Quicklisp support for SLY
Emacs Lisp
29
star
12

sly-macrostep

Expand CL macros inside source files
Emacs Lisp
28
star
13

sly-stepper

sly-slepper
TeX
27
star
14

yasmate

Convert textmate bundles to yasnippet format
Emacs Lisp
24
star
15

eslack

Slack client for Emacs
Emacs Lisp
12
star
16

sly-hello-world

A dummy template for writing SLY contribs
Emacs Lisp
9
star
17

sly-named-readtables

NAMED-READTABLES support for SLY
Emacs Lisp
9
star
18

zapp

Zebugger Adapter Protocol Plugin
Emacs Lisp
8
star
19

emacs-livereload

A livereload server running on Emacs
JavaScript
7
star
20

mac-key-mode

Provide mac-style key bindings on Carbon Emacs
Emacs Lisp
6
star
21

sinatra-thumbnails

Dynamic generation, serving and caching of thumbnail images for simple file-based CMS's written in Sinatra.
Ruby
6
star
22

efire

A campfire client for emacs
Emacs Lisp
5
star
23

nestor

A common-lisp clone of the nesta ruby cms
Common Lisp
5
star
24

cl-guard

A uniform interface to your file and event watching needs in common lisp.
Common Lisp
4
star
25

eel

Emacs interface to voidtools Everything file search
Emacs Lisp
4
star
26

ecco

ecco is a port of docco for emacs
Emacs Lisp
4
star
27

elisp-shorthand

Pretty dumb namespacing system
Emacs Lisp
3
star
28

hello-world-2000

Simplest possible C++ Hello World with CMake+Conan
CMake
3
star
29

tcpppl4

Exercise solutions for The C++ Programming Language 4th edition
C++
2
star
30

st

My fork of simple terminal
C
2
star
31

treeconf

C++ command-line parser for tree-like options
C++
2
star
32

blip

Automatically find and run tests in emacs
Emacs Lisp
2
star
33

lsplex

Experimental Language Server proxy/multiplexer
C++
2
star
34

whopper

A bare bones fork of http://common-lisp.net/project/bese/yaclml.html
Common Lisp
2
star
35

edice

Why would you want to roll dice in Emacs?
Emacs Lisp
2
star
36

vulkan-man-pages

Archlinux package for vulkan man pages
Shell
1
star
37

minns

a minimal name server, written as an exercise in C++
C++
1
star
38

revbufs

Reverts all out-of-date buffers safely
Emacs Lisp
1
star
39

raytracing-one-weekend

working through https://raytracing.github.io/books/RayTracingInOneWeekend.html
C++
1
star
40

nih

A shrubbery!!!
Emacs Lisp
1
star
41

blinky-template

A bare-bones Makefile-based template for ESP32 projects
C
1
star