mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-14 11:24:38 +02:00
fix(mason): conform to v2 changes
This commit is contained in:
commit
040be9b87a
24 changed files with 85 additions and 55 deletions
|
@ -24,7 +24,7 @@ local supported = {
|
|||
|
||||
return {
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
opts = { ensure_installed = { "biome" } },
|
||||
},
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
return {
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
opts = function(_, opts)
|
||||
table.insert(opts.ensure_installed, "black")
|
||||
end,
|
||||
|
|
|
@ -58,7 +58,7 @@ M.has_parser = LazyVim.memoize(M.has_parser)
|
|||
|
||||
return {
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
opts = { ensure_installed = { "prettier" } },
|
||||
},
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ return {
|
|||
})
|
||||
end,
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
opts = { ensure_installed = { "ansible-lint" } },
|
||||
},
|
||||
{
|
||||
|
|
|
@ -117,7 +117,7 @@ return {
|
|||
optional = true,
|
||||
dependencies = {
|
||||
-- Ensure C/C++ debugger is installed
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
optional = true,
|
||||
opts = { ensure_installed = { "codelldb" } },
|
||||
},
|
||||
|
|
|
@ -10,7 +10,7 @@ return {
|
|||
},
|
||||
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
opts = { ensure_installed = { "elm-format" } },
|
||||
},
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ return {
|
|||
},
|
||||
-- Ensure Go tools are installed
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
opts = { ensure_installed = { "goimports", "gofumpt" } },
|
||||
},
|
||||
{
|
||||
|
@ -83,7 +83,7 @@ return {
|
|||
optional = true,
|
||||
dependencies = {
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
opts = { ensure_installed = { "gomodifytags", "impl" } },
|
||||
},
|
||||
},
|
||||
|
@ -111,7 +111,7 @@ return {
|
|||
optional = true,
|
||||
dependencies = {
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
opts = { ensure_installed = { "delve" } },
|
||||
},
|
||||
{
|
||||
|
|
|
@ -28,7 +28,7 @@ return {
|
|||
},
|
||||
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
opts = { ensure_installed = { "haskell-language-server" } },
|
||||
},
|
||||
|
||||
|
@ -37,7 +37,7 @@ return {
|
|||
optional = true,
|
||||
dependencies = {
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
opts = { ensure_installed = { "haskell-debug-adapter" } },
|
||||
},
|
||||
},
|
||||
|
|
|
@ -56,7 +56,7 @@ return {
|
|||
end,
|
||||
dependencies = {
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
opts = { ensure_installed = { "java-debug-adapter", "java-test" } },
|
||||
},
|
||||
},
|
||||
|
@ -87,8 +87,7 @@ return {
|
|||
opts = function()
|
||||
local cmd = { vim.fn.exepath("jdtls") }
|
||||
if LazyVim.has("mason.nvim") then
|
||||
local mason_registry = require("mason-registry")
|
||||
local lombok_jar = mason_registry.get_package("jdtls"):get_install_path() .. "/lombok.jar"
|
||||
local lombok_jar = LazyVim.get_pkg_path("jdtls", "/lombok.jar")
|
||||
table.insert(cmd, string.format("--jvm-arg=-javaagent:%s", lombok_jar))
|
||||
end
|
||||
return {
|
||||
|
@ -151,15 +150,13 @@ return {
|
|||
if LazyVim.has("mason.nvim") then
|
||||
local mason_registry = require("mason-registry")
|
||||
if opts.dap and LazyVim.has("nvim-dap") and mason_registry.is_installed("java-debug-adapter") then
|
||||
local java_dbg_pkg = mason_registry.get_package("java-debug-adapter")
|
||||
local java_dbg_path = java_dbg_pkg:get_install_path()
|
||||
local java_dbg_path = LazyVim.get_pkg_path("java-debug-adapter")
|
||||
local jar_patterns = {
|
||||
java_dbg_path .. "/extension/server/com.microsoft.java.debug.plugin-*.jar",
|
||||
}
|
||||
-- java-test also depends on java-debug-adapter.
|
||||
if opts.test and mason_registry.is_installed("java-test") then
|
||||
local java_test_pkg = mason_registry.get_package("java-test")
|
||||
local java_test_path = java_test_pkg:get_install_path()
|
||||
local java_test_path = LazyVim.get_pkg_path("java-test")
|
||||
vim.list_extend(jar_patterns, {
|
||||
java_test_path .. "/extension/server/*.jar",
|
||||
})
|
||||
|
|
|
@ -14,7 +14,7 @@ return {
|
|||
end,
|
||||
-- Add packages(linting, debug adapter)
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
opts = { ensure_installed = { "ktlint" } },
|
||||
},
|
||||
-- Add syntax highlighting
|
||||
|
@ -35,7 +35,7 @@ return {
|
|||
{
|
||||
"mfussenegger/nvim-lint",
|
||||
optional = true,
|
||||
dependencies = "williamboman/mason.nvim",
|
||||
dependencies = "mason-org/mason.nvim",
|
||||
opts = {
|
||||
linters_by_ft = { kotlin = { "ktlint" } },
|
||||
},
|
||||
|
@ -64,7 +64,7 @@ return {
|
|||
{
|
||||
"mfussenegger/nvim-dap",
|
||||
optional = true,
|
||||
dependencies = "williamboman/mason.nvim",
|
||||
dependencies = "mason-org/mason.nvim",
|
||||
opts = function()
|
||||
local dap = require("dap")
|
||||
if not dap.adapters.kotlin then
|
||||
|
|
|
@ -40,7 +40,7 @@ return {
|
|||
},
|
||||
},
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
opts = { ensure_installed = { "markdownlint-cli2", "markdown-toc" } },
|
||||
},
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@ return {
|
|||
},
|
||||
},
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
opts = { ensure_installed = { "csharpier", "netcoredbg" } },
|
||||
},
|
||||
{
|
||||
|
|
|
@ -35,7 +35,7 @@ return {
|
|||
},
|
||||
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"phpcs",
|
||||
|
@ -48,7 +48,7 @@ return {
|
|||
optional = true,
|
||||
opts = function()
|
||||
local dap = require("dap")
|
||||
local path = require("mason-registry").get_package("php-debug-adapter"):get_install_path()
|
||||
local path = LazyVim.get_pkg_path("php-debug-adapter")
|
||||
dap.adapters.php = {
|
||||
type = "executable",
|
||||
command = "node",
|
||||
|
|
|
@ -48,7 +48,7 @@ return {
|
|||
},
|
||||
},
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
opts = { ensure_installed = { "erb-formatter", "erb-lint" } },
|
||||
},
|
||||
{
|
||||
|
|
|
@ -43,7 +43,7 @@ return {
|
|||
|
||||
-- Ensure Rust debugger is installed
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
optional = true,
|
||||
opts = function(_, opts)
|
||||
opts.ensure_installed = opts.ensure_installed or {}
|
||||
|
@ -111,7 +111,7 @@ return {
|
|||
},
|
||||
config = function(_, opts)
|
||||
if LazyVim.has("mason.nvim") then
|
||||
local package_path = require("mason-registry").get_package("codelldb"):get_install_path()
|
||||
local package_path = LazyVim.get_pkg_path("codelldb")
|
||||
local codelldb = package_path .. "/extension/adapter/codelldb"
|
||||
local library_path = package_path .. "/extension/lldb/lib/liblldb.dylib"
|
||||
local uname = io.popen("uname"):read("*l")
|
||||
|
|
|
@ -143,7 +143,7 @@ return {
|
|||
|
||||
-- Linters & formatters
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
opts = { ensure_installed = { "sqlfluff" } },
|
||||
},
|
||||
{
|
||||
|
|
|
@ -20,7 +20,7 @@ return {
|
|||
},
|
||||
-- ensure terraform tools are installed
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
opts = { ensure_installed = { "tflint" } },
|
||||
},
|
||||
{
|
||||
|
|
|
@ -194,7 +194,7 @@ return {
|
|||
optional = true,
|
||||
dependencies = {
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
opts = function(_, opts)
|
||||
opts.ensure_installed = opts.ensure_installed or {}
|
||||
table.insert(opts.ensure_installed, "js-debug-adapter")
|
||||
|
|
|
@ -18,7 +18,7 @@ return {
|
|||
},
|
||||
},
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
opts = { ensure_installed = { "shellcheck" } },
|
||||
},
|
||||
-- add some stuff to treesitter
|
||||
|
|
|
@ -2,7 +2,7 @@ return {
|
|||
|
||||
-- Ensure GitUI tool is installed
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
opts = { ensure_installed = { "gitui" } },
|
||||
keys = {
|
||||
{
|
||||
|
|
|
@ -2,10 +2,14 @@ return {
|
|||
-- lspconfig
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
event = "LazyFile",
|
||||
event = vim.fn.has("nvim-0.11") == 1 and { "BufReadPre", "BufNewFile", "BufWritePre" } or "LazyFile",
|
||||
dependencies = {
|
||||
"mason.nvim",
|
||||
{ "williamboman/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()
|
||||
---@class PluginLspOpts
|
||||
|
@ -188,7 +192,18 @@ return {
|
|||
opts.capabilities or {}
|
||||
)
|
||||
|
||||
local function setup(server)
|
||||
-- get all the servers that are available through mason-lspconfig
|
||||
local have_mason, mlsp = pcall(require, "mason-lspconfig")
|
||||
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").get_mappings().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 function configure(server)
|
||||
local server_opts = vim.tbl_deep_extend("force", {
|
||||
capabilities = vim.deepcopy(capabilities),
|
||||
}, servers[server] or {})
|
||||
|
@ -205,14 +220,22 @@ return {
|
|||
return
|
||||
end
|
||||
end
|
||||
require("lspconfig")[server].setup(server_opts)
|
||||
end
|
||||
if vim.fn.has("nvim-0.11") == 1 then
|
||||
vim.lsp.config(server, server_opts)
|
||||
else
|
||||
require("lspconfig")[server].setup(server_opts)
|
||||
end
|
||||
|
||||
-- get all the servers that are available through mason-lspconfig
|
||||
local have_mason, mlsp = pcall(require, "mason-lspconfig")
|
||||
local all_mslp_servers = {}
|
||||
if have_mason then
|
||||
all_mslp_servers = vim.tbl_keys(require("mason-lspconfig.mappings.server").lspconfig_to_package)
|
||||
-- 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 vim.fn.has("nvim-0.11") == 1 then
|
||||
vim.lsp.enable(server)
|
||||
else
|
||||
configure(server)
|
||||
end
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local ensure_installed = {} ---@type string[]
|
||||
|
@ -221,8 +244,8 @@ return {
|
|||
server_opts = server_opts == true and {} or server_opts
|
||||
if server_opts.enabled ~= false then
|
||||
-- run manual setup 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
|
||||
setup(server)
|
||||
if configure(server) then
|
||||
exclude_automatic_enable[#exclude_automatic_enable + 1] = server
|
||||
else
|
||||
ensure_installed[#ensure_installed + 1] = server
|
||||
end
|
||||
|
@ -231,14 +254,23 @@ return {
|
|||
end
|
||||
|
||||
if have_mason then
|
||||
mlsp.setup({
|
||||
local setup_config = {
|
||||
ensure_installed = vim.tbl_deep_extend(
|
||||
"force",
|
||||
ensure_installed,
|
||||
LazyVim.opts("mason-lspconfig.nvim").ensure_installed or {}
|
||||
),
|
||||
handlers = { setup },
|
||||
})
|
||||
}
|
||||
|
||||
if vim.fn.has("nvim-0.11") == 1 then
|
||||
setup_config.automatic_enable = {
|
||||
exclude = exclude_automatic_enable,
|
||||
}
|
||||
else
|
||||
setup_config.handlers = { configure }
|
||||
end
|
||||
|
||||
mlsp.setup(setup_config)
|
||||
end
|
||||
|
||||
if LazyVim.lsp.is_enabled("denols") and LazyVim.lsp.is_enabled("vtsls") then
|
||||
|
@ -257,8 +289,9 @@ return {
|
|||
-- cmdline tools and lsp servers
|
||||
{
|
||||
|
||||
"williamboman/mason.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
cmd = "Mason",
|
||||
version = vim.fn.has("nvim-0.11") == 0 and "1.11.0" or false,
|
||||
keys = { { "<leader>cm", "<cmd>Mason<cr>", desc = "Mason" } },
|
||||
build = ":MasonUpdate",
|
||||
opts_extend = { "ensure_installed" },
|
||||
|
|
|
@ -253,7 +253,7 @@ function M.get_pkg_path(pkg, path, opts)
|
|||
opts = opts or {}
|
||||
opts.warn = opts.warn == nil and true or opts.warn
|
||||
path = path or ""
|
||||
local ret = root .. "/packages/" .. pkg .. "/" .. path
|
||||
local ret = root .. "/packages/" .. pkg .. path
|
||||
if opts.warn and not vim.loop.fs_stat(ret) and not require("lazy.core.config").headless() then
|
||||
M.warn(
|
||||
("Mason package path not found for **%s**:\n- `%s`\nYou may need to force update the package."):format(pkg, path)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue