Prerequisites
Before starting, ensure you have:- Neovim 0.10 or later (
nvim --version) - A language server installed for your language
- Basic familiarity with Lua configuration
Install a Language Server
First, install at least one language server. Here are popular options:Configure and Enable LSP
Verify It Works
Check LSP status
Run the healthcheck to verify LSP is working:You should see your server listed under “Enabled Configurations” and “Active Clients”.
Complete Example
Here’s a minimalinit.lua with multiple language servers:
Troubleshooting
LSP Not Starting
Server not found in PATH
Server not found in PATH
Ensure the language server is installed and available in your PATH:If not found, install it or specify the full path in
cmd:No root marker found
No root marker found
LSP servers need a “workspace root” to function. Ensure your project has one of the Or create a marker file:
root_markers:Config not recognized
Config not recognized
Check that the config is properly defined:You should see your config name in the output.
Check Logs
View the LSP log for detailed error messages:Client Not Attaching
Check active clients
Check active clients
In the problematic buffer, run:If empty, the client isn’t attaching. Check:
- The filetype matches your config:
:set filetype? - A root marker exists in your project
- The server is enabled:
:lua =vim.lsp.config['your_server']
Wrong filetype
Wrong filetype
Force set the correct filetype:Or add to your config:
Using nvim-lspconfig Plugin
If you prefer not to configure servers manually, use the nvim-lspconfig plugin:nvim-lspconfig provides pre-configured setups for 200+ language servers with sensible defaults.
Next Steps
Now that LSP is working, explore more features:Configuration
Advanced configuration options
Completion
Set up auto-completion
Diagnostics
Customize error display
Code Actions
Use quick fixes and refactorings