✨ feat(nvim): add autocmd to create a new dir when saving a file inside (removed mkdir.nvim extra)
This commit is contained in:
parent
046c754215
commit
d2d9e50a57
3 changed files with 14 additions and 5 deletions
|
@ -106,4 +106,5 @@
|
||||||
"NEWS.md": "2123"
|
"NEWS.md": "2123"
|
||||||
},
|
},
|
||||||
"version": 2
|
"version": 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,3 +128,15 @@ au({ "BufLeave", "FocusLost", "InsertEnter", "CmdlineEnter", "WinLeave" }, {
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Create a dir when saving a file if it doesnt exist
|
||||||
|
au("BufWritePre", {
|
||||||
|
group = ag("auto_create_dir", { clear = true }),
|
||||||
|
callback = function(args)
|
||||||
|
if args.match:match("^%w%w+://") then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local file = vim.loop.fs_realpath(args.match) or args.match
|
||||||
|
vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
return {
|
|
||||||
"jghauser/mkdir.nvim",
|
|
||||||
event = "VeryLazy",
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue