mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
feat: create parent dir of current file if it does not exist
This commit is contained in:
parent
665250fe58
commit
6fd7155787
@ -207,3 +207,12 @@ function! utils#add_pack(name) abort
|
|||||||
|
|
||||||
return l:status
|
return l:status
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Create the parent dir for current file if it does not exist
|
||||||
|
function! utils#may_create_dir(path) abort
|
||||||
|
let l:parent_dir = fnamemodify(a:path, ':p:h')
|
||||||
|
|
||||||
|
if !isdirectory(l:parent_dir)
|
||||||
|
call mkdir(l:parent_dir, "p")
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|||||||
@ -118,3 +118,8 @@ augroup packer_auto_compile
|
|||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufWritePost */nvim/lua/plugins.lua source <afile> | PackerCompile
|
autocmd BufWritePost */nvim/lua/plugins.lua source <afile> | PackerCompile
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
|
augroup auto_create_dir
|
||||||
|
autocmd!
|
||||||
|
autocmd BufWritePre * call utils#may_create_dir(expand("<afile>"))
|
||||||
|
augroup END
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user