Neovim needs a built-in way to connect to LSP servers without requiring external plugins. The built-in LSP client should handle the complexity of starting servers, managing clients, and exposing a Lua API for interacting with language servers.
vim.lsp is Neovim’s built-in Lua framework for creating LSP clients and building LSP-powered tools. It provides functions to start/configure language servers, handle LSP methods, and implement editor features using semantic analysis.
- Configuration: Use
vim.lsp.config()to define server configurations (cmd, filetypes, root_markers) - Activation: Use
vim.lsp.enable()to auto-start LSP for matching buffers - Client Management:
vim.lsp.start()creates a client;vim.lsp.get_clients()retrieves active clients - Buffer Operations:
vim.lsp.buf.*functions operate on the current buffer (definition, references, hover) - Handler System: Custom handlers can intercept/override LSP responses at multiple levels
- Built-in (no plugin required for basic LSP)
- Lua-native API (
vim.lsp.buf,vim.lsp.client) - Config merging from multiple sources (global, runtimepath, after/)
- Built-in keymaps and buffer-local options for common features
- Event-driven: LspAttach, LspDetach, LspProgress, etc.
- Built from: LSP — the protocol it implements
- Builds into: LSP Configuration, LSP Client, LSP Events, Semantic Tokens
- Related: Root Markers — workspace detection
- Contrasts with: Treesitter — syntax parsing vs semantic analysis
- Config files in runtimepath are eagerly evaluated
- Global keymaps are created unconditionally on startup
- Default buffer-local settings (omnifunc, tagfunc, formatexpr) can conflict with other plugins
- Large workspaces: file watching can cause performance issues on Linux