vimtricks.wiki Concise Vim tricks, one at a time.

How do I configure an LSP client in Neovim 0.11 without using nvim-lspconfig?

Answer

vim.lsp.config()

Explanation

Neovim 0.11 introduced vim.lsp.config() and vim.lsp.enable() as a built-in API for declaring LSP client configurations without relying on the nvim-lspconfig plugin. This lets you register named LSP clients and activate them for specific filetypes using pure Lua.

How it works

  • vim.lsp.config('name', { ... }) registers a named LSP configuration with fields like cmd, filetypes, root_markers, and settings
  • vim.lsp.enable('name') activates the registered config for matching filetypes
  • Neovim also auto-discovers config files placed in ~/.config/nvim/lsp/<name>.lua

Example

-- In init.lua or a plugin file:
vim.lsp.config('lua_ls', {
  cmd = { 'lua-language-server' },
  filetypes = { 'lua' },
  root_markers = { '.luarc.json', '.git' },
  settings = {
    Lua = { diagnostics = { globals = { 'vim' } } },
  },
})
vim.lsp.enable('lua_ls')

Alternatively, create ~/.config/nvim/lsp/lua_ls.lua with just the config table, and Neovim picks it up automatically.

Tips

  • Pass false as the second argument to vim.lsp.enable() to disable a configured server: vim.lsp.enable('lua_ls', false)
  • Multiple servers can share the same filetype — Neovim manages lifecycle independently
  • This is a lightweight alternative to nvim-lspconfig for users who want fewer plugin dependencies
  • Still compatible with nvim-lspconfig if you prefer a gradual migration

Next

What is the difference between the inner word (iw) and inner WORD (iW) text objects in Vim?