Skip to main content

LSP Configuration

GentlemanNvim leverages LazyVim’s LSP configuration with additional language support and custom settings for frontend development.

Overview

The LSP setup is managed through LazyVim extras, providing:

Auto-installation

LSP servers install automatically on first use

Multiple Languages

TypeScript, Go, Nix, JSON, TOML, and more

Format on Save

Prettier and Biome integration

Inline Diagnostics

Real-time error checking

Enabled Language Servers

Configured through LazyVim extras in config/lazy.lua:

TypeScript & JavaScript

{ import = "lazyvim.plugins.extras.lang.typescript" }
{ import = "lazyvim.plugins.extras.lang.angular" }
Provides:
  • tsserver - TypeScript language server
  • Angular Language Service - Angular-specific IntelliSense
  • Type checking and auto-imports
  • Refactoring support
  • Go to definition/references
  • Rename symbol across project
  • Organize imports
  • Quick fixes and code actions
  • Inlay hints for types
  • Auto-completion with type information

JSON

{ import = "lazyvim.plugins.extras.lang.json" }
Provides:
  • jsonls - JSON language server
  • Schema validation
  • Auto-completion for package.json, tsconfig.json, etc.

Markdown

{ import = "lazyvim.plugins.extras.lang.markdown" }
Provides:
  • marksman - Markdown language server
  • Link validation
  • Table of contents generation
  • Reference completion
Enhanced with:
{ "MeanderingProgrammer/render-markdown.nvim" }

Go

{ import = "lazyvim.plugins.extras.lang.go" }
Provides:
  • gopls - Official Go language server
  • Code formatting with gofmt
  • Import organization
  • Test integration

Other Languages

ExtraLanguage ServerPurpose
lang.astroastro-lsAstro framework support
lang.nixnilNix language support
lang.tomltaploTOML configuration files

Formatters

Prettier

{ import = "lazyvim.plugins.extras.formatting.prettier" }
Formats:
  • JavaScript/TypeScript
  • JSON
  • Markdown
  • HTML/CSS
  • YAML
Configuration: Prettier looks for .prettierrc in your project root. Default settings apply if not found.
Create a .prettierrc.json in your project to customize formatting:
{
  "semi": true,
  "singleQuote": true,
  "tabWidth": 2,
  "printWidth": 100
}

Biome

{ import = "lazyvim.plugins.extras.formatting.biome" }
Fast alternative to Prettier for JavaScript/TypeScript:
  • 10-20x faster than Prettier
  • Integrated linter
  • Compatible with Prettier configs
When Biome is used: Biome takes precedence when biome.json exists in project root.
Biome and Prettier coexist - Biome is used when configured, otherwise Prettier is the fallback.

Linters

ESLint

{ import = "lazyvim.plugins.extras.linting.eslint" }
JavaScript/TypeScript linting with:
  • Real-time error highlighting
  • Code action fixes
  • Auto-fix on save (when configured)
Configuration: ESLint requires configuration in your project:
  • .eslintrc.js
  • .eslintrc.json
  • eslint.config.js (flat config)
ESLint will not run without a configuration file. Create one in your project root or run npm init @eslint/config.

LSP Keybindings

Inherited from LazyVim:
KeymapActionDescription
gdGo to definitionJump to where symbol is defined
grGo to referencesShow all references
gIGo to implementationJump to implementation
gyGo to type definitionJump to type definition
KHover documentationShow documentation popup

Code Actions

KeymapActionDescription
<leader>caCode actionsShow available code actions
<leader>rnRenameRename symbol project-wide
<leader>cfFormatFormat current buffer
<leader>cFFormat injectedFormat injected code (e.g., in markdown)

Diagnostics

