Skip to content

Commit 84114bb

Browse files
committed
feat(template): check whether the first item in runtimepath, e.g. /home/dchen/.vim/templates has the template file
So the setting won't get overwritten when updating the bash-support
1 parent 8bbd20a commit 84114bb

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

autoload/mmtemplates/core.vim

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1664,7 +1664,15 @@ function! s:IncludeFile ( templatefile, ... )
16641664
if read_abs
16651665
let templatefile = s:ConcatNormalizedFilename ( templatefile )
16661666
else
1667-
let templatefile = s:ConcatNormalizedFilename ( s:t_runtime.state_stack[-1].current_path, templatefile )
1667+
" check whether the first item in runtimepath, e.g. $HOME/.vim/templates has the template file
1668+
let templatepath_tmp = s:ConcatNormalizedFilename( split(&runtimepath, ',')[0], "templates")
1669+
let templatepath_tmp = s:ConcatNormalizedFilename( templatepath_tmp, templatefile)
1670+
if filereadable(templatepath_tmp)
1671+
let templatefile = templatepath_tmp
1672+
else
1673+
let templatefile = s:ConcatNormalizedFilename ( s:t_runtime.state_stack[-1].current_path, templatefile )
1674+
endif
1675+
unlet templatepath_tmp
16681676
endif
16691677
"
16701678
" file does not exists or was already visited?

0 commit comments

Comments
 (0)