diff --git a/lua/lazyvim/plugins/extras/lang/java.lua b/lua/lazyvim/plugins/extras/lang/java.lua index f03e2ab7..97e37ef5 100644 --- a/lua/lazyvim/plugins/extras/lang/java.lua +++ b/lua/lazyvim/plugins/extras/lang/java.lua @@ -190,30 +190,40 @@ return { local client = vim.lsp.get_client_by_id(args.data.client_id) if client and client.name == "jdtls" then local wk = require("which-key") - wk.register({ - ["cx"] = { name = "+extract" }, - ["cxv"] = { require("jdtls").extract_variable_all, "Extract Variable" }, - ["cxc"] = { require("jdtls").extract_constant, "Extract Constant" }, - ["gs"] = { require("jdtls").super_implementation, "Goto Super" }, - ["gS"] = { require("jdtls.tests").goto_subjects, "Goto Subjects" }, - ["co"] = { require("jdtls").organize_imports, "Organize Imports" }, - }, { mode = "n", buffer = args.buf }) - wk.register({ - ["c"] = { name = "+code" }, - ["cx"] = { name = "+extract" }, - ["cxm"] = { - [[lua require('jdtls').extract_method(true)]], - "Extract Method", + wk.add({ + { + mode = "n", + buffer = args.buf, + { "cx", group = "extract" }, + { "cxv", require("jdtls").extract_variable_all, desc = "Extract Variable" }, + { "cxc", require("jdtls").extract_constant, desc = "Extract Constant" }, + { "gs", require("jdtls").super_implementation, desc = "Goto Super" }, + { "gS", require("jdtls.tests").goto_subjects, desc = "Goto Subjects" }, + { "co", require("jdtls").organize_imports, desc = "Organize Imports" }, }, - ["cxv"] = { - [[lua require('jdtls').extract_variable_all(true)]], - "Extract Variable", + }) + wk.add({ + { + mode = "v", + buffer = args.buf, + { "cx", group = "extract" }, + { + "cxm", + [[lua require('jdtls').extract_method(true)]], + desc = "Extract Method", + }, + { + "cxv", + [[lua require('jdtls').extract_variable_all(true)]], + desc = "Extract Variable", + }, + { + "cxc", + [[lua require('jdtls').extract_constant(true)]], + desc = "Extract Constant", + }, }, - ["cxc"] = { - [[lua require('jdtls').extract_constant(true)]], - "Extract Constant", - }, - }, { mode = "v", buffer = args.buf }) + }) if opts.dap and LazyVim.has("nvim-dap") and mason_registry.is_installed("java-debug-adapter") then -- custom init for Java debugger @@ -223,26 +233,32 @@ return { -- Java Test require Java debugger to work if opts.test and mason_registry.is_installed("java-test") then -- custom keymaps for Java test runner (not yet compatible with neotest) - wk.register({ - ["t"] = { name = "+test" }, - ["tt"] = { - function() - require("jdtls.dap").test_class({ - config_overrides = type(opts.test) ~= "boolean" and opts.test.config_overrides or nil, - }) - end, - "Run All Test", + wk.add({ + { + mode = "n", + buffer = args.buf, + { "t", group = "test" }, + { + "tt", + function() + require("jdtls.dap").test_class({ + config_overrides = type(opts.test) ~= "boolean" and opts.test.config_overrides or nil, + }) + end, + desc = "Run All Test", + }, + { + "tr", + function() + require("jdtls.dap").test_nearest_method({ + config_overrides = type(opts.test) ~= "boolean" and opts.test.config_overrides or nil, + }) + end, + desc = "Run Nearest Test", + }, + { "tT", require("jdtls.dap").pick_test, desc = "Run Test" }, }, - ["tr"] = { - function() - require("jdtls.dap").test_nearest_method({ - config_overrides = type(opts.test) ~= "boolean" and opts.test.config_overrides or nil, - }) - end, - "Run Nearest Test", - }, - ["tT"] = { require("jdtls.dap").pick_test, "Run Test" }, - }, { mode = "n", buffer = args.buf }) + }) end end