need I say what type of commit this is?

*kitchen sink*
This commit is contained in:
2025-05-18 13:03:31 -05:00
parent 77130d61af
commit 450750835a
9 changed files with 752 additions and 48 deletions

View File

@ -1,7 +1,15 @@
local misc = require("core.misc")
local map, auto = misc.map, misc.auto
local jdtls = require("jdtls")
local ok, jdtls = pcall(require, "jdtls")
if not ok then
vim.notify("jdtls not loaded, can't setup jdtls lsp or dap",
vim.log.levels.INFO, {})
return
end
-- HACK: I don't like using path concatination there *should* be a way to get
-- the path from mason
local jdtls_install = vim.fs.joinpath(vim.fn.stdpath('data'),
"/mason/packages/jdtls")
local java_dap_install = vim.fs.joinpath(vim.fn.stdpath('data'),
@ -24,7 +32,7 @@ local config = {
"-Dlog.level=ALL",
"-Dlog.protocol=true",
"-Dosgi.bundles.defaultStartLevel=4",
"-Xmx1G",
"-Xmx1G"
},
root_dir = vim.fs.dirname(vim.fs.find({
@ -49,6 +57,7 @@ local config = {
map("x", "crc", function() jdtls.extract_constant(true) end, opts)
map("x", "crm", function() jdtls.extract_method(true) end, opts)
-- do some refreshes often because I don't trust jdtls
pcall(vim.lsp.codelens.refresh)
auto("BufWritePost", {
buffer = bufnr,
@ -59,7 +68,14 @@ local config = {
})
-- setup nvim-dap
require("dap").adapters.java = nil -- remove any old java adapters
local ok, dap = pcall(require, "dap")
if not ok then
vim.notify("dap not loaded can't setup dap for jdtls",
vim.log.levels.INFO, {})
return
end
dap.adapters.java = nil -- remove any old java adapters
jdtls.setup_dap({ hotcodereplace = "auto" })
require("jdtls.dap").setup_dap_main_class_configs()
end,
@ -79,6 +95,8 @@ local config = {
}
}
-- HACK: same hack as before
-- generate the path to the java file(s)
---@type string?
local cache_path = vim.fs.joinpath(vim.fn.stdpath("cache"),
@ -95,20 +113,18 @@ end
--- build a cache of the JavaVersion code
local function build_cache()
-- check if we have javac
vim.system({ "javac" }, {}, function(out)
if out.code == 127 then
cache_path = nil
return
end
if vim.fn.executable("javac") ~= 1 then
cache_path = nil
return
end
-- compile our code
vim.system({ "javac", src_path, "-d", vim.fn.stdpath("cache"), }, {},
function(out)
if out.code ~= 0 then
cache_path = nil
end
end)
end)
-- compile our code
vim.system({ "javac", src_path, "-d", vim.fn.stdpath("cache"), }, {},
function(out)
if out.code ~= 0 then
cache_path = nil
end
end)
end
-- check if we have a compiled version of JavaVersion