feat(nvim): add autocmd to create a new dir when saving a file inside (removed mkdir.nvim extra)
This commit is contained in:
1 parent
bff8305e3f
commit
ff77cde1c7
7 files changed
+103
-54
No files matched your search
@@ -128,3 +128,15 @@ au({ "BufLeave", "FocusLost", "InsertEnter", "CmdlineEnter", "WinLeave" }, {
|
||||
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,
|
||||
})
|
||||
Reference in new issue
Block a user