1
0
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:
jdhao
2022-01-13 01:51:19 +08:00
parent 665250fe58
commit 6fd7155787
2 changed files with 14 additions and 0 deletions

View File

@@ -207,3 +207,12 @@ function! utils#add_pack(name) abort
return l:status
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