mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-13 19:04:36 +02:00
Merge dc5100e843
into 25abbf546d
This commit is contained in:
commit
01249b5865
6 changed files with 86 additions and 56 deletions
|
@ -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 = vim.fn.expand("$MASON/share/jdtls/lombok.jar")
|
||||
table.insert(cmd, string.format("--jvm-arg=-javaagent:%s", lombok_jar))
|
||||
end
|
||||
return {
|
||||
|
@ -151,17 +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 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_pkg = mason_registry.get_package("java-test")
|
||||
local java_test_path = java_test_pkg:get_install_path()
|
||||
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
|
||||
|
|
|
@ -48,11 +48,10 @@ return {
|
|||
optional = true,
|
||||
opts = function()
|
||||
local dap = require("dap")
|
||||
local path = require("mason-registry").get_package("php-debug-adapter"):get_install_path()
|
||||
dap.adapters.php = {
|
||||
type = "executable",
|
||||
command = "node",
|
||||
args = { path .. "/extension/out/phpDebug.js" },
|
||||
command = "php-debug-adapter",
|
||||
args = {},
|
||||
}
|
||||
end,
|
||||
},
|
||||
|
|
|
@ -111,13 +111,9 @@ return {
|
|||
},
|
||||
config = function(_, opts)
|
||||
if LazyVim.has("mason.nvim") then
|
||||
local package_path = require("mason-registry").get_package("codelldb"):get_install_path()
|
||||
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),
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
{ "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()
|
||||
---@class PluginLspOpts
|
||||
|
@ -188,57 +192,84 @@ return {
|
|||
opts.capabilities or {}
|
||||
)
|
||||
|
||||
local function setup(server)
|
||||
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
|
||||
end
|
||||
elseif opts.setup["*"] then
|
||||
if opts.setup["*"](server, server_opts) then
|
||||
return
|
||||
end
|
||||
end
|
||||
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
|
||||
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)
|
||||
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 {})
|
||||
|
||||
if opts.setup[server] then
|
||||
if opts.setup[server](server, server_opts) then
|
||||
return true
|
||||
end
|
||||
elseif opts.setup["*"] then
|
||||
if opts.setup["*"](server, server_opts) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
if vim.fn.has("nvim-0.11") == 1 then
|
||||
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
|
||||
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[]
|
||||
for server, server_opts in pairs(servers) do
|
||||
if server_opts then
|
||||
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
|
||||
else
|
||||
exclude_automatic_enable[#exclude_automatic_enable + 1] = server
|
||||
end
|
||||
end
|
||||
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
|
||||
|
@ -259,6 +290,7 @@ return {
|
|||
|
||||
"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" },
|
||||
|
@ -292,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" },
|
||||
}
|
||||
|
|
|
@ -253,11 +253,18 @@ 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
|
||||
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)
|
||||
)
|
||||
local ret = vim.fs.normalize(root .. "/packages/" .. 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
|
||||
|
|
|
@ -26,7 +26,12 @@ describe("Extra", function()
|
|||
return not vim.tbl_contains(ignore, extra.modname)
|
||||
end, extras)
|
||||
|
||||
local lsp_to_pkg = require("mason-lspconfig.mappings.server").lspconfig_to_package
|
||||
local lsp_to_pkg = {}
|
||||
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({
|
||||
import = "lazyvim.plugins.treesitter",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue