Skip to main content

LSP Setup in LazyVim

Language Server Protocol (LSP) setup is one of the most notoriously difficult parts of configuring vanilla Neovim. LazyVim solves this by automatically managing LSP servers, formatters, and linters using Mason and nvim-lspconfig.

How LazyVim handles LSP​

Out of the box, LazyVim provides a robust LSP foundation:

  • Mason (williamboman/mason.nvim) installs servers.
  • Mason-Lspconfig bridges Mason with Neovim's built-in LSP client.
  • Keymaps, capabilities, and autocommands (like format-on-save) are wired up automatically.

The easiest way to get full language support is via LazyVim Extras. Extras are curated configurations for specific languages that include the best LSP, formatter, linter, and Treesitter parsers.

  1. Open Neovim and run :LazyExtras.
  2. Navigate to the lang section.
  3. Press x to enable a language (e.g., lang.typescript, lang.python).
  4. Restart Neovim. LazyVim will automatically download and configure everything needed for that language!

Method 2: Adding servers manually​

If an Extra doesn't exist for your language, or you want fine-grained control, you can add servers by extending the nvim-lspconfig options in lua/plugins/lsp.lua:

return {
"neovim/nvim-lspconfig",
opts = {
servers = {
-- Enable a server with default settings
pyright = {},
-- Enable a server with custom settings
tsserver = {
settings = {
typescript = {
inlayHints = {
includeInlayParameterNameHints = "all",
},
},
},
},
},
},
}

Formatting with conform.nvim​

LazyVim uses conform.nvim for formatting. To add a formatter:

return {
"stevearc/conform.nvim",
opts = {
formatters_by_ft = {
lua = { "stylua" },
javascript = { "prettier" },
},
},
}

Linting with nvim-lint​

For linters, LazyVim uses nvim-lint:

return {
"mfussenegger/nvim-lint",
opts = {
linters_by_ft = {
javascript = { "eslint_d" },
},
},
}

Comparison: Vanilla vs LazyVim​

FeatureVanilla NeovimLazyVim
InstallationManual via Mason or system package managerAutomatic via Mason / LazyExtras
Server ConfigWrite setup boilerplate for each serverJust add server name to opts.servers
Format on saveWrite custom autocommandsWorks out of the box with conform.nvim
KeymapsMap manually in LspAttach autocommandPre-configured (K, gd, gr, etc.)