lua/magictt/plugins/lsp/mason.lua.
Current Configuration
The LSP configuration is split into two main sections:1. Language Servers (mason.lua:1-35)
2. Formatters and Linters (mason.lua:36-51)
Adding a New Language Server
Find the LSP server name
Visit Mason’s LSP server list or run:Then search for your language (press
/ and type the language name).Common examples:- Rust:
rust_analyzer - Go:
gopls - C/C++:
clangd - Java:
jdtls - Ruby:
solargraph - PHP:
intelephense
Adding Formatters and Linters
To add formatters or linters for your language:Find the tool name
Open Mason to browse available tools:Filter by category:
- Press
2for Formatters - Press
3for Linters
Real-World Example: Adding Rust Support
Here’s a complete example of adding Rust language support:Real-World Example: Adding Go Support
LSP Configuration Structure
The LSP setup follows this structure:mason.lua (Installation)
Defines which servers and tools to install.lsp.lua (Configuration)
Defines how LSP servers behave (keybindings, autocompletion capabilities, etc.).Advanced: Per-Language Configuration
For language-specific LSP configuration, you can modifylua/magictt/plugins/lsp/lsp.lua.
Current Auto-Format Configuration (lsp.lua:18-24)
Adding Custom Language Configuration
To add custom configuration for a specific language server:LSP Server Settings
Each language server has its own settings. Find documentation for your server:Example: TypeScript Settings
Example: Lua Settings
Managing Installed Servers
Mason UI Commands
:Masonor<leader>mm- Open Mason panel:MasonInstall <package>- Install a package:MasonUninstall <package>- Uninstall a package:MasonUpdate- Update all packages:MasonLog- View installation logs
Within the Mason UI
i- Install package under cursoru- Uninstall package under cursorU- Update package under cursor/- Search packagesX- Uninstall all packages
Troubleshooting
LSP Not Attaching
-
Check if server is installed:
-
Check LSP status:
-
Restart LSP:
Installation Failures
-
Check Mason log:
- Check dependencies: Some servers require external dependencies (Node.js, Python, etc.)
-
Manual installation:
Server Not Working Correctly
-
Check health:
-
Verify file type: Ensure Neovim detects the correct file type:
- Review server settings: Check the server’s documentation for required configuration.
Best Practices
- Only install what you need: Don’t install every available LSP server
- Use mason-tool-installer: Automatically installs tools on startup
- Keep servers updated: Run
:MasonUpdateperiodically - Check compatibility: Ensure your OS supports the LSP server
- Read documentation: Each server has unique features and settings
- Configure per-project: Use project-local settings when needed
Common Language Servers
| Language | LSP Server | Formatter | Linter |
|---|---|---|---|
| TypeScript/JavaScript | ts_ls | prettier | eslint_d |
| Python | pyright | black, isort | pylint |
| Rust | rust_analyzer | rustfmt | Built-in |
| Go | gopls | gofumpt | golangci-lint |
| C/C++ | clangd | clang-format | cpplint |
| Lua | lua_ls | stylua | luacheck |
| HTML | html | prettier | - |
| CSS | cssls | prettier | stylelint |
| JSON | jsonls | prettier | - |
| YAML | yamlls | prettier | - |
| Markdown | marksman | prettier | markdownlint |