refactor: remove < 0.11 code

This commit is contained in:
Folke Lemaitre 2025-09-15 11:59:46 +02:00
parent 6cb3d86762
commit d4aa0a7da2
No known key found for this signature in database
GPG key ID: 9B52594D560070AB

View file

@ -2,14 +2,10 @@ return {
-- lspconfig -- lspconfig
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
event = vim.fn.has("nvim-0.11") == 1 and { "BufReadPre", "BufNewFile", "BufWritePre" } or "LazyFile", event = { "BufReadPre", "BufNewFile", "BufWritePre" },
dependencies = { dependencies = {
"mason.nvim", "mason.nvim",
{ { "mason-org/mason-lspconfig.nvim", config = function() end },
"mason-org/mason-lspconfig.nvim",
version = vim.fn.has("nvim-0.11") == 0 and "1.32.0" or false,
config = function() end,
},
}, },
opts = function() opts = function()
---@class PluginLspOpts ---@class PluginLspOpts
@ -181,11 +177,7 @@ return {
-- get all the servers that are available through mason-lspconfig -- get all the servers that are available through mason-lspconfig
local have_mason, mlsp = pcall(require, "mason-lspconfig") local have_mason, mlsp = pcall(require, "mason-lspconfig")
local all_mslp_servers = {} local all_mslp_servers = {}
if have_mason and vim.fn.has("nvim-0.11") == 1 then all_mslp_servers = vim.tbl_keys(require("mason-lspconfig.mappings").get_mason_map().lspconfig_to_package)
all_mslp_servers = vim.tbl_keys(require("mason-lspconfig.mappings").get_mason_map().lspconfig_to_package)
elseif have_mason then
all_mslp_servers = vim.tbl_keys(require("mason-lspconfig.mappings.server").lspconfig_to_package)
end
local exclude_automatic_enable = {} ---@type string[] local exclude_automatic_enable = {} ---@type string[]
@ -203,19 +195,11 @@ return {
return true return true
end end
end end
if vim.fn.has("nvim-0.11") == 1 then vim.lsp.config(server, server_opts)
vim.lsp.config(server, server_opts)
else
require("lspconfig")[server].setup(server_opts)
end
-- manually enable if mason=false or if this is a server that cannot be installed with mason-lspconfig -- manually enable if mason=false or if this is a server that cannot be installed with mason-lspconfig
if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then
if vim.fn.has("nvim-0.11") == 1 then vim.lsp.enable(server)
vim.lsp.enable(server)
else
configure(server)
end
return true return true
end end
return false return false
@ -247,13 +231,9 @@ return {
), ),
} }
if vim.fn.has("nvim-0.11") == 1 then setup_config.automatic_enable = {
setup_config.automatic_enable = { exclude = exclude_automatic_enable,
exclude = exclude_automatic_enable, }
}
else
setup_config.handlers = { configure }
end
mlsp.setup(setup_config) mlsp.setup(setup_config)
end end
@ -276,7 +256,6 @@ return {
"mason-org/mason.nvim", "mason-org/mason.nvim",
cmd = "Mason", cmd = "Mason",
version = vim.fn.has("nvim-0.11") == 0 and "1.11.0" or false,
keys = { { "<leader>cm", "<cmd>Mason<cr>", desc = "Mason" } }, keys = { { "<leader>cm", "<cmd>Mason<cr>", desc = "Mason" } },
build = ":MasonUpdate", build = ":MasonUpdate",
opts_extend = { "ensure_installed" }, opts_extend = { "ensure_installed" },