Introduction
mason.nvim is a Neovim plugin that provides a portable package manager for external editor tooling. It handles downloading, installing, and updating LSP servers, DAP debug adapters, linters, and formatters into a self-contained directory, keeping your system clean and your Neovim environment reproducible.
What mason.nvim Does
- Installs LSP servers, DAP adapters, linters, and formatters from a curated registry
- Provides a floating window UI for browsing, installing, and updating packages
- Manages a dedicated installation directory separate from system paths
- Automatically configures PATH so Neovim can find installed tools
- Supports companion plugins for automatic integration with nvim-lspconfig and null-ls
Architecture Overview
mason.nvim maintains a registry of package definitions that describe how to download and install each tool. Packages are installed into a data directory (typically ~/.local/share/nvim/mason) using platform-appropriate methods: npm, pip, cargo, go install, or direct binary downloads. The plugin prepends its bin directory to Neovim's PATH, making installed tools available to LSP clients, formatters, and linters without global installation.
Self-Hosting & Configuration
- Requires Neovim 0.7+ and Git; some packages need Node.js, Python, or other runtimes
- Install via lazy.nvim, packer.nvim, or any Neovim plugin manager
- Pair with mason-lspconfig.nvim for automatic LSP server setup with nvim-lspconfig
- Configure default package lists with ensure_installed in the setup function
- Custom registries can override or extend the default package definitions
Key Features
- Unified interface for tools that would otherwise require separate install steps
- Cross-platform support for macOS, Linux, and Windows without manual binary management
- Version pinning ensures reproducible setups across machines
- Health check command (:checkhealth mason) diagnoses missing dependencies
- Extensible registry format lets users add private or internal tool packages
Comparison with Similar Tools
- nvim-lsp-installer — predecessor to mason.nvim (now deprecated); LSP-only scope
- null-ls / none-ls — injects non-LSP sources into the LSP client; mason installs the tools these use
- Homebrew — system-wide package manager; mason keeps tools scoped to Neovim
- mise / asdf — version managers for runtimes; mason focuses specifically on editor tooling
- COC.nvim — VS Code extension host for Neovim; manages extensions differently than standalone tools
FAQ
Q: Does mason.nvim replace nvim-lspconfig? A: No. mason.nvim installs LSP servers; nvim-lspconfig configures them. Use mason-lspconfig.nvim to bridge the two.
Q: Where are packages installed? A: By default in ~/.local/share/nvim/mason. Override this with the install_root_dir option in the setup call.
Q: Can I use mason.nvim without lazy.nvim? A: Yes. mason.nvim works with any Neovim plugin manager including packer.nvim, vim-plug, and manual installation.
Q: How do I update all installed packages? A: Open the Mason UI with :Mason and press U to update all, or run :MasonUpdate from the command line.