Some more jdtls and dap config changes

master
Wynd 2026-03-17 01:44:24 +02:00
parent 3b16716986
commit 259a009602
3 changed files with 58 additions and 6 deletions

View File

@ -1,6 +1,5 @@
local map = vim.keymap.set
local jdtls = require("jdtls")
local dap = require("dap")
local telescope = require("telescope.builtin")
local comment_api = require("Comment.api")
@ -16,11 +15,6 @@ map({ "n", "v", "x" }, "<Del>", '"_x')
-- filthy casual save keybind
map({ "n", "i", "v" }, "<C-s>", function()
vim.cmd("w")
local has_dap_session = dap.session() ~= nil
-- If jdtls is available and dap is running also run the hotcode swap automatically
if jdtls and has_dap_session then
vim.cmd("JdtUpdateHotcode")
end
end, { desc = "File Save" })
-- easy way to close the current buffer
map("n", "<C-X>", "<cmd>bd!<cr>", { desc = "Close Buffer" })

View File

@ -1,5 +1,31 @@
return {
{
"mfussenegger/nvim-dap",
config = function()
local dap = require("dap")
-- dap.listeners.before.launch.build = function(session)
-- local config = session.config
--
-- if config.preLaunchTask == "prepareRunClientCompile" then
-- vim.system({ "./gradlew", "prepareRunClientCompile" }):wait()
-- end
-- end
-- No I'm not gonna fucking use overseer just to run a fucking script
local orig_run = dap.run
dap.run = function(config)
vim.notify("Running task " .. config.preLaunchTask)
if config.preLaunchTask == "prepareRunClientCompile" then
vim.system({ "./gradlew", "prepareRunClientCompile" }, {}, function()
vim.schedule(function()
orig_run(config)
end)
end)
else
orig_run(config)
end
end
end,
},
}

View File

@ -64,8 +64,19 @@ return {
root_dir = vim.fs.root(0, { "gradlew", ".git", "mvnw" }),
on_attach = function(_, _)
require("jdtls").setup_dap({ hotcodereplace = "auto" })
require("jdtls.dap").setup_dap_main_class_configs()
end,
settings = {
java = {
autobuild = { enabled = true },
configuration = {
updateBuildConfiguration = "interactive",
},
format = {
enable = false,
settings = {
@ -75,6 +86,27 @@ return {
profile = "GoogleStyle",
},
},
saveActions = {
-- organizeImports = true,
cleanup = true,
},
cleanup = {
actions = {
"addOverride",
"addDeprecated",
"qualifyMembers",
"qualifyStaticMembers",
-- "addFinalModifier",
"lambdaExpression",
"lambdaExpressionFromAnonymousClass",
"switchExpression",
"stringConcatToTextBlock",
"instanceofPatternMatch",
"useSwitchForInstanceofPattern",
},
},
},
},