chore: some improvements
This commit is contained in:
parent
70f5f3c859
commit
d69fb57aa6
10 changed files with 182 additions and 59 deletions
|
|
@ -7,3 +7,4 @@ vim.keymap.set("n", "<M-BS>", "<CMD>e#<CR>", { desc = "Previous file" })
|
|||
|
||||
require("config.maps.maven")
|
||||
require("config.maps.cpp")
|
||||
require("config.maps.vue")
|
||||
|
|
|
|||
26
lua/config/maps/vue.lua
Normal file
26
lua/config/maps/vue.lua
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
-- Function to check if pom.xml exists in current or parent directories
|
||||
local function is_npm_project()
|
||||
local uv = vim.loop
|
||||
local dir = uv.fs_realpath(vim.fn.expand("%:p:h"))
|
||||
while dir do
|
||||
if uv.fs_stat(dir .. "/package-lock.json") 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 = "typescript",
|
||||
callback = function()
|
||||
if is_npm_project() then
|
||||
vim.keymap.set("n", "<leader><F5>", "<CMD>! npm run format<CR>", { desc = "Prettier" })
|
||||
end
|
||||
end,
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue