Skip to content

Commit

Permalink
fix: prevent mason setup from being run twice (#1298)
Browse files Browse the repository at this point in the history
* fix: prevent mason setup from being run twice

Addresses nvim-lua/kickstart.nvim#1297

Currently, we're calling `require('mason').setup(...)` twice:
* once when setting it as a dependency of `nvim-lspconfig` (since we set
        `config = true`)
* once in the `config` function we define for `nvim-lspconfig`

Calling setup twice can cause issues with, e.g., setting the `PATH`
option: you might append Mason's bin dir in one setup call and prepend
it in the other.

We've kept the setup of `mason` in the `nvim-lspconfig` dependencies
table since leaving it to the `config` function caused some
plugin-loading-order related issues in the past. See:
* nvim-lua/kickstart.nvim#210
* nvim-lua/kickstart.nvim#554
* nvim-lua/kickstart.nvim#555
* nvim-lua/kickstart.nvim#865

* docs: tweak comments per review feedback
  • Loading branch information
paulopizarro committed Jan 8, 2025
1 parent cf18f08 commit 80bc39f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,14 @@ git clone https://github.com/ppizarro/my.vim ~/.config/nvim
`gc` - Toggles the region using linewise comment
`gb` - Toggles the region using blockwise comment
```

# Update

To check the current status of installed tools and/or manually install
other tools, you can run
:Mason

You can press `g?` for help in this menu.

`mason` had to be setup earlier: to configure its options see the
`dependencies` table for `nvim-lspconfig` above.
4 changes: 3 additions & 1 deletion lua/pp/plugins/lsp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ return {
"neovim/nvim-lspconfig",
dependencies = {
-- Automatically install LSPs and related tools to stdpath for Neovim
{ "williamboman/mason.nvim", config = true }, -- NOTE: Must be loaded before dependants
-- Mason must be loaded before its dependents so we need to set it up here.
-- NOTE: `opts = {}` is the same as calling `require('mason').setup({})`
{ "williamboman/mason.nvim", opts = {} },
{ "williamboman/mason-lspconfig.nvim" },
{ "WhoIsSethDaniel/mason-tool-installer.nvim" },

Expand Down

0 comments on commit 80bc39f

Please sign in to comment.