mirror of
https://github.com/prurigro/darkcloud-nvimconfig.git
synced 2024-11-22 11:44:10 -05:00
Redetect filetype after saving as new name + wrap autocmd with check
This commit is contained in:
parent
479494f636
commit
38819aedae
1 changed files with 18 additions and 10 deletions
|
@ -84,17 +84,25 @@
|
||||||
set timeout timeoutlen=500 "how long before timing out for mappings
|
set timeout timeoutlen=500 "how long before timing out for mappings
|
||||||
set ttimeout ttimeoutlen=100 "how long before timing out for terminal key codes
|
set ttimeout ttimeoutlen=100 "how long before timing out for terminal key codes
|
||||||
|
|
||||||
"enable the auto-creation of missing folders in a save path
|
if has('autocmd')
|
||||||
if !exists('*s:MakeNewDir')
|
"enable the auto-creation of missing folders in a save path
|
||||||
function s:MakeNewDir(fullpath, buf)
|
if !exists('*s:MakeNewDir')
|
||||||
if empty(getbufvar(a:buf,'&buftype')) && a:fullpath!~#'\v^\w+\:\/'
|
function s:MakeNewDir(fullpath, buf)
|
||||||
let dirpath=fnamemodify(a:fullpath,':h')
|
if empty(getbufvar(a:buf,'&buftype')) && a:fullpath!~#'\v^\w+\:\/'
|
||||||
if !isdirectory(dirpath)|call mkdir(dirpath,'p')|endif
|
let dirpath=fnamemodify(a:fullpath,':h')
|
||||||
endif
|
if !isdirectory(dirpath)|call mkdir(dirpath,'p')|endif
|
||||||
endfunction
|
endif
|
||||||
augroup WriteDir
|
endfunction
|
||||||
|
augroup WriteDir
|
||||||
|
autocmd!
|
||||||
|
autocmd BufWritePre * :call s:MakeNewDir(expand('<afile>'),+expand('<abuf>'))
|
||||||
|
augroup END
|
||||||
|
endif
|
||||||
|
|
||||||
|
"update the current filetype when a file is renamed
|
||||||
|
augroup RenameCheckFiletype
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufWritePre * :call s:MakeNewDir(expand('<afile>'),+expand('<abuf>'))
|
autocmd BufFilePost * filetype detect
|
||||||
augroup END
|
augroup END
|
||||||
endif
|
endif
|
||||||
"}}}
|
"}}}
|
||||||
|
|
Loading…
Reference in a new issue