Native LSP Setup
On this page
Native LSP Setup
Neovim 0.11 made language servers a first-class config concern. A server is
described by a file in lsp/ at the top of your config — no plugin code in
the way.
A server definition
~/.config/nvim/lsp/lua_ls.lua:
return {
cmd = { "lua-language-server" },
filetypes = { "lua" },
settings = { Lua = { diagnostics = { globals = { "vim" } } } },
}The file returns a table: the command Neovim launches, the filetypes that trigger it, and settings handed straight to the server.
Enable it
lua/config/lsp.lua:
vim.lsp.enable("lua_ls")
vim.diagnostic.config({ virtual_lines = { current_line = true } })vim.lsp.enable activates the definition — from your lsp/ directory,
deep-merged over nvim-lspconfig’s defaults if that data package is
installed. The virtual_lines diagnostic style renders the full message
under the current line only: quiet screen, full detail exactly where your
eyes are.
Watch it work
Open a Lua file and type a broken line — an unclosed string, an unused
variable. Diagnostics appear in the gutter and under the cursor line within
a couple of seconds of the server attaching. Rename with grn, jump with
gd, hover with K.
The complete wiring — capabilities for completion, LspAttach keymaps,
per-server settings for a dozen languages — is in the
course repo under
nvim/lua/config/lsp.lua and nvim/lsp/.