Understanding the LSP Setup
The LSP configuration is managed in several files:lua/user/lsp/mason.lua- Server installation and setuplua/user/lsp/handlers.lua- Common LSP handlers and keybindingslua/user/lsp/settings/- Server-specific configurations
Current LSP Servers
The base configuration includes:Adding a New LSP Server
Step 1: Add Server to Configuration
Editlua/user/lsp/mason.lua and add your server to the servers table:
Step 2: Restart Neovim
Mason will automatically install the new server:Step 3: Verify Installation
Check Mason status:Available LSP Servers
Here are commonly used language servers:Web Development
Systems Programming
Scripting Languages
Configuration Files
Other Languages
2 to view available LSP servers.
Server-Specific Configuration
Creating a Server Configuration
Some servers need custom settings. Create a configuration file inlua/user/lsp/settings/.
Example: Lua Language Server (lua_ls.lua)
pyright.lua)
Create lua/user/lsp/settings/pyright.lua:
tsserver.lua)
Create lua/user/lsp/settings/tsserver.lua:
How Server Configuration Works
The mason.lua file automatically loads server-specific settings:LSP Keybindings
These keybindings are automatically available when LSP is attached:Leader-Based (via Which-Key)
<leader>la- Code action<leader>ld- Document diagnostics<leader>lf- Format code<leader>li- LSP info<leader>lj- Next diagnostic<leader>lk- Previous diagnostic<leader>lr- Rename symbol<leader>ls- Document symbols<leader>lw- Workspace diagnostics
Direct Keybindings
These are defined inlua/user/lsp/handlers.lua:
gD- Go to declarationgd- Go to definitionK- Hover documentationgi- Go to implementationgr- Show referencesgl- Show line diagnostics
Practical Examples
Example 1: Adding Rust Support
Step 1: Add rust-analyzer to mason.lua:lua/user/lsp/settings/rust_analyzer.lua:
Example 2: Adding Go Support
Step 1: Add gopls to mason.lua:lua/user/lsp/settings/gopls.lua:
Example 3: Full Web Development Stack
Mason Configuration
Customize Mason’s behavior inlua/user/lsp/mason.lua:
Troubleshooting
Server Not Installing
- Check server name is correct
-
Manually install via Mason:
Then press
ion the server -
Check Mason logs:
LSP Not Attaching
-
Verify server is installed:
-
Check LSP status:
-
Check filetype is detected:
-
Ensure filetype matches server:
tsserverneeds filetypetypescriptorjavascriptpyrightneeds filetypepythonlua_lsneeds filetypelua
Server Errors
- Check server configuration file syntax
-
View LSP logs:
-
Restart LSP server:
Configuration Not Loading
- Verify file name matches server name exactly
- Check file is in
lua/user/lsp/settings/ - Ensure file returns a table
- Restart Neovim after creating config
Advanced Configuration
Custom On-Attach Function
Modifylua/user/lsp/handlers.lua to customize behavior for all servers:
Server-Specific On-Attach
In your server settings file:Next Steps
- Add More Plugins
- Customize Keymaps
- Change Colorschemes
- Learn about Null-ls for formatters and linters

