From 7a79081892a097fdef3c25c21f0c446413dee4ba Mon Sep 17 00:00:00 2001 From: Mathias Fussenegger Date: Thu, 30 May 2024 15:15:44 +0200 Subject: [PATCH] Add dap configuration provider Depends on https://github.com/mfussenegger/nvim-dap/pull/1237 --- lua/jdtls/dap.lua | 23 +++++++++++++++++++++++ lua/jdtls/setup.lua | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lua/jdtls/dap.lua b/lua/jdtls/dap.lua index 9d6d1b9..d7c9eb4 100644 --- a/lua/jdtls/dap.lua +++ b/lua/jdtls/dap.lua @@ -711,6 +711,29 @@ function M.setup_dap(opts) end end dap.adapters.java = start_debug_adapter + + if dap.providers and dap.providers.configs then + dap.providers.configs["jdtls"] = function () + local co = coroutine.running() + local resumed = false + vim.defer_fn(function() + if not resumed then + resumed = true + coroutine.resume(co, {}) + vim.schedule(function() + vim.notify("Discovering main classes to debug took too long", vim.log.levels.INFO) + end) + end + end, 2000) + M.fetch_main_configs(nil, function(configs) + if not resumed then + resumed = true + coroutine.resume(co, configs) + end + end) + return coroutine.yield() + end + end end ---@class JdtSetupDapOpts ---@field config_overrides JdtDapConfig These will be used as default overrides for |jdtls.dap.test_class|, |jdtls.dap.test_nearest_method| and discovered main classes diff --git a/lua/jdtls/setup.lua b/lua/jdtls/setup.lua index b8774af..36e2761 100644 --- a/lua/jdtls/setup.lua +++ b/lua/jdtls/setup.lua @@ -202,7 +202,7 @@ local function extract_data_dir(bufnr) end ----@param client lsp.Client +---@param client vim.lsp.Client ---@param opts jdtls.start.opts local function add_commands(client, bufnr, opts) local function create_cmd(name, command, cmdopts)