Skip to content

Commit a7d158d

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 99c746c commit a7d158d

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

autoload/mmtemplates/core.vim

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1664,7 +1664,16 @@ 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+
1671+
if filereadable(templatepath_tmp)
1672+
let templatefile = templatepath_tmp
1673+
else
1674+
let templatefile = s:ConcatNormalizedFilename ( s:t_runtime.state_stack[-1].current_path, templatefile )
1675+
endif
1676+
unlet templatepath_tmp
16681677
endif
16691678
"
16701679
" file does not exists or was already visited?

0 commit comments

Comments
 (0)