feat: load additional autocommands.
This commit is contained in:
parent
790a67bacc
commit
e0003847ba
@ -62,7 +62,10 @@
|
|||||||
enableTreesitter = true;
|
enableTreesitter = true;
|
||||||
enableFormat = true;
|
enableFormat = true;
|
||||||
|
|
||||||
lua.enable = true;
|
lua = {
|
||||||
|
enable = true;
|
||||||
|
lsp.lazydev.enable = true;
|
||||||
|
};
|
||||||
# python = {
|
# python = {
|
||||||
# enable = true;
|
# enable = true;
|
||||||
# format.type = "black-and-isort";
|
# format.type = "black-and-isort";
|
||||||
@ -172,6 +175,8 @@
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
extraLuaFiles = [./nvim/autocommands.lua];
|
||||||
|
|
||||||
extraPlugins = with pkgs.vimPlugins; {
|
extraPlugins = with pkgs.vimPlugins; {
|
||||||
harpoon = {
|
harpoon = {
|
||||||
package = harpoon2;
|
package = harpoon2;
|
||||||
|
16
modules/home-manager/nvim/autocommands.lua
Normal file
16
modules/home-manager/nvim/autocommands.lua
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
local autocmd = vim.api.nvim_create_autocmd
|
||||||
|
local function augroup(name)
|
||||||
|
return vim.api.nvim_create_augroup("crony_" .. name, { clear = true })
|
||||||
|
end
|
||||||
|
|
||||||
|
-- [[ Auto create parent directory if it doesn't exist ]]
|
||||||
|
autocmd({ "BufWritePre" }, {
|
||||||
|
group = augroup("auto_create_dir"),
|
||||||
|
callback = function(event)
|
||||||
|
if event.match:match("^%w%w+://") then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local file = vim.loop.fs_realpath(event.match) or event.match
|
||||||
|
vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p")
|
||||||
|
end,
|
||||||
|
})
|
Loading…
x
Reference in New Issue
Block a user