Skip to content

Prelude LSP

Overview

Prelude supports two LSP clients, controlled by the prelude-lsp-client variable:

  • Eglot (default) - built into Emacs 29+, lightweight, zero extra dependencies
  • lsp-mode - feature-rich third-party client with lsp-ui (peek views, sideline diagnostics, doc overlays)

Language modules that support LSP (Go, Rust, Scala, Dart, etc.) automatically use whichever client you've configured.

Choosing an LSP Client

The default is Eglot. To switch to lsp-mode, add to your personal/preload/ config:

(setq prelude-lsp-client 'lsp-mode)

Eglot

Eglot is built into Emacs 29+ and works out of the box with most language servers. It uses standard Emacs facilities (xref, eldoc, flymake, completion-at-point) rather than introducing its own UI.

Prelude configures eglot to shut down language servers automatically when the last project buffer is closed and extends xref navigation across the whole project.

Key Bindings

Standard Emacs bindings that work with eglot:

  • M-. - find definition (xref)
  • M-? - find references (xref)
  • C-h . - documentation at point (eldoc)

Prelude additions under the C-c C-l prefix:

Key Command Description
C-c C-l r eglot-rename Rename symbol
C-c C-l e eglot-code-actions Code actions
C-c C-l f eglot-format-buffer Format buffer
C-c C-l o eglot-code-action-organize-imports Organize imports

lsp-mode

When prelude-lsp-client is set to lsp-mode, the prelude-lsp-mode module is loaded automatically. It installs lsp-mode and lsp-ui.

lsp-mode Key Bindings

All lsp-mode key bindings use the C-c C-l prefix:

Key Command Description
C-c C-l . lsp-ui-peek-find-definitions Peek at definition
C-c C-l ? lsp-ui-peek-find-references Peek at references
C-c C-l r lsp-rename Rename symbol
C-c C-l x lsp-workspace-restart Restart workspace
C-c C-l w lsp-ui-peek-find-workspace-symbol Find symbol
C-c C-l i lsp-ui-peek-find-implementation Find implementation
C-c C-l d lsp-describe-thing-at-point Describe at point
C-c C-l e lsp-execute-code-action Code action
C-c C-l f lsp-format-buffer Format buffer
C-c C-l o lsp-organize-imports Organize imports
C-c C-l m lsp-ui-imenu LSP imenu

Installing Language Servers

Regardless of which client you use, you need the appropriate language server installed on your system. Common examples:

  • Go: gopls (go install golang.org/x/tools/gopls@latest)
  • Rust: rust-analyzer
  • Scala: metals
  • Python: pyright or pylsp
  • Dart: Dart SDK includes its analysis server