From 8a52e1bf75a48227013e73c6940586d7421b8b42 Mon Sep 17 00:00:00 2001 From: Iordanis Petkakis <12776461+dpetka2001@users.noreply.github.com> Date: Thu, 8 May 2025 20:17:39 +0300 Subject: [PATCH 1/8] fix(mason): conform to v2 changes --- .../plugins/extras/formatting/biome.lua | 2 +- .../plugins/extras/formatting/black.lua | 2 +- .../plugins/extras/formatting/prettier.lua | 2 +- lua/lazyvim/plugins/extras/lang/ansible.lua | 2 +- lua/lazyvim/plugins/extras/lang/clangd.lua | 2 +- lua/lazyvim/plugins/extras/lang/elm.lua | 2 +- lua/lazyvim/plugins/extras/lang/go.lua | 6 +- lua/lazyvim/plugins/extras/lang/haskell.lua | 4 +- lua/lazyvim/plugins/extras/lang/java.lua | 11 ++-- lua/lazyvim/plugins/extras/lang/kotlin.lua | 6 +- lua/lazyvim/plugins/extras/lang/markdown.lua | 2 +- lua/lazyvim/plugins/extras/lang/omnisharp.lua | 2 +- lua/lazyvim/plugins/extras/lang/php.lua | 4 +- lua/lazyvim/plugins/extras/lang/ruby.lua | 2 +- lua/lazyvim/plugins/extras/lang/rust.lua | 4 +- lua/lazyvim/plugins/extras/lang/sql.lua | 2 +- lua/lazyvim/plugins/extras/lang/terraform.lua | 2 +- .../plugins/extras/lang/typescript.lua | 2 +- lua/lazyvim/plugins/extras/util/dot.lua | 2 +- lua/lazyvim/plugins/extras/util/gitui.lua | 2 +- lua/lazyvim/plugins/lsp/init.lua | 65 ++++++++++++++----- lua/lazyvim/util/init.lua | 2 +- tests/extras/extra_spec.lua | 4 +- tests/minit.lua | 4 +- 24 files changed, 84 insertions(+), 54 deletions(-) diff --git a/lua/lazyvim/plugins/extras/formatting/biome.lua b/lua/lazyvim/plugins/extras/formatting/biome.lua index 1a4e274c..91e488ca 100644 --- a/lua/lazyvim/plugins/extras/formatting/biome.lua +++ b/lua/lazyvim/plugins/extras/formatting/biome.lua @@ -24,7 +24,7 @@ local supported = { return { { - "williamboman/mason.nvim", + "mason-org/mason.nvim", opts = { ensure_installed = { "biome" } }, }, diff --git a/lua/lazyvim/plugins/extras/formatting/black.lua b/lua/lazyvim/plugins/extras/formatting/black.lua index 769c3009..29289393 100644 --- a/lua/lazyvim/plugins/extras/formatting/black.lua +++ b/lua/lazyvim/plugins/extras/formatting/black.lua @@ -1,6 +1,6 @@ return { { - "williamboman/mason.nvim", + "mason-org/mason.nvim", opts = function(_, opts) table.insert(opts.ensure_installed, "black") end, diff --git a/lua/lazyvim/plugins/extras/formatting/prettier.lua b/lua/lazyvim/plugins/extras/formatting/prettier.lua index 855dc258..6edd414c 100644 --- a/lua/lazyvim/plugins/extras/formatting/prettier.lua +++ b/lua/lazyvim/plugins/extras/formatting/prettier.lua @@ -58,7 +58,7 @@ M.has_parser = LazyVim.memoize(M.has_parser) return { { - "williamboman/mason.nvim", + "mason-org/mason.nvim", opts = { ensure_installed = { "prettier" } }, }, diff --git a/lua/lazyvim/plugins/extras/lang/ansible.lua b/lua/lazyvim/plugins/extras/lang/ansible.lua index 29d1711a..0d20b02a 100644 --- a/lua/lazyvim/plugins/extras/lang/ansible.lua +++ b/lua/lazyvim/plugins/extras/lang/ansible.lua @@ -6,7 +6,7 @@ return { }) end, { - "williamboman/mason.nvim", + "mason-org/mason.nvim", opts = { ensure_installed = { "ansible-lint" } }, }, { diff --git a/lua/lazyvim/plugins/extras/lang/clangd.lua b/lua/lazyvim/plugins/extras/lang/clangd.lua index ae245d54..33dc4ed4 100644 --- a/lua/lazyvim/plugins/extras/lang/clangd.lua +++ b/lua/lazyvim/plugins/extras/lang/clangd.lua @@ -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" } }, }, diff --git a/lua/lazyvim/plugins/extras/lang/elm.lua b/lua/lazyvim/plugins/extras/lang/elm.lua index 9e21ab0a..81cc4de6 100644 --- a/lua/lazyvim/plugins/extras/lang/elm.lua +++ b/lua/lazyvim/plugins/extras/lang/elm.lua @@ -10,7 +10,7 @@ return { }, { - "williamboman/mason.nvim", + "mason-org/mason.nvim", opts = { ensure_installed = { "elm-format" } }, }, diff --git a/lua/lazyvim/plugins/extras/lang/go.lua b/lua/lazyvim/plugins/extras/lang/go.lua index bf3b22ee..ff8def2e 100644 --- a/lua/lazyvim/plugins/extras/lang/go.lua +++ b/lua/lazyvim/plugins/extras/lang/go.lua @@ -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" } }, }, { diff --git a/lua/lazyvim/plugins/extras/lang/haskell.lua b/lua/lazyvim/plugins/extras/lang/haskell.lua index 77b0413a..a599d310 100644 --- a/lua/lazyvim/plugins/extras/lang/haskell.lua +++ b/lua/lazyvim/plugins/extras/lang/haskell.lua @@ -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" } }, }, }, diff --git a/lua/lazyvim/plugins/extras/lang/java.lua b/lua/lazyvim/plugins/extras/lang/java.lua index 236c86c9..45295740 100644 --- a/lua/lazyvim/plugins/extras/lang/java.lua +++ b/lua/lazyvim/plugins/extras/lang/java.lua @@ -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", }) diff --git a/lua/lazyvim/plugins/extras/lang/kotlin.lua b/lua/lazyvim/plugins/extras/lang/kotlin.lua index a15f3cc4..3c6be754 100644 --- a/lua/lazyvim/plugins/extras/lang/kotlin.lua +++ b/lua/lazyvim/plugins/extras/lang/kotlin.lua @@ -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 diff --git a/lua/lazyvim/plugins/extras/lang/markdown.lua b/lua/lazyvim/plugins/extras/lang/markdown.lua index 8b07985b..33e9e457 100644 --- a/lua/lazyvim/plugins/extras/lang/markdown.lua +++ b/lua/lazyvim/plugins/extras/lang/markdown.lua @@ -40,7 +40,7 @@ return { }, }, { - "williamboman/mason.nvim", + "mason-org/mason.nvim", opts = { ensure_installed = { "markdownlint-cli2", "markdown-toc" } }, }, { diff --git a/lua/lazyvim/plugins/extras/lang/omnisharp.lua b/lua/lazyvim/plugins/extras/lang/omnisharp.lua index 3881e6a4..07ba0490 100644 --- a/lua/lazyvim/plugins/extras/lang/omnisharp.lua +++ b/lua/lazyvim/plugins/extras/lang/omnisharp.lua @@ -36,7 +36,7 @@ return { }, }, { - "williamboman/mason.nvim", + "mason-org/mason.nvim", opts = { ensure_installed = { "csharpier", "netcoredbg" } }, }, { diff --git a/lua/lazyvim/plugins/extras/lang/php.lua b/lua/lazyvim/plugins/extras/lang/php.lua index 70814eae..616de783 100644 --- a/lua/lazyvim/plugins/extras/lang/php.lua +++ b/lua/lazyvim/plugins/extras/lang/php.lua @@ -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", diff --git a/lua/lazyvim/plugins/extras/lang/ruby.lua b/lua/lazyvim/plugins/extras/lang/ruby.lua index 9e21331e..4224e6d8 100644 --- a/lua/lazyvim/plugins/extras/lang/ruby.lua +++ b/lua/lazyvim/plugins/extras/lang/ruby.lua @@ -48,7 +48,7 @@ return { }, }, { - "williamboman/mason.nvim", + "mason-org/mason.nvim", opts = { ensure_installed = { "erb-formatter", "erb-lint" } }, }, { diff --git a/lua/lazyvim/plugins/extras/lang/rust.lua b/lua/lazyvim/plugins/extras/lang/rust.lua index e5304b56..027f49b2 100644 --- a/lua/lazyvim/plugins/extras/lang/rust.lua +++ b/lua/lazyvim/plugins/extras/lang/rust.lua @@ -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") diff --git a/lua/lazyvim/plugins/extras/lang/sql.lua b/lua/lazyvim/plugins/extras/lang/sql.lua index 8e69374c..070d26ff 100644 --- a/lua/lazyvim/plugins/extras/lang/sql.lua +++ b/lua/lazyvim/plugins/extras/lang/sql.lua @@ -143,7 +143,7 @@ return { -- Linters & formatters { - "williamboman/mason.nvim", + "mason-org/mason.nvim", opts = { ensure_installed = { "sqlfluff" } }, }, { diff --git a/lua/lazyvim/plugins/extras/lang/terraform.lua b/lua/lazyvim/plugins/extras/lang/terraform.lua index 8ae3f843..362dfc53 100644 --- a/lua/lazyvim/plugins/extras/lang/terraform.lua +++ b/lua/lazyvim/plugins/extras/lang/terraform.lua @@ -20,7 +20,7 @@ return { }, -- ensure terraform tools are installed { - "williamboman/mason.nvim", + "mason-org/mason.nvim", opts = { ensure_installed = { "tflint" } }, }, { diff --git a/lua/lazyvim/plugins/extras/lang/typescript.lua b/lua/lazyvim/plugins/extras/lang/typescript.lua index 6d7ae673..f7cc3231 100644 --- a/lua/lazyvim/plugins/extras/lang/typescript.lua +++ b/lua/lazyvim/plugins/extras/lang/typescript.lua @@ -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") diff --git a/lua/lazyvim/plugins/extras/util/dot.lua b/lua/lazyvim/plugins/extras/util/dot.lua index e24b9fe0..2c2a97a5 100644 --- a/lua/lazyvim/plugins/extras/util/dot.lua +++ b/lua/lazyvim/plugins/extras/util/dot.lua @@ -18,7 +18,7 @@ return { }, }, { - "williamboman/mason.nvim", + "mason-org/mason.nvim", opts = { ensure_installed = { "shellcheck" } }, }, -- add some stuff to treesitter diff --git a/lua/lazyvim/plugins/extras/util/gitui.lua b/lua/lazyvim/plugins/extras/util/gitui.lua index e0dd6049..524812a4 100644 --- a/lua/lazyvim/plugins/extras/util/gitui.lua +++ b/lua/lazyvim/plugins/extras/util/gitui.lua @@ -2,7 +2,7 @@ return { -- Ensure GitUI tool is installed { - "williamboman/mason.nvim", + "mason-org/mason.nvim", opts = { ensure_installed = { "gitui" } }, keys = { { diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua index 6ba4597f..d952a45c 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -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 = { { "cm", "Mason", desc = "Mason" } }, build = ":MasonUpdate", opts_extend = { "ensure_installed" }, diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index 4b49f539..ad1e05dd 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -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) diff --git a/tests/extras/extra_spec.lua b/tests/extras/extra_spec.lua index fa2fc9de..2afb6b94 100644 --- a/tests/extras/extra_spec.lua +++ b/tests/extras/extra_spec.lua @@ -44,7 +44,7 @@ describe("Extra", function() local mod = require(extra.modname) assert.is_not_nil(mod) local spec = Plugin.Spec.new({ - { "williamboman/mason.nvim", opts = { ensure_installed = {} } }, + { "mason-org/mason.nvim", opts = { ensure_installed = {} } }, { "nvim-treesitter/nvim-treesitter", opts = { ensure_installed = {} } }, mod, }, { optional = true }) @@ -60,7 +60,7 @@ describe("Extra", function() local mod = require(extra.modname) local spec = Plugin.Spec.new({ - { "williamboman/mason.nvim", opts = { ensure_installed = {} } }, + { "mason-org/mason.nvim", opts = { ensure_installed = {} } }, { "nvim-treesitter/nvim-treesitter", opts = { ensure_installed = {} } }, mod, }, { optional = true }) diff --git a/tests/minit.lua b/tests/minit.lua index 88cb4185..3eb3a8b4 100644 --- a/tests/minit.lua +++ b/tests/minit.lua @@ -8,8 +8,8 @@ require("lazy.minit").setup({ spec = { { dir = vim.uv.cwd() }, "LazyVim/starter", - "williamboman/mason-lspconfig.nvim", - "williamboman/mason.nvim", + "mason-org/mason-lspconfig.nvim", + "mason-org/mason.nvim", "nvim-treesitter/nvim-treesitter", { "echasnovski/mini.icons", opts = {} }, }, From 0585eeac05e7feb06246577cce251a351291e0df Mon Sep 17 00:00:00 2001 From: Iordanis Petkakis <12776461+dpetka2001@users.noreply.github.com> Date: Wed, 14 May 2025 11:22:57 +0300 Subject: [PATCH 2/8] Update lua/lazyvim/plugins/extras/lang/java.lua Co-authored-by: William Boman --- lua/lazyvim/plugins/extras/lang/java.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/lang/java.lua b/lua/lazyvim/plugins/extras/lang/java.lua index 45295740..5503ff12 100644 --- a/lua/lazyvim/plugins/extras/lang/java.lua +++ b/lua/lazyvim/plugins/extras/lang/java.lua @@ -87,7 +87,7 @@ return { opts = function() local cmd = { vim.fn.exepath("jdtls") } if LazyVim.has("mason.nvim") then - local lombok_jar = LazyVim.get_pkg_path("jdtls", "/lombok.jar") + local lombok_jar = vim.fn.expand "$MASON/share/jdtls/lombok.jar" table.insert(cmd, string.format("--jvm-arg=-javaagent:%s", lombok_jar)) end return { From 64c4e501c6989229d7920671c5991c85d4a9d557 Mon Sep 17 00:00:00 2001 From: Iordanis Petkakis <12776461+dpetka2001@users.noreply.github.com> Date: Wed, 14 May 2025 11:42:51 +0300 Subject: [PATCH 3/8] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit suggestions by @williamboman and @TheDSCPL Co-authored-by: William Boman Co-authored-by: Luis DurĂ£o --- lua/lazyvim/plugins/extras/lang/java.lua | 4 ++-- lua/lazyvim/plugins/lsp/init.lua | 2 +- lua/lazyvim/util/init.lua | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/java.lua b/lua/lazyvim/plugins/extras/lang/java.lua index 5503ff12..2548344e 100644 --- a/lua/lazyvim/plugins/extras/lang/java.lua +++ b/lua/lazyvim/plugins/extras/lang/java.lua @@ -152,13 +152,13 @@ return { if opts.dap and LazyVim.has("nvim-dap") and mason_registry.is_installed("java-debug-adapter") then 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", + vim.fn.expand "$MASON/share/java-debug-adapter/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_path = LazyVim.get_pkg_path("java-test") vim.list_extend(jar_patterns, { - java_test_path .. "/extension/server/*.jar", + vim.fn.expand "$MASON/share/java-test/*.jar", }) end for _, jar_pattern in ipairs(jar_patterns) do diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua index 408e9858..5510a8a8 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -196,7 +196,7 @@ return { 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) + 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 diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index ad1e05dd..d6731e2b 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -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 = vim.fs.normalize(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) From 759e410984f4c690c35890c278cf5478461d1808 Mon Sep 17 00:00:00 2001 From: Iordanis Petkakis <12776461+dpetka2001@users.noreply.github.com> Date: Wed, 14 May 2025 12:10:32 +0300 Subject: [PATCH 4/8] remove unnecessary paths after William's suggestions --- lua/lazyvim/plugins/extras/lang/java.lua | 8 +++----- lua/lazyvim/plugins/extras/lang/php.lua | 5 ++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/java.lua b/lua/lazyvim/plugins/extras/lang/java.lua index 2548344e..9e5047cf 100644 --- a/lua/lazyvim/plugins/extras/lang/java.lua +++ b/lua/lazyvim/plugins/extras/lang/java.lua @@ -87,7 +87,7 @@ return { opts = function() local cmd = { vim.fn.exepath("jdtls") } if LazyVim.has("mason.nvim") then - local lombok_jar = vim.fn.expand "$MASON/share/jdtls/lombok.jar" + local lombok_jar = vim.fn.expand("$MASON/share/jdtls/lombok.jar") table.insert(cmd, string.format("--jvm-arg=-javaagent:%s", lombok_jar)) end return { @@ -150,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_path = LazyVim.get_pkg_path("java-debug-adapter") local jar_patterns = { - vim.fn.expand "$MASON/share/java-debug-adapter/com.microsoft.java.debug.plugin-*.jar", + vim.fn.expand("$MASON/share/java-debug-adapter/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_path = LazyVim.get_pkg_path("java-test") vim.list_extend(jar_patterns, { - vim.fn.expand "$MASON/share/java-test/*.jar", + vim.fn.expand("$MASON/share/java-test/*.jar"), }) end for _, jar_pattern in ipairs(jar_patterns) do diff --git a/lua/lazyvim/plugins/extras/lang/php.lua b/lua/lazyvim/plugins/extras/lang/php.lua index 616de783..04469223 100644 --- a/lua/lazyvim/plugins/extras/lang/php.lua +++ b/lua/lazyvim/plugins/extras/lang/php.lua @@ -48,11 +48,10 @@ return { optional = true, opts = function() local dap = require("dap") - local path = LazyVim.get_pkg_path("php-debug-adapter") dap.adapters.php = { type = "executable", - command = "node", - args = { path .. "/extension/out/phpDebug.js" }, + command = "php-debug-adapter", + args = {}, } end, }, From 060b7ca704123adc494d09ee70158759c0eaf93a Mon Sep 17 00:00:00 2001 From: TheDSCPL Date: Wed, 14 May 2025 02:29:56 +0000 Subject: [PATCH 5/8] Improve mason deps' assets resolution --- lua/lazyvim/plugins/extras/lang/php.lua | 2 +- lua/lazyvim/plugins/extras/lang/rust.lua | 10 +++------- tests/extras/extra_spec.lua | 7 ++++++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/php.lua b/lua/lazyvim/plugins/extras/lang/php.lua index 04469223..c7827b88 100644 --- a/lua/lazyvim/plugins/extras/lang/php.lua +++ b/lua/lazyvim/plugins/extras/lang/php.lua @@ -50,7 +50,7 @@ return { local dap = require("dap") dap.adapters.php = { type = "executable", - command = "php-debug-adapter", + command = vim.fn.exepath("php-debug-adapter"), args = {}, } end, diff --git a/lua/lazyvim/plugins/extras/lang/rust.lua b/lua/lazyvim/plugins/extras/lang/rust.lua index 027f49b2..b5da242e 100644 --- a/lua/lazyvim/plugins/extras/lang/rust.lua +++ b/lua/lazyvim/plugins/extras/lang/rust.lua @@ -111,13 +111,9 @@ return { }, config = function(_, opts) if LazyVim.has("mason.nvim") then - 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") - if uname == "Linux" then - library_path = package_path .. "/extension/lldb/lib/liblldb.so" - end + local codelldb = vim.fn.exepath("codelldb") + local codelldb_lib_ext = io.popen("uname"):read("*l") == "Linux" and ".so" or ".dylib" + local library_path = vim.fn.expand("$MASON/opt/lldb/lib/liblldb" .. codelldb_lib_ext) opts.dap = { adapter = require("rustaceanvim.config").get_codelldb_adapter(codelldb, library_path), } diff --git a/tests/extras/extra_spec.lua b/tests/extras/extra_spec.lua index a6781bde..3bd27d34 100644 --- a/tests/extras/extra_spec.lua +++ b/tests/extras/extra_spec.lua @@ -26,7 +26,12 @@ describe("Extra", function() return not vim.tbl_contains(ignore, extra.modname) end, extras) - local lsp_to_pkg = require("mason-lspconfig").get_mappings().lspconfig_to_package + local lsp_to_pkg = {} + if vim.fn.has("nvim-0.11") == 1 then + lsp_to_pkg = require("mason-lspconfig.mappings").get_mason_map().lspconfig_to_package + else + lsp_to_pkg = require("mason-lspconfig.mappings.server").lspconfig_to_package + end local tsspec = Plugin.Spec.new({ import = "lazyvim.plugins.treesitter", From 65306ceff474c407d472e8950e481e96e6c05f68 Mon Sep 17 00:00:00 2001 From: TheDSCPL Date: Wed, 14 May 2025 02:32:25 +0000 Subject: [PATCH 6/8] Improve path joining in LazyVim.get_pkg_path --- lua/lazyvim/plugins/extras/lang/php.lua | 2 +- lua/lazyvim/util/init.lua | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/php.lua b/lua/lazyvim/plugins/extras/lang/php.lua index c7827b88..04469223 100644 --- a/lua/lazyvim/plugins/extras/lang/php.lua +++ b/lua/lazyvim/plugins/extras/lang/php.lua @@ -50,7 +50,7 @@ return { local dap = require("dap") dap.adapters.php = { type = "executable", - command = vim.fn.exepath("php-debug-adapter"), + command = "php-debug-adapter", args = {}, } end, diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index d6731e2b..339fdadb 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -254,10 +254,17 @@ function M.get_pkg_path(pkg, path, opts) opts.warn = opts.warn == nil and true or opts.warn path = path or "" local ret = vim.fs.normalize(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) - ) + if opts.warn then + vim.schedule(function() + if not require("lazy.core.config").headless() and not vim.loop.fs_stat(ret) then + M.warn( + ("Mason package path not found for **%s**:\n- `%s`\nYou may need to force update the package."):format( + pkg, + path + ) + ) + end + end) end return ret end From db31669abdb7e23ecf863d43d73cd73b4de7ed66 Mon Sep 17 00:00:00 2001 From: Iordanis Petkakis <12776461+dpetka2001@users.noreply.github.com> Date: Sat, 7 Jun 2025 15:53:13 +0300 Subject: [PATCH 7/8] Some more fixes Take into account when `server_opts.enabled = false` to add the server into `exclude_automatic_enable`, since `configure(server)` won't execute for that. Also `return true` for `opts.setup` to be in accordance with the rest of `configure` function and remove `server_opts.enabled` conditional check from `configure`, since it will only execute when `server_opts.enabled ~= false` either way. --- lua/lazyvim/plugins/lsp/init.lua | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua index 5510a8a8..15f41e91 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -207,17 +207,14 @@ return { local server_opts = vim.tbl_deep_extend("force", { capabilities = vim.deepcopy(capabilities), }, servers[server] or {}) - if server_opts.enabled == false then - return - end if opts.setup[server] then if opts.setup[server](server, server_opts) then - return + return true end elseif opts.setup["*"] then if opts.setup["*"](server, server_opts) then - return + return true end end if vim.fn.has("nvim-0.11") == 1 then @@ -249,6 +246,8 @@ return { else ensure_installed[#ensure_installed + 1] = server end + else + exclude_automatic_enable[#exclude_automatic_enable + 1] = server end end end @@ -325,8 +324,4 @@ return { end) end, }, - - -- pin to v1 for now - { "mason-org/mason.nvim", version = "^1.0.0" }, - { "mason-org/mason-lspconfig.nvim", version = "^1.0.0" }, } From dc5100e8432be8d11f24fefb46a18d80487747ac Mon Sep 17 00:00:00 2001 From: Iordanis Petkakis <12776461+dpetka2001@users.noreply.github.com> Date: Sat, 7 Jun 2025 16:26:44 +0300 Subject: [PATCH 8/8] fix tests --- tests/extras/extra_spec.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/extras/extra_spec.lua b/tests/extras/extra_spec.lua index 3bd27d34..39c3e0c0 100644 --- a/tests/extras/extra_spec.lua +++ b/tests/extras/extra_spec.lua @@ -27,10 +27,10 @@ describe("Extra", function() end, extras) local lsp_to_pkg = {} - if vim.fn.has("nvim-0.11") == 1 then - lsp_to_pkg = require("mason-lspconfig.mappings").get_mason_map().lspconfig_to_package - else + if require("lazy.core.config").spec.plugins["mason-lspconfig.nvim"].version == "^1.0.0" then lsp_to_pkg = require("mason-lspconfig.mappings.server").lspconfig_to_package + else + lsp_to_pkg = require("mason-lspconfig.mappings").get_mason_map().lspconfig_to_package end local tsspec = Plugin.Spec.new({