mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-21 16:39:06 +02:00
fix(java): only setup debug adapter config if mason is installed (for real this time) (#5014)
## Description This one *actually* fixes the issue, sorry about my previous PR.
This commit is contained in:
parent
aad0edbf74
commit
5b1b6b29d7
1 changed files with 54 additions and 60 deletions
|
@ -146,14 +146,10 @@ return {
|
|||
config = function(_, opts)
|
||||
-- Find the extra bundles that should be passed on the jdtls command-line
|
||||
-- if nvim-dap is enabled with java debug/test.
|
||||
local mason_registry = require("mason-registry")
|
||||
local bundles = {} ---@type string[]
|
||||
if
|
||||
LazyVim.has("mason.nvim")
|
||||
and opts.dap
|
||||
and LazyVim.has("nvim-dap")
|
||||
and mason_registry.is_installed("java-debug-adapter")
|
||||
then
|
||||
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 = {
|
||||
|
@ -173,7 +169,7 @@ return {
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
local function attach_jdtls()
|
||||
local fname = vim.api.nvim_buf_get_name(0)
|
||||
|
||||
|
@ -245,12 +241,9 @@ return {
|
|||
},
|
||||
})
|
||||
|
||||
if
|
||||
LazyVim.has("mason.nvim")
|
||||
and opts.dap
|
||||
and LazyVim.has("nvim-dap")
|
||||
and mason_registry.is_installed("java-debug-adapter")
|
||||
then
|
||||
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
|
||||
-- custom init for Java debugger
|
||||
require("jdtls").setup_dap(opts.dap)
|
||||
require("jdtls.dap").setup_dap_main_class_configs(opts.dap_main)
|
||||
|
@ -286,6 +279,7 @@ return {
|
|||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- User can set additional keymaps in opts.on_attach
|
||||
if opts.on_attach then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue