Convert Figma logo to code with AI

emacs-lsp logolsp-mode

Emacs client/library for the Language Server Protocol

4,757
872
4,757
408

Top Related Projects

162,288

Visual Studio Code

82,552

Vim-fork focused on extensibility and usability

36,358

The official Vim repository

2,243

A client for Language Server Protocol servers

3,103

async language server protocol plugin for vim and neovim

Quick Overview

LSP Mode is a client for Language Server Protocol (LSP) servers in Emacs. It provides IDE-like features such as auto-completion, jump to definition, find references, and more for various programming languages, leveraging the power of language servers.

Pros

  • Supports a wide range of programming languages through different language servers
  • Integrates seamlessly with Emacs, providing a native-like experience
  • Highly customizable and extensible
  • Active development and community support

Cons

  • Can be complex to set up and configure for beginners
  • Performance may vary depending on the language server and project size
  • Requires external language servers to be installed separately
  • May conflict with other Emacs packages or configurations

Code Examples

  1. Basic configuration in Emacs init file:
(require 'lsp-mode)
(add-hook 'python-mode-hook #'lsp)
(add-hook 'ruby-mode-hook #'lsp)

This code enables LSP Mode for Python and Ruby files.

  1. Customizing LSP Mode settings:
(setq lsp-prefer-flymake nil)
(setq lsp-ui-doc-enable t)
(setq lsp-ui-doc-position 'top)

This code disables Flymake, enables LSP UI documentation, and sets the documentation position to the top.

  1. Adding custom language server configuration:
(lsp-register-client
 (make-lsp-client :new-connection (lsp-stdio-connection "custom-language-server")
                  :major-modes '(custom-mode)
                  :server-id 'custom-ls))

This code registers a custom language server for a specific major mode.

Getting Started

To get started with LSP Mode:

  1. Install LSP Mode via MELPA:

    (require 'package)
    (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
    (package-initialize)
    (package-install 'lsp-mode)
    
  2. Add basic configuration to your Emacs init file:

    (require 'lsp-mode)
    (add-hook 'prog-mode-hook #'lsp)
    
  3. Install language servers for your desired programming languages (e.g., pip install python-language-server for Python).

  4. Open a file in the supported language, and LSP Mode should automatically start and provide IDE-like features.

Competitor Comparisons

162,288

Visual Studio Code

Pros of vscode

  • More user-friendly interface, especially for beginners
  • Extensive marketplace with a wide range of extensions
  • Built-in Git integration and debugging tools

Cons of vscode

  • Heavier resource usage compared to Emacs
  • Less customizable than Emacs, which offers more flexibility
  • Slower startup time, especially with many extensions installed

Code comparison

lsp-mode (Emacs):

(use-package lsp-mode
  :commands (lsp lsp-deferred)
  :init
  (setq lsp-keymap-prefix "C-c l")
  :config
  (lsp-enable-which-key-integration t))

vscode (settings.json):

{
  "editor.suggestSelection": "first",
  "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
  "editor.formatOnSave": true,
  "files.autoSave": "afterDelay"
}

Both lsp-mode and vscode provide Language Server Protocol (LSP) support, enabling advanced IDE-like features across various programming languages. While lsp-mode offers deep integration with Emacs and its ecosystem, vscode provides a more accessible and feature-rich environment out of the box. The choice between them often depends on personal preference, workflow requirements, and familiarity with Emacs or modern GUI-based editors.

82,552

Vim-fork focused on extensibility and usability

Pros of neovim

  • Built-in LSP client, reducing the need for external plugins
  • Faster startup time and overall performance
  • More active development and larger community

Cons of neovim

  • Steeper learning curve for users transitioning from traditional Vim
  • Less extensive ecosystem of plugins compared to Emacs

Code Comparison

lsp-mode (Emacs):

(use-package lsp-mode
  :commands (lsp lsp-deferred)
  :init
  (setq lsp-keymap-prefix "C-c l")
  :config
  (lsp-enable-which-key-integration t))

neovim (Lua):

require'lspconfig'.pyright.setup{}
vim.api.nvim_set_keymap('n', '<space>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
vim.api.nvim_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
vim.api.nvim_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)

While lsp-mode requires additional configuration and package management, neovim's built-in LSP client allows for more straightforward setup. However, lsp-mode offers more extensive customization options and integration with other Emacs packages. Neovim's approach is more lightweight and performance-oriented, while lsp-mode provides a more comprehensive feature set within the Emacs ecosystem.

36,358

The official Vim repository

Pros of vim

  • Lightweight and fast, with minimal system resources required
  • Extensive plugin ecosystem with a large community of contributors
  • Highly customizable with a powerful scripting language (Vimscript)

Cons of vim

  • Steeper learning curve for beginners due to modal editing
  • Less integrated language server protocol (LSP) support out of the box
  • Configuration can be more complex and time-consuming

Code comparison

vim:

" Basic LSP setup in vim
let g:lsp_diagnostics_enabled = 1
let g:lsp_signs_enabled = 1
let g:lsp_diagnostics_echo_cursor = 1

lsp-mode:

;; Basic LSP setup in Emacs
(use-package lsp-mode
  :hook (prog-mode . lsp-deferred)
  :commands lsp)

Summary

vim is a lightweight, highly customizable text editor with a large plugin ecosystem. It offers excellent performance and flexibility but may require more setup for advanced features like LSP integration. lsp-mode, on the other hand, provides a more seamless LSP experience out of the box for Emacs users, with easier configuration and integration. The choice between the two largely depends on personal preference, existing editor familiarity, and specific project requirements.

2,243

A client for Language Server Protocol servers

Pros of eglot

  • Lightweight and minimalistic approach, with a smaller codebase
  • Built-in support in Emacs 29+, reducing external dependencies
  • Simpler configuration and setup process

Cons of eglot

  • Fewer customization options compared to lsp-mode
  • Limited support for some advanced LSP features
  • Smaller ecosystem of extensions and integrations

Code Comparison

eglot configuration:

(use-package eglot
  :hook ((python-mode . eglot-ensure)
         (rust-mode . eglot-ensure))
  :config
  (add-to-list 'eglot-server-programs '(rust-mode . ("rust-analyzer"))))

lsp-mode configuration:

(use-package lsp-mode
  :hook ((python-mode . lsp)
         (rust-mode . lsp))
  :config
  (setq lsp-rust-server 'rust-analyzer)
  (setq lsp-enable-symbol-highlighting t)
  (setq lsp-enable-on-type-formatting t))

Both eglot and lsp-mode are popular choices for integrating Language Server Protocol (LSP) support in Emacs. eglot offers a more streamlined experience with its lightweight approach and built-in support in newer Emacs versions. However, lsp-mode provides more extensive customization options and a broader range of features for power users. The choice between the two often depends on personal preferences and specific requirements for LSP integration in Emacs.

3,103

async language server protocol plugin for vim and neovim

Pros of vim-lsp

  • Lightweight and faster performance, especially for larger projects
  • Easier integration with existing Vim plugins and workflows
  • More flexible configuration options for custom language servers

Cons of vim-lsp

  • Smaller community and fewer contributors compared to lsp-mode
  • Less comprehensive documentation and fewer examples available
  • Fewer built-in features and integrations out of the box

Code Comparison

vim-lsp configuration:

let g:lsp_settings = {
    \ 'pyls': {'workspace_config': {'pyls': {'plugins': {'pycodestyle': {'enabled': v:false}}}}},
    \ }

lsp-mode configuration:

(use-package lsp-mode
  :hook ((python-mode . lsp))
  :config
  (setq lsp-pyls-plugins-pycodestyle-enabled nil))

Both examples disable pycodestyle in the Python language server, but lsp-mode uses a more declarative approach with use-package integration.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README


title: LSP Mode - Language Server Protocol support for Emacs description: Language Server Protocol support with multiples languages support for Emacs root_file: README.md

CI

Language Server Protocol Support for Emacs

LSP mode


homepage • installation • languages • settings • tutorials • troubleshooting • screenshots • FAQ


Why?

  • :heart: Community Driven
  • :gem: Fully featured - supports all features in Language Server Protocol v3.14.
  • :rocket: Fast - see performance section.
  • :star2: Flexible - choose between full-blown IDE with flashy UI or minimal distraction free.
  • :gear: Easy to configure - works out of the box and automatically upgrades if additional packages are present.

Overview

Client for Language Server Protocol (v3.14). lsp-mode aims to provide IDE-like experience by providing optional integration with the most popular Emacs packages like company, flycheck and projectile.

  • Non-blocking asynchronous calls
  • Real-time Diagnostics/linting via flycheck (recommended) or flymake when Emacs > 26 (requires flymake>=1.0.5)
  • Code completion - company-capf / completion-at-point (note that company-lsp is no longer supported).
  • Hovers - using lsp-ui
  • Code actions - via lsp-execute-code-action, modeline (recommended) or lsp-ui sideline.
  • Code outline - using builtin imenu or helm-imenu
  • Code navigation - using builtin xref, lsp-treemacs tree views or lsp-ui peek functions.
  • Code lens
  • Symbol highlights
  • Formatting
  • Project errors on modeline
  • Debugger - dap-mode
  • Breadcrumb on headerline
  • Helm integration - helm-lsp
  • Ivy integration - lsp-ivy
  • Consult integration - consult-lsp
  • Treemacs integration - lsp-treemacs
  • Semantic tokens as defined by LSP 3.16 (compatible language servers include recent development builds of clangd and rust-analyzer)
  • which-key integration for better discovery
  • iedit
  • dired
  • ido

Presentations/demos

See also

  • lsp-docker - provide docker image with preconfigured language servers with corresponding emacs configuration.
  • company-box - company frontend with icons.
  • dap-mode - Debugger integration for lsp-mode.
  • eglot - An alternative minimal LSP implementation.
  • which-key - Emacs package that displays available keybindings in popup
  • projectile - Project Interaction Library for Emacs
  • emacs-tree-sitter - Faster, fine-grained code highlighting via tree-sitter.
  • gccemacs - modified Emacs capable of compiling and running Emacs Lisp as native code.

Contributions

Contributions are very much welcome!

NOTE Documentation for clients is generated from doc comments in the clients themselves (see lsp-doc.el) and some metadata (see lsp-clients.json) so please submit corrections accordingly.

Support the project

The emacs-lsp organization has more than 20,000 lines of code, to keep all of this working, we need to implement new features and help the community on a lot of issues.

You can help us keep going and improving it by supporting the project

Members

Here it is a list of the current lsp-mode members and what they are primary working on/responsible for.

kurnevsky
kurnevsky

Scala | Rust
seagle0128
seagle0128

Go | Python MS
sebastiansturm
sebastiansturm

lsp-mode core | C++
vibhavp
vibhavp

lsp-mode core
yyoncho
yyoncho

lsp-mode core | Java
ericdallo
ericdallo

Dart/Flutter | Clojure
danielmartin
danielmartin

C++ | Swift
kiennq
kiennq

completions | pwsh
nbfalcon
nbfalcon

lsp-mode core | iedit
psibi
psibi

Terraform | Nix
razzmatazz
razzmatazz

C# | F#
jcs090218
jcs090218

lsp-mode core