Home

Awesome

Linux macOS Windows GitHub CI Sponsors

mason-lspconfig.nvim

<p align="center"> <code>mason-lspconfig</code> bridges <a href="https://github.com/williamboman/mason.nvim"><code>mason.nvim</code></a> with the <a href="https://github.com/neovim/nvim-lspconfig"><code>lspconfig</code></a> plugin - making it easier to use both plugins together. </p> <p align="center"> <code>:help mason-lspconfig.nvim</code> </p> <p align="center"> <sup>Latest version: v1.30.0</sup> <!-- x-release-please-version --> </p>

Table of Contents

Introduction

:h mason-lspconfig-introduction

mason-lspconfig.nvim closes some gaps that exist between mason.nvim and lspconfig. Its main responsibilities are to:

It is recommended to use this extension if you use mason.nvim and lspconfig (it's strongly recommended for Windows users).

Note: this plugin uses the lspconfig server names in the APIs it exposes - not mason.nvim package names. See this table for a complete mapping.

Requirements

:h mason-lspconfig-requirements

Installation

Packer

use {
    "williamboman/mason.nvim",
    "williamboman/mason-lspconfig.nvim",
    "neovim/nvim-lspconfig",
}

lazy.nvim

{
    "williamboman/mason.nvim",
    "williamboman/mason-lspconfig.nvim",
    "neovim/nvim-lspconfig",
}

vim-plug

Plug 'williamboman/mason.nvim'
Plug 'williamboman/mason-lspconfig.nvim'
Plug 'neovim/nvim-lspconfig'

Setup

:h mason-lspconfig-quickstart

It's important that you set up the plugins in the following order:

  1. mason.nvim
  2. mason-lspconfig.nvim
  3. Setup servers via lspconfig

Pay extra attention to this if you lazy-load plugins, or somehow "chain" the loading of plugins via your plugin manager.

require("mason").setup()
require("mason-lspconfig").setup()

-- After setting up mason-lspconfig you may set up servers via lspconfig
-- require("lspconfig").lua_ls.setup {}
-- require("lspconfig").rust_analyzer.setup {}
-- ...

Refer to the Configuration section for information about which settings are available.

Automatic server setup (advanced feature)

:h mason-lspconfig-automatic-server-setup

mason-lspconfig provides extra, opt-in, functionality that allows you to automatically set up LSP servers installed via mason.nvim without having to manually add each server setup to your Neovim configuration. Refer to :h mason-lspconfig-automatic-server-setup for more details.

Commands

:h mason-lspconfig-commands

Configuration

:h mason-lspconfig-settings

You may optionally configure certain behavior of mason-lspconfig.nvim when calling the .setup() function. Refer to the default configuration for a list of all available settings.

Example:

require("mason-lspconfig").setup {
    ensure_installed = { "lua_ls", "rust_analyzer" },
}

Default configuration

local DEFAULT_SETTINGS = {
    -- A list of servers to automatically install if they're not already installed. Example: { "rust_analyzer@nightly", "lua_ls" }
    -- This setting has no relation with the `automatic_installation` setting.
    ---@type string[]
    ensure_installed = {},

    -- Whether servers that are set up (via lspconfig) should be automatically installed if they're not already installed.
    -- This setting has no relation with the `ensure_installed` setting.
    -- Can either be:
    --   - false: Servers are not automatically installed.
    --   - true: All servers set up via lspconfig are automatically installed.
    --   - { exclude: string[] }: All servers set up via lspconfig, except the ones provided in the list, are automatically installed.
    --       Example: automatic_installation = { exclude = { "rust_analyzer", "solargraph" } }
    ---@type boolean
    automatic_installation = false,

    -- See `:h mason-lspconfig.setup_handlers()`
    ---@type table<string, fun(server_name: string)>?
    handlers = nil,
}

Available LSP servers

<!-- available-lsp-servers:start -->
LanguageServer name
1ะก:Enterprisebsl_ls
Adaals
Angularangularls
Ansibleansiblels
Antlersantlersls
Apexapex_ls
Arduinoarduino_language_server
Assemblyasm_lsp
Astroastro
AWKawk_ls
Azure Pipelinesazure_pipelines_ls
Bashbashls
Bashpkgbuild_language_server
Beancountbeancount
Bicepbicep
Bladestimulus_ls
BrighterScriptbright_script
C#ast_grep
C#csharp_ls
C#harper_ls
C# (docs)omnisharp
C#omnisharp_mono
C++ast_grep
C++clangd
C++harper_ls
Cairocairo_ls
Cast_grep
Cclangd
Charper_ls
Clarityclarity_lsp
Clojureclojure_lsp
ClojureScriptclojure_lsp
CMakecmake
CMakeneocmake
COBOLcobol_ls
CodeQLcodeqlls
Coqcoq_lsp
Crystalcrystalline
CSSast_grep
CSScss_variables
CSScssls
CSScssmodules_ls
CSStailwindcss
CSSunocss
Cucumbercucumber_language_server
Cuedagger
Cyphercypher_ls
Dartast_grep
Dhalldhall_lsp_server
Djangojinja_lsp
Dockerdocker_compose_language_service
Dockerdockerls
DOTdotls
Droolsdrools_lsp
Dserve_d
Earthlyearthlyls
Elixirelixirls
Elixirlexical
Elmelmls
Emberember
Emmetemmet_language_server
Emmetemmet_ls
Ergerg_language_server
Erlangelp
Erlangerlangls
F#fsautocomplete
Facility Service Definitionfacility_language_server
Fennelfennel_language_server
Fennelfennel_ls
Fluxflux_lsp
Fortranfortls
Glimmerglint
GLSLglslls
Goast_grep
Gogolangci_lint_ls
Gogopls
Goharper_ls
Gotempl
Gradlegradle_ls
GraphQLgraphql
Groovygroovyls
Handlebarsglint
Haskellhls
Haxehaxe_language_server
Helmhelm_ls
Hoonhoon_ls
HTMLast_grep
HTMLhtml
HTMLlwc_ls
HTMLstimulus_ls
HTMLtempl
HTMLtwiggy_language_server
HTMXhtmx
Hyprhyprls
Javaast_grep
Javajava_language_server
Javajdtls
JavaScriptast_grep
JavaScriptbiome
JavaScriptdenols
JavaScripteslint
JavaScriptglint
JavaScriptharper_ls
JavaScriptlwc_ls
JavaScriptquick_lint_js
JavaScriptrome
JavaScripttsserver
JavaScriptvtsls
Jinjajinja_lsp
Jqjqls
JSONbiome
JSONjsonls
Jsonnetjsonnet_ls
JSONrome
JSONspectral
JSXast_grep
Julia (docs)julials
Kotlinast_grep
Kotlinkotlin_language_server
LaTeXltex
LaTeXtexlab
LaTeXtextlsp
Lelwellelwel_ls
LESScss_variables
LESScssls
Liquidshopify_theme_ls
Liquidtheme_check
Luaast_grep
Luaharper_ls
Lualua_ls
Luauluau_lsp
Markdowngrammarly
Markdownharper_ls
Markdownltex
Markdownmarkdown_oxide
Markdownmarksman
Markdownprosemd_lsp
Markdownremark_ls
Markdownvale_ls
Markdownzk
Matlabmatlab_ls
MDXmdx_analyzer
Mesonmesonlsp
Mesonswift_mesonls
Metamath Zeromm0_ls
Motokomotoko_lsp
Movemove_analyzer
Nginxnginx_language_server
Nickelnickel_ls
Nimnim_langserver
Nimnimls
Nixnil_ls
Nixrnix
Nunjucksjinja_lsp
OCamlocamllsp
Odinols
OneScriptbsl_ls
OpenAPIvacuum
OpenCLopencl_ls
OpenFOAMfoam_ls
OpenGLglsl_analyzer
OpenSCADopenscad_lsp
Orgtextlsp
Perlperlnavigator
Pestpest_ls
PHPintelephense
PHPphpactor
PHPpsalm
PHPstimulus_ls
PICO-8pico8_ls
PowerShellpowershell_es
Prismaprismals
Protobufbufls
Protobufpbls
Puppetpuppet
PureScriptpurescriptls
Pythonast_grep
Pythonbasedpyright
Pythonharper_ls
Pythonjedi_language_server
Pythonmutt_ls
Python (docs)pylsp
Pythonpylyzer
Pythonpyre
Pythonpyright
Pythonruff
Pythonruff_lsp
Pythonsourcery
Rakuraku_navigator
Reasonreason_ls
Regoregal
Regoregols
ReScriptrescriptls
reStructuredTextltex
Robot Frameworkrobotframework_ls
Rr_language_server
Rubyharper_ls
Rubyrubocop
Rubyruby_lsp
Rubysolargraph
Rubysorbet
Rubystandardrb
Rubysteep
Rubystimulus_ls
Rustast_grep
Rustharper_ls
Rustrust_analyzer
Saltsalt_ls
SCSScss_variables
SCSScssls
SCSSsomesass_ls
Slintslint_lsp
Smithysmithy_ls
Snyksnyk_ls
Soliditysolang
Soliditysolc
Soliditysolidity
Soliditysolidity_ls
Soliditysolidity_ls_nomicfoundation
Sphinxesbonio
SQLsqlls
SQLsqls
Standard MLmillet
Starlarkbzl
Starlarkstarlark_rust
Starlarkstarpls
Stylelintstylelint_lsp
Sveltesvelte
SystemVeriloghdl_checker
SystemVerilogsvlangserver
SystemVerilogsvls
SystemVerilogverible
Tealteal_ls
Terraformterraformls
Terraformtflint
Textgrammarly
Textltex
Texttextlsp
Textvale_ls
Thriftthriftls
TOMLharper_ls
TOMLtaplo
Twigtwiggy_language_server
TypeScriptast_grep
TypeScriptbiome
TypeScriptdenols
TypeScripteslint
TypeScriptglint
TypeScriptharper_ls
TypeScriptquick_lint_js
TypeScriptrome
TypeScripttsserver
TypeScriptvtsls
Typsttinymist
Typsttypst_lsp
Valavala_ls
Veriloghdl_checker
Verylveryl_ls
VHDLhdl_checker
VHDLvhdl_ls
VimScriptvimls
Visualforcevisualforce_ls
Vuevolar
Vuevuels
Vv_analyzer
Vvls
WGSLwgsl_analyzer
XMLlemminx
YAMLgitlab_ci_ls
YAMLhydra_lsp
YAMLspectral
YAMLyamlls
Zigzls
-autotools_ls
-custom_elements_ls
-diagnosticls
-dprint
-efm
-typos_lsp
<!-- available-lsp-servers:end -->