feat(languages): Configure java

This commit is contained in:
kalmenn 2024-12-16 15:36:33 +01:00
parent 199d202ddc
commit ad98de9170
Signed by: kalmenn
GPG key ID: F500055C44BC3834
2 changed files with 36 additions and 10 deletions

View file

@ -0,0 +1,25 @@
return {
"mfussenegger/nvim-jdtls",
opts = {
cmd = { "jdtls" },
},
ft = { "java" },
cond = function(_)
return vim.fn.executable("jdtls") ~= 0
and vim.fn.executable("python3") ~= 0
end,
config = function(_, opts)
if (opts.root_dir == nil) then
opts.root_dir = vim.fs.dirname(vim.fs.find({'gradlew', '.git', 'mvnw'}, { upward = true })[1])
end
vim.api.nvim_create_autocmd({ "FileType" }, {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(ev)
if (ev.match == "java") then
require("jdtls").start_or_attach(opts)
end
end,
})
end,
}