Initial Commit
This commit is contained in:
commit
18da9560c6
31 changed files with 769 additions and 0 deletions
27
lua/config/maps/maven.lua
Normal file
27
lua/config/maps/maven.lua
Normal 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,
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue