diff options
| author | jdhao <jdhao@hotmail.com> | 2022-08-20 13:50:23 +0800 |
|---|---|---|
| committer | jdhao <jdhao@hotmail.com> | 2022-08-20 13:50:23 +0800 |
| commit | 085c8017d8ed3c83d1f61306d6b42f460d2857bc (patch) | |
| tree | 275d40b627bf60635f9f912ec34de3b5e2adf5c9 /lua | |
| parent | efa7b215e7010de3d1d03cc3e4adbc5ca89f3b26 (diff) | |
update the autocmd for saving a file
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/utils.lua | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lua/utils.lua b/lua/utils.lua index ae9e0e9..3312479 100644 --- a/lua/utils.lua +++ b/lua/utils.lua @@ -15,13 +15,12 @@ function M.executable(name) return false end -function M.may_create_dir() - local fpath = fn.expand('<afile>') - local parent_dir = fn.fnamemodify(fpath, ":p:h") - local res = fn.isdirectory(parent_dir) +--- Create a dir if if does not exist +function M.may_create_dir(dir) + local res = fn.isdirectory(dir) if res == 0 then - fn.mkdir(parent_dir, 'p') + fn.mkdir(dir, 'p') end end |