KeymapActionDescription
]dNext diagnosticJump to next error/warning
[dPrevious diagnosticJump to previous error/warning
<leader>cdLine diagnosticsShow diagnostics for current line
<leader>xxTroubleOpen trouble list (all diagnostics)

Custom LSP Configuration

Node.js Integration

Custom Node.js host configuration:
vim.g.node_host_prog = vim.fn.exepath("node") or "/usr/local/bin/node"

if vim.fn.executable("node") == 1 then
  local node_version = vim.fn.system("node --version"):gsub("\n", "")
  print("Using Node.js version: " .. node_version)
end
The configuration automatically detects and uses the Node.js in your PATH. Required for:
  • TypeScript language server
  • ESLint
  • Prettier
  • Angular Language Service

LSP on Attach

LazyVim automatically sets up LSP keybindings when a language server attaches. No additional configuration needed.

Completion Engine

Modern completion engine replacing nvim-cmp:
{ import = "lazyvim.plugins.extras.coding.blink" }
Features:
  • Faster than nvim-cmp
  • LSP completion
  • Snippet support
  • Fuzzy matching
  • AI assistant completion (Avante integration)
Custom Sources:
opts = {
  sources = {
    default = { "avante_commands", "avante_mentions", "avante_files" },
    providers = {
      avante_commands = { score_offset = 90 },
      avante_files = { score_offset = 100 },
      avante_mentions = { score_offset = 1000 },
    },
  },
}
  1. avante_mentions (score: 1000) - @mentions in AI chat
  2. avante_files (score: 100) - File paths
  3. avante_commands (score: 90) - AI commands
  4. LSP (score: 60) - Language server completions
  5. Buffer - Words from current buffer
  6. Path - File system paths

Copilot Integration

GitHub Copilot completions are integrated but disabled in specific file types:
require("copilot.api").filetypes = {
  yaml = false,
  markdown = false,
  help = false,
  gitcommit = false,
  gitrebase = false,
}
Copilot is intentionally disabled in documentation and configuration files to prevent unwanted AI suggestions.

Format on Save

LazyVim automatically formats on save using configured formatters:
  1. Biome (if biome.json exists)
  2. Prettier (fallback for JS/TS/JSON/MD)
  3. LSP formatter (language-specific)

Disable Format on Save

Per-buffer:
:lua vim.b.autoformat = false
Globally in config:
vim.g.autoformat = false

Diagnostic Configuration

LazyVim provides sensible diagnostic defaults:
vim.diagnostic.config({
  virtual_text = true,        -- Show errors inline
  signs = true,               -- Show signs in gutter
  update_in_insert = false,   -- Don't update while typing
  underline = true,           -- Underline errors
  severity_sort = true,       -- Sort by severity
})

LSP Server Management

Mason

LazyVim uses Mason to manage LSP servers:
CommandAction
:MasonOpen Mason UI
:MasonInstall <server>Install LSP server
:MasonUninstall <server>Uninstall LSP server
:MasonUpdateUpdate all installed servers
LazyVim auto-installs LSP servers when you open a file. You rarely need to use Mason manually.

Commonly Installed Servers

These install automatically based on file types:
  • typescript-language-server - TypeScript/JavaScript
  • angular-language-server - Angular
  • json-lsp - JSON
  • marksman - Markdown
  • gopls - Go
  • nil - Nix
  • taplo - TOML
  • lua-language-server - Lua

Troubleshooting

LSP Not Starting

1

Check LSP Status

Run :LspInfo to see active servers and their status
2

Check Mason

Run :Mason to verify the language server is installed
3

Check Logs

Run :LspLog to view language server logs
4

Restart LSP

Run :LspRestart to restart the language server

Formatting Not Working

1

Verify Formatter Installation

Check if Prettier/Biome is in your project:
npm list prettier biome
2

Check Autoformat Setting

Run in Neovim:
:lua print(vim.b.autoformat, vim.g.autoformat)
Both should be true or nil
3

Manual Format

Try formatting manually with <leader>cf to see errors

ESLint Not Running

ESLint requires a configuration file (.eslintrc.js, .eslintrc.json, or eslint.config.js) in your project root.
Create configuration:
npm init @eslint/config

Advanced Configuration

Custom LSP Settings

Override LSP server settings by creating lua/plugins/lsp.lua:
return {
  {
    "neovim/nvim-lspconfig",
    opts = {
      servers = {
        tsserver = {
          settings = {
            typescript = {
              inlayHints = {
                includeInlayParameterNameHints = "all",
                includeInlayFunctionParameterTypeHints = true,
              },
            },
          },
        },
      },
    },
  },
}

Add Custom Language Server

Example for adding a new LSP:
return {
  {
    "neovim/nvim-lspconfig",
    opts = {
      servers = {
        -- Add your custom server
        rust_analyzer = {
          settings = {
            ["rust-analyzer"] = {
              cargo = {
                allFeatures = true,
              },
            },
          },
        },
      },
    },
  },
}

Performance Tips

For large TypeScript projects:
  • Create tsconfig.json with strict file includes
  • Use project references for monorepos
  • Consider disabling semantic tokens:
    tsserver = {
      settings = {
        typescript = {
          semanticTokens = { enabled = false },
        },
      },
    }
    

Next Steps

AI Assistants

Enhance LSP with AI-powered code intelligence

Keymaps

Learn all LSP-related keybindings

Build docs developers (and LLMs) love