*mason-lspconfig.nvim* Minimum version of Neovim: 0.11.0 Author: William Boman Type |gO| to see the table of contents. ============================================================================== INTRODUCTION *mason-lspconfig-introduction* `mason-lspconfig.nvim` closes some gaps that exist between `mason.nvim` and `nvim-lspconfig`. Its main responsibilities are to: - allow you to (i) automatically install, and (ii) automatically enable (`vim.lsp.enable()`) installed servers - provide extra convenience APIs such as the `:LspInstall` command - provide additional LSP configurations for a few servers - translate between `nvim-lspconfig` server names and `mason.nvim` package names (e.g. `lua_ls <-> lua-language-server`) ============================================================================== REQUIREMENTS *mason-lspconfig-requirements* `mason-lspconfig` requires `mason.nvim` and `nvim-lspconfig` to be installed. Note that `nvim-lspconfig` needs to be available in |rtp| before you set up `mason-lspconfig`. - `neovim >= 0.11.0` - `mason.nvim >= 2.0.0` - `nvim-lspconfig >= 2.0.0` ============================================================================== QUICK START *mason-lspconfig-quickstart* ----------------- Setting up mason-lspconfig.nvim It's important that you set up `mason.nvim` and have `nvim-lspconfig` available in |'runtimepath'| before setting up `mason-lspconfig.nvim`. To enable the `mason-lspconfig` plugin, call the `setup()` function, like so: >lua require("mason").setup() require("mason-lspconfig").setup() < Refer to |mason-lspconfig-settings| for available settings. ----------------- Setting up servers `mason-lspconfig.nvim` will automatically enable (|vim.lsp.enable()|) installed servers for you by default, see |mason-automatic-enable|. Refer to |lsp-quickstart| for information on how to configure servers. ----------------- Installation of servers To install an LSP server supported by `nvim-lspconfig` (and `mason.nvim`) you may use the `:LspInstall` command, like so: >vim :LspInstall rust_analyzer lua_ls < This command is more or less an alias of the |:MasonInstall| command, except that it only accepts LSP servers and - more importantly - only accepts `nvim-lspconfig` server names (as opposed to `mason.nvim` package names). You may also run the same command without any arguments. This will prompt you with a selection of servers that are recommended for the filetype of the buffer you're currently editing: >vim :LspInstall < ============================================================================== COMMANDS *mason-lspconfig-commands* ------------------------------------------------------------------------------ INSTALLING AN LSP SERVER *:LspInstall* >vim :LspInstall [ ...] < Installs the provided servers. This command only accepts servers that have a corresponding server configuration in `nvim-lspconfig`. You may also provide a |'filetype'| like `:LspInstall typescript`. This will prompt you with a selection of all available servers for that given language. When the command is ran without any arguments, the currently active buffer's 'filetype' will be used to identify relevant servers, and you will be prompted with a selection of servers for the current |'filetype'|. ------------------------------------------------------------------------------ UNINSTALLING AN LSP SERVER *:LspUninstall* >vim :LspUninstall ... < Uninstalls the provided servers. ============================================================================== SETTINGS *mason-lspconfig-settings* You can configure certain behavior of `mason-lspconfig` when calling the `.setup()` function. Refer to |mason-lspconfig-default-settings| for all available settings. Example: >lua require("mason-lspconfig").setup({ ensure_installed = { "rust_analyzer", "ts_ls" } }) < *mason-lspconfig-default-settings* >lua local DEFAULT_SETTINGS = { -- A list of servers to automatically install if they're not already installed. Example: { "rust_analyzer@nightly", "lua_ls" } ---@type string[] ensure_installed = {}, -- Whether installed servers should automatically be enabled via `:h vim.lsp.enable()`. -- -- To exclude certain servers from being automatically enabled: -- ```lua -- automatic_enable = { -- exclude = { "rust_analyzer", "ts_ls" } -- } -- ``` -- -- To only enable certain servers to be automatically enabled: -- ```lua -- automatic_enable = { -- "lua_ls", -- "vimls" -- } -- ``` ---@type boolean | string[] | { exclude: string[] } automatic_enable = true, } < ============================================================================== AUTOMATICALLY ENABLE SERVERS *mason-automatic-enable* By default, `mason-lspconfig` will automatically enable servers you have installed in Mason. This means you don't have to call |vim.lsp.enable()| yourself. To disable this feature: >lua require("mason-lspconfig").setup({ automatic_enable = false }) < Note: ~ Servers that you have installed outside of Mason will not be recognized by this feature. You will still have to manually enable (|vim.lsp.enable()|) such servers yourself. ============================================================================== Lua module: mason-lspconfig *mason-lspconfig.setup()* setup({config}) Sets up mason with the provided {config} (see |mason-lspconfig-settings|). *mason-lspconfig.get_installed_servers()* get_installed_servers() Returns the installed LSP servers supported by lspconfig. Note: ~ The returned strings are the nvim-lspconfig server names, not the Mason package names. For example, "lua_ls" is returned instead of "lua-language-server". Returns: ~ string[] See also: ~ |mason-registry.get_installed_packages()| |mason-registry.get_installed_package_names()| *mason-lspconfig.get_available_servers()* get_available_servers({filter}) Returns the available (both installed & uninstalled) LSP servers. Note: ~ The returned strings are the nvim-lspconfig server names, not the Mason package names. For example, "lua_ls" is returned instead of "lua-language-server". Parameters: ~ {filter} (table|nil) A table with key-value pairs used to filter the list of server names. The available keys are: - filetype (string | string[]): Only return servers with matching filetype Returns: ~ string[] See also: ~ |mason-registry.get_all_packages()| |mason-registry.get_all_package_names()| *mason-lspconfig.get_mappings()* get_mappings() Returns: - server name mappings between nvim-lspconfig and Mason. - filetype mappings for supported servers Returns: ~ { lspconfig_to_package: table, package_to_lspconfig: table, filetypes: table } Note: ~ This function only returns nvim-lspconfig servers that are recognized by Mason. vim:tw=78:ft=help:norl:expandtab:sw=4