aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2025-04-21 19:28:33 +0200
committerWilliam Boman <william@redwill.se>2025-04-21 19:28:33 +0200
commit5c142464ea29ceca3b4d77d2c80b9e8e3fca02d9 (patch)
tree4ac215a1b5d3eb6a2cb2a61ea46a81ea9d581da1
parentv2.0.0-rc.1 (diff)
downloadmason-lspconfig-5c142464ea29ceca3b4d77d2c80b9e8e3fca02d9.tar
mason-lspconfig-5c142464ea29ceca3b4d77d2c80b9e8e3fca02d9.tar.gz
mason-lspconfig-5c142464ea29ceca3b4d77d2c80b9e8e3fca02d9.tar.bz2
mason-lspconfig-5c142464ea29ceca3b4d77d2c80b9e8e3fca02d9.tar.lz
mason-lspconfig-5c142464ea29ceca3b4d77d2c80b9e8e3fca02d9.tar.xz
mason-lspconfig-5c142464ea29ceca3b4d77d2c80b9e8e3fca02d9.tar.zst
mason-lspconfig-5c142464ea29ceca3b4d77d2c80b9e8e3fca02d9.zip
refactor!: remove `automatic_installation` setting
This is removed because of the transition towards `vim.lsp.config`-style configurations.
-rw-r--r--README.md11
-rw-r--r--doc/mason-lspconfig.txt11
-rw-r--r--lua/mason-lspconfig/lspconfig_hook.lua29
-rw-r--r--lua/mason-lspconfig/settings.lua11
-rw-r--r--tests/mason-lspconfig/setup_spec.lua92
5 files changed, 0 insertions, 154 deletions
diff --git a/README.md b/README.md
index c5d32fb..f8f5ab7 100644
--- a/README.md
+++ b/README.md
@@ -146,20 +146,9 @@ require("mason-lspconfig").setup {
```lua
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,
diff --git a/doc/mason-lspconfig.txt b/doc/mason-lspconfig.txt
index e7392ac..44c437f 100644
--- a/doc/mason-lspconfig.txt
+++ b/doc/mason-lspconfig.txt
@@ -140,20 +140,9 @@ Example:
>lua
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,
diff --git a/lua/mason-lspconfig/lspconfig_hook.lua b/lua/mason-lspconfig/lspconfig_hook.lua
index cc7606f..04010f1 100644
--- a/lua/mason-lspconfig/lspconfig_hook.lua
+++ b/lua/mason-lspconfig/lspconfig_hook.lua
@@ -5,22 +5,6 @@ local platform = require "mason-core.platform"
local memoized_set = _.memoize(_.set_of)
----@param server_name string
-local function should_auto_install(server_name)
- if platform.is_headless then
- return false
- end
- local settings = require "mason-lspconfig.settings"
-
- if settings.current.automatic_installation == true then
- return true
- end
- if type(settings.current.automatic_installation) == "table" then
- return not memoized_set(settings.current.automatic_installation.exclude)[server_name]
- end
- return false
-end
-
---@param lspconfig_server_name string
local function resolve_server_config_factory(lspconfig_server_name)
local Optional = require "mason-core.optional"
@@ -84,19 +68,6 @@ return function()
log.error("Failed to expand cmd path", config.name, config.cmd)
end
end
- elseif should_auto_install(config.name) then
- local ok, pkg = pcall(registry.get_package, pkg_name)
- if ok then
- require("mason-lspconfig.install").install(pkg):once(
- "closed",
- vim.schedule_wrap(function()
- if pkg:is_installed() then
- -- reload config
- require("lspconfig")[config.name].setup(config)
- end
- end)
- )
- end
end
end)
end
diff --git a/lua/mason-lspconfig/settings.lua b/lua/mason-lspconfig/settings.lua
index f808a25..e852a3d 100644
--- a/lua/mason-lspconfig/settings.lua
+++ b/lua/mason-lspconfig/settings.lua
@@ -3,20 +3,9 @@ local M = {}
---@class MasonLspconfigSettings
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,
diff --git a/tests/mason-lspconfig/setup_spec.lua b/tests/mason-lspconfig/setup_spec.lua
index ad37ce6..c5a3fee 100644
--- a/tests/mason-lspconfig/setup_spec.lua
+++ b/tests/mason-lspconfig/setup_spec.lua
@@ -117,98 +117,6 @@ describe("mason-lspconfig setup", function()
end)
)
- it(
- "should notify when installing servers via automatic installation",
- async_test(function()
- local dummy = registry.get_package "dummy"
- local fail_dummy = registry.get_package "fail_dummy"
- spy.on(Pkg, "install")
- spy.on(vim, "notify")
-
- platform.is_headless = false
- mason_lspconfig.setup { automatic_installation = true }
- local lspconfig = require "lspconfig"
- lspconfig.dummylsp.setup {}
- lspconfig.fail_dummylsp.setup {}
-
- assert.spy(Pkg.install).was_called(2)
- assert.spy(Pkg.install).was_called_with(match.ref(dummy), {})
- assert.spy(Pkg.install).was_called_with(match.ref(fail_dummy), {})
-
- assert
- .spy(vim.notify)
- .was_called_with(
- [[[mason-lspconfig.nvim] installing dummylsp]],
- vim.log.levels.INFO,
- { title = "mason-lspconfig.nvim" }
- )
- assert.spy(vim.notify).was_called_with(
- [[[mason-lspconfig.nvim] installing fail_dummylsp]],
- vim.log.levels.INFO,
- { title = "mason-lspconfig.nvim" }
- )
- assert.wait_for(function()
- assert.is_true(dummy.install_handle:is_closed())
- assert.is_true(fail_dummy.install_handle:is_closed())
- assert.spy(vim.notify).was_called_with(
- [[[mason-lspconfig.nvim] dummylsp was successfully installed]],
- vim.log.levels.INFO,
- { title = "mason-lspconfig.nvim" }
- )
- assert.spy(vim.notify).was_called_with(
- [[[mason-lspconfig.nvim] failed to install fail_dummylsp. Installation logs are available in :Mason and :MasonLog]],
- vim.log.levels.ERROR,
- { title = "mason-lspconfig.nvim" }
- )
- end)
- end)
- )
-
- it(
- "should automatically install servers",
- async_test(function()
- local dummy = registry.get_package "dummy"
- local dummy2 = registry.get_package "dummy2"
- spy.on(Pkg, "install")
-
- platform.is_headless = false
- mason_lspconfig.setup { automatic_installation = true }
- local lspconfig = require "lspconfig"
- spy.on(lspconfig.dummylsp, "setup")
- spy.on(lspconfig.dummy2lsp, "setup")
- lspconfig.dummylsp.setup {}
- lspconfig.dummy2lsp.setup {}
-
- assert.spy(Pkg.install).was_called(2)
- assert.spy(Pkg.install).was_called_with(match.ref(dummy), {})
- assert.spy(Pkg.install).was_called_with(match.ref(dummy2), {})
-
- assert.wait_for(function()
- assert.is_true(dummy.install_handle:is_closed())
- assert.is_true(dummy2.install_handle:is_closed())
- assert.spy(lspconfig.dummylsp.setup).was_called(2)
- assert.spy(lspconfig.dummy2lsp.setup).was_called(2)
- end)
- end)
- )
-
- it(
- "should not automatically install servers when headless",
- async_test(function()
- spy.on(Pkg, "install")
-
- platform.is_headless = true
- mason_lspconfig.setup { automatic_installation = true }
- local lspconfig = require "lspconfig"
- spy.on(lspconfig.dummylsp, "setup")
- spy.on(lspconfig.dummy2lsp, "setup")
- lspconfig.dummylsp.setup {}
- lspconfig.dummy2lsp.setup {}
-
- assert.spy(Pkg.install).was_called(0)
- end)
- )
-
it("should apply mason-lspconfig server configs", function()
stub(registry, "is_installed")
registry.is_installed.on_call_with("dummy").returns(true)