Initial Commit

This commit is contained in:
Maurice Grönwoldt 2025-07-30 16:05:16 +02:00
commit 18da9560c6
No known key found for this signature in database
GPG key ID: FBB005FE74FEF996
31 changed files with 769 additions and 0 deletions

27
lua/config/maps/maven.lua Normal file
View file

@ -0,0 +1,27 @@
-- Function to check if pom.xml exists in current or parent directories
local function is_maven_project()
local uv = vim.loop
local dir = uv.fs_realpath(vim.fn.expand("%:p:h"))
while dir do
if uv.fs_stat(dir .. "/pom.xml") then
return true
end
local parent_dir = uv.fs_realpath(dir .. "/..")
if parent_dir == dir then
break
end
dir = parent_dir
end
return false
end
-- Create autocommand on FileType java or whatever filetype you want
vim.api.nvim_create_autocmd("FileType", {
pattern = "java",
callback = function()
if is_maven_project() then
vim.keymap.set("n", "<leader><F5>", "<CMD>! mvn clean install -DskipTests<CR>", { desc = "Build Java" })
vim.keymap.set("n", "<leader><F7>", "<CMD>! mvn spotless:apply<CR>", { desc = "Format Java" })
end
end,
})