Configs2026年7月28日·1 分钟阅读

nvim-lspconfig — Quickstart Configurations for Neovim LSP

Provides default configurations for dozens of language servers so you can set up Neovim's built-in LSP client with minimal boilerplate — just install the server and call setup().

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
nvim-lspconfig
直接安装命令
npx -y tokrepo@latest install ec4ed26c-8a1b-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

nvim-lspconfig is the official companion plugin for Neovim's built-in Language Server Protocol client. It ships pre-built configurations for 100+ language servers, handling launch commands, root directory detection, and default settings so developers can enable LSP features with a single setup() call per server.

What nvim-lspconfig Does

  • Provides default launch configurations for 100+ language servers
  • Detects project root directories using language-specific markers (package.json, Cargo.toml, etc.)
  • Validates server availability and reports diagnostic issues via :LspInfo
  • Maps common capabilities like go-to-definition and hover out of the box
  • Exposes hooks (on_attach, capabilities) for custom keybindings and behavior

Architecture Overview

nvim-lspconfig is a thin configuration layer — it does not implement the LSP client itself (that lives in Neovim core). Each server has a Lua file defining the default command, filetypes, root_dir detection function, and settings. When you call require('lspconfig').server.setup(opts), it merges your overrides with the defaults and registers an autocommand that starts the language server when a matching buffer is opened.

Self-Hosting & Configuration

  • Install via your preferred plugin manager alongside Neovim 0.8+
  • Install language servers separately (npm, pip, cargo, system package manager)
  • Call require('lspconfig')..setup({}) for each server you want
  • Override on_attach to define keymaps when a server attaches to a buffer
  • Pass capabilities from nvim-cmp or blink.cmp for enhanced completion

Key Features

  • Covers 100+ servers: pyright, ts_ls, lua_ls, rust_analyzer, gopls, clangd, and more
  • Automatic root directory detection per project type
  • Built-in :LspInfo command for debugging server connections
  • Composable with completion plugins (nvim-cmp, blink.cmp) via capabilities
  • Community-maintained configs that track upstream server changes

Comparison with Similar Tools

  • mason-lspconfig.nvim — Bridges mason.nvim and lspconfig so installed servers auto-configure; complements rather than replaces lspconfig
  • CoC.nvim — Brings its own LSP client and extensions ecosystem; lspconfig uses Neovim's native client
  • ALE — Linting and fixing tool that can use LSP but primarily runs external programs; lspconfig focuses on the LSP protocol
  • none-ls.nvim — Injects diagnostics and code actions from non-LSP sources into the LSP framework; works alongside lspconfig

FAQ

Q: Do I need both mason.nvim and nvim-lspconfig? A: mason.nvim installs servers; nvim-lspconfig configures them. You can install servers manually and skip mason, but using both together simplifies the workflow.

Q: How do I add custom keymaps for LSP actions? A: Pass an on_attach function in your setup() call. This function receives the client and buffer number, and you can define buffer-local keymaps there.

Q: Why does :LspInfo show no active clients? A: The server may not be installed, or the root directory markers were not found. Check that the server binary is on your PATH and that the file is inside a recognized project.

Q: Can I use multiple servers for the same filetype? A: Yes. Call setup() for each server. Neovim can attach multiple LSP clients to the same buffer.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产