feat(nvim): add autocmd to create a new dir when saving a file inside (removed mkdir.nvim extra)

This commit is contained in:
Sergio Laín 2024-02-10 01:52:50 +01:00
parent 046c754215
commit d2d9e50a57
No known key found for this signature in database
GPG key ID: 14C9B8080681777B
3 changed files with 14 additions and 5 deletions

View file

@ -106,4 +106,5 @@
"NEWS.md": "2123" "NEWS.md": "2123"
}, },
"version": 2 "version": 2
} }

View file

@ -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,
})

View file

@ -1,4 +0,0 @@
return {
"jghauser/mkdir.nvim",
event = "VeryLazy",
}