From a7d158d408db6ceecdc08d64c51b5494f5552f48 Mon Sep 17 00:00:00 2001 From: Ding-Yi Chen Date: Mon, 2 Jun 2025 17:17:35 +1000 Subject: [PATCH] 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 --- autoload/mmtemplates/core.vim | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/autoload/mmtemplates/core.vim b/autoload/mmtemplates/core.vim index f941869..974f1c6 100644 --- a/autoload/mmtemplates/core.vim +++ b/autoload/mmtemplates/core.vim @@ -1664,7 +1664,16 @@ function! s:IncludeFile ( templatefile, ... ) if read_abs let templatefile = s:ConcatNormalizedFilename ( templatefile ) else - let templatefile = s:ConcatNormalizedFilename ( s:t_runtime.state_stack[-1].current_path, templatefile ) + " check whether the first item in runtimepath, e.g. $HOME/.vim/templates has the template file + let templatepath_tmp = s:ConcatNormalizedFilename( split(&runtimepath, ',')[0], "templates") + let templatepath_tmp = s:ConcatNormalizedFilename( templatepath_tmp, templatefile) + + if filereadable(templatepath_tmp) + let templatefile = templatepath_tmp + else + let templatefile = s:ConcatNormalizedFilename ( s:t_runtime.state_stack[-1].current_path, templatefile ) + endif + unlet templatepath_tmp endif " " file does not exists or was already visited?