This commit is contained in:
2025-05-31 03:32:58 -04:00
parent ef678f31fd
commit e830931ff4
41 changed files with 253 additions and 268 deletions

View File

@ -1,5 +1,7 @@
local misc = require("core.misc")
local map, auto = misc.map, misc.auto
-- FIXME: the following error is emmitted when starting up jdtls:
-- ERROR No LSP client found that supports vscode.java.resolveMainClass
local map, auto = core.misc.map, core.misc.auto
local ok, jdtls = pcall(require, "jdtls")
if not ok then
@ -8,20 +10,16 @@ if not ok then
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'),
"/mason/packages/java-debug-adapter")
local jdtls_install = core.mason.get_pkg_path("jdtls")
local java_dap_install = core.mason.get_pkg_path("java-debug-adapter")
-- make sure to check if things with 💀 need updating
local config = {
cmd = {
"/usr/lib/jvm/openjdk21/bin/java", -- 💀
"-jar", -- 💀
vim.fn.glob(jdtls_install.."/plugins/org.eclipse.equinox.launcher_*.jar"),
"-configuration", jdtls_install.."/config_linux",
vim.fn.glob(vim.fs.joinpath(jdtls_install, "plugins/org.eclipse.equinox.launcher_*.jar")),
"-configuration", jdtls_install.."config_linux",
"-data", vim.fn.stdpath("cache").."/nvim-jdtls",
"--add-modules=ALL-SYSTEM",
@ -88,15 +86,13 @@ local config = {
init_options = {
bundles = {
vim.fs.joinpath(java_dap_install,
vim.fn.glob("/extension/server/com.microsoft.java.debug.plugin-*.jar",
vim.fn.glob("extension/server/com.microsoft.java.debug.plugin-*.jar",
true)
)
}
}
}
-- 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"),
@ -150,20 +146,20 @@ local function version_check()
if out.code ~= 0 then
vim.notify(string.format(
"java version check failed: exit code %s", out.code),
vim.log.levels.ERROR, { title = misc.appid })
vim.log.levels.ERROR, { title = core.misc.appid })
vim.notify(string.format(
"%s", vim.inspect(out.stdout)),
vim.log.levels.ERROR, { title = misc.appid })
vim.log.levels.ERROR, { title = core.misc.appid })
return false
elseif not v then
vim.notify("no java version info found", vim.log.levels.ERROR,
{ title = misc.appid })
{ title = core.misc.appid })
return false
elseif v.major < 21 then
vim.notify(string.format(
"java version %s < 21.0.0 Cannot run jdtls, bailing out",
v[1].."."..v[2].."."..v[3]),
vim.log.levels.ERROR, { title = misc.appid })
vim.log.levels.ERROR, { title = core.misc.appid })
return false
end