Skip to content

Commit

Permalink
fix: migrate to using mason-tool-installer.nvim for all Mason packa…
Browse files Browse the repository at this point in the history
…ge management
  • Loading branch information
mehalter committed Sep 18, 2024
1 parent 16b6b4d commit 1a6eb27
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/content/docs/configuration/customizing_plugins.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ The `table` notation is the simplest method for configuration but does not cover

:::tip

Since [`lazy.nvim` v10.23.0](https://github.com/folke/lazy.nvim/releases/tag/v10.23.0) a new configuration option has been added called `opts_extend` which allows specifying that a part of the options passed to the `opts` table should be treated as a list that is extended rather than replaced completely as described below. Since [AstroNvim v4.9.0](https://github.com/AstroNvim/AstroNvim/releases/tag/v4.9.0) this option has been enabled out of the box for the `ensure_installed` tables for the following plugins: [`nvim-treesitter`](https://github.com/nvim-treesitter/nvim-treesitter), [`mason-lspconfig.nvim`](https://github.com/williamboman/mason-lspconfig.nvim), [`mason-null-ls.nvim`](https://github.com/jay-babu/mason-null-ls.nvim), and [`mason-nvim-dap.nvim`](https://github.com/jay-babu/mason-nvim-dap.nvim). This allows the user to use the basic table notation to simply add more items to these `ensure_installed` lists.
Since [`lazy.nvim` v10.23.0](https://github.com/folke/lazy.nvim/releases/tag/v10.23.0) a new configuration option has been added called `opts_extend` which allows specifying that a part of the options passed to the `opts` table should be treated as a list that is extended rather than replaced completely as described below. Since [AstroNvim v4.9.0](https://github.com/AstroNvim/AstroNvim/releases/tag/v4.9.0) this option has been enabled out of the box for the `ensure_installed` tables for [`nvim-treesitter`](https://github.com/nvim-treesitter/nvim-treesitter) and [`mason-tool-installer.nvim`](https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim). This allows the user to use the basic table notation to simply add more items to these `ensure_installed` lists.

:::

Expand Down
20 changes: 10 additions & 10 deletions src/content/docs/recipes/advanced_lsp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ return {

### LSP Setup Without Installer

AstroNvim comes with [mason-lspconfig](https://github.com/williamboman/mason-lspconfig.nvim) as an easy interface for setting up and installing language servers, but this might not be adequate for all users. The LSP installer doesn't support all of the language servers that Neovim's LSP config supports and some users may already have the language servers installed on their machine and don't want to reinstall it separately. In these cases we have added an easy interface for setting up these servers. The following plugin specification for AstroLSP simply sets up `pyright` language server for a user with `pyright` already available on their system:
AstroNvim comes with [mason-lspconfig](https://github.com/williamboman/mason-lspconfig.nvim) as an easy interface for setting up language servers installed with Mason, but this might not be adequate for all users. The LSP installer doesn't support all of the language servers that Neovim's LSP config supports and some users may already have the language servers installed on their machine and don't want to reinstall it separately. In these cases we have added an easy interface for setting up these servers. The following plugin specification for AstroLSP simply sets up `pyright` language server for a user with `pyright` already available on their system:

```lua title="lua/plugins/astrolsp.lua" {7-12}
return {
Expand Down Expand Up @@ -278,7 +278,7 @@ Many of these can be found pre-configured in the [AstroNvim Community Repository

:::

There are some plugins available for doing advanced setup of language servers that require the user to not use the `lspconfig` setup call and instead use their own plugin setup for handling this. AstroNvim provides a nice way to do this while still using `mason-lspconfig` for installing the language servers. You can use the `setup_handlers` table for specifying how language servers should be setup such as using a language specific plugin. This function for each handler has two parameters, the first is the name of the server and the second is the options we would be passing to the `lspconfig` setup call. These options include things such as our built in `capabilities`, `on_attach`, as well as the user defined options in the `config` table. Here are a couple examples for some common LSP plugins:
There are some plugins available for doing advanced setup of language servers that require the user to not use the `lspconfig` setup call and instead use their own plugin setup for handling this. AstroNvim provides a nice way to do this while still using `mason.nvim` for installing the language servers. You can use the `setup_handlers` table for specifying how language servers should be setup such as using a language specific plugin. This function for each handler has two parameters, the first is the name of the server and the second is the options we would be passing to the `lspconfig` setup call. These options include things such as our built in `capabilities`, `on_attach`, as well as the user defined options in the `config` table. Here are a couple examples for some common LSP plugins:

### Typescript ([typescript.nvim](https://github.com/jose-elias-alvarez/typescript.nvim))

Expand Down Expand Up @@ -311,9 +311,9 @@ return {
},
},
{
"williamboman/mason-lspconfig.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim",
opts = {
ensure_installed = { "tsserver" }, -- automatically install lsp
ensure_installed = { "typescript-language-server" }, -- automatically install lsp
},
},
}
Expand Down Expand Up @@ -350,9 +350,9 @@ return {
},
},
{
"williamboman/mason-lspconfig.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim",
opts = {
ensure_installed = { "denols" }, -- automatically install lsp
ensure_installed = { "deno" }, -- automatically install lsp
},
},
}
Expand Down Expand Up @@ -506,7 +506,7 @@ return {
end,
},
{
"williamboman/mason-lspconfig.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim",
opts = {
ensure_installed = { "clangd" }, -- automatically install lsp
},
Expand Down Expand Up @@ -597,9 +597,9 @@ return {
},
},
{
"williamboman/mason-lspconfig.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim",
opts = {
ensure_installed = { "rust_analyzer" }, -- automatically install lsp
ensure_installed = { "rust-analyzer" }, -- automatically install lsp
},
},
}
Expand Down Expand Up @@ -701,7 +701,7 @@ return {
},
},
{
"williamboman/mason-lspconfig.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim",
opts = {
ensure_installed = { "jdtls" },
},
Expand Down
8 changes: 4 additions & 4 deletions src/content/docs/recipes/dap.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ return {

### Automatically Install Debuggers

`mason-nvim-dap` also allows you to automatically install debuggers that you may want. This can be configured by extending the `mason-nvim-dap` plugin options:
`mason-tool-installer.nvim` is the plugin AstroNvim uses to centralize Mason package management and allows you to automatically install debuggers that you may want. This can be configured by extending the `mason-tool-installer.nvim` plugin options:

```lua title="lua/plugins/mason-nvim-dap.lua"
```lua title="lua/plugins/mason-tool-installer.lua"
return {
"jay-babu/mason-nvim-dap.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim",
opts = {
ensure_installed = { "python" },
ensure_installed = { "debugpy" },
},
}
```
Expand Down
1 change: 1 addition & 0 deletions src/content/docs/reference/default_plugins.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ title: Default Plugins
| [L3MON4D3/LuaSnip](https://github.com/L3MON4D3/LuaSnip) | Snippet Engine |
| [MunifTanjim/nui.nvim](https://github.com/MunifTanjim/nui.nvim) | UI Component Library (for Neo-Tree) |
| [NMAC427/guess-indent.nvim](https://github.com/NMAC427/guess-indent.nvim) | Automatic Indentation Detection |
| [WhoIsSethDaniel/mason-tool-installer.nvim](https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim) | Automatic Mason Installation |
| [akinsho/toggleterm.nvim](https://github.com/akinsho/toggleterm.nvim) | Terminal Management |
| [brenoprata10/nvim-highlight-colors](https://github.com/brenoprata10/nvim-highlight-colors) | Highlight Color Strings |
| [echasnovski/mini.bufremove](https://github.com/echasnovski/mini.bufremove) | Buffer Removal |
Expand Down
18 changes: 9 additions & 9 deletions src/content/docs/using_the_docs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ AstroNvim is configured nearly entirely through the configuration of Neovim plug

For example, a recipe or code block may look like this which describes how to automatically install the Typescript language server:

```lua title="lua/plugins/mason-lspconfig.lua"
```lua title="lua/plugins/mason-tool-installer.lua"
return {
{
"williamboman/mason-lspconfig.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim",
opts = {
ensure_installed = { "tsserver" },
ensure_installed = { "typescript-language-server" },
},
},
}
Expand All @@ -26,24 +26,24 @@ This can either be fully copied and pasted into a new file in your `lua/plugins`
```lua title="lua/plugins/tsserver.lua" ins={1-8}
return {
{
"williamboman/mason-lspconfig.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim",
opts = {
ensure_installed = { "tsserver" },
ensure_installed = { "typescript-language-server" },
},
},
}
```

Sometimes you might want to consolidate the code as well such as if you are already automatically installing other language servers. In that case you will just want to take the code that is in the recipe and fit it into files/locations that you are already managing. For example, say you already have a `lua/plugins/mason-lspconfig.lua` file that is automatically installing the python language server:
Sometimes you might want to consolidate the code as well such as if you are already automatically installing other language servers. In that case you will just want to take the code that is in the recipe and fit it into files/locations that you are already managing. For example, say you already have a `lua/plugins/mason-tool-installer.lua` file that is automatically installing the python language server:

```lua title="lua/plugins/mason-lspconfig.lua" ins={7}
```lua title="lua/plugins/mason-tool-installer.lua" ins={7}
return {
{
"williamboman/mason-lspconfig.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim",
opts = {
ensure_installed = {
"pyright",
"tsserver",
"typescript-language-server",
},
},
},
Expand Down

0 comments on commit 1a6eb27

Please sign in to comment.