dotfiles-nvim/lua/plugins/languages/java.lua

26 lines
606 B
Lua
Raw Normal View History

2024-12-16 15:36:33 +01:00
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,
}