From cab4b138984cdd97fa31fc0cec9d0ec56ee0b57c Mon Sep 17 00:00:00 2001 From: Asou Chang Date: Fri, 31 May 2019 16:27:48 +0800 Subject: [PATCH] Let path of tags customizable --- doc/srcexpl.txt | 7 +++++++ plugin/srcexpl.vim | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/doc/srcexpl.txt b/doc/srcexpl.txt index f01526f..4d9313e 100644 --- a/doc/srcexpl.txt +++ b/doc/srcexpl.txt @@ -189,6 +189,13 @@ g:SrcExpl_updateTagsCmd *g:SrcExpl_updateTagsCmd* Default: "ctags --sort=foldcase -R ." +g:SrcExpl_tagsPath *g:SrcExpl_tagsPath* + This is the path which Source Explorer will attempt to load tags. It + can be either relative path or absolute path. + + Default: "tags" + + ------------------------------------------------------------------------------ KEY MAPPINGS *srcexpl-key-mappings* diff --git a/plugin/srcexpl.vim b/plugin/srcexpl.vim index dc14f81..329c064 100644 --- a/plugin/srcexpl.vim +++ b/plugin/srcexpl.vim @@ -222,6 +222,13 @@ if !exists('g:SrcExpl_updateTagsCmd') let g:SrcExpl_updateTagsCmd = 'ctags --sort=foldcase -R .' endif +" User interface to specify the tags file location +" relative path or absolute path, 'tags' as default +if !exists('g:SrcExpl_tagsPath') + let g:SrcExpl_tagsPath = "tags" +endif + + " User interface to update tags file artificially if !exists('g:SrcExpl_updateTagsKey') let g:SrcExpl_updateTagsKey = '' @@ -367,7 +374,7 @@ function! g:SrcExpl_UpdateTags() " Call the external 'ctags' utility program exe "!" . g:SrcExpl_updateTagsCmd " Rejudge the tags file if existed - if !filereadable("tags") + if !filereadable(g:SrcExpl_tagsPath) " Tell them what happened call SrcExpl_ReportErr("Execute 'ctags' utility program failed") return -1 @@ -384,7 +391,7 @@ function! g:SrcExpl_UpdateTags() " Found one successfully else " Is the tags file in the current directory ? - if tagfiles()[0] ==# "tags" + if tagfiles()[0] ==# g:SrcExpl_tagsPath " Prompt the current work directory echohl Question echo "SrcExpl: Updating 'tags' file in (". expand('%:p:h') . ")" @@ -1077,7 +1084,7 @@ function! SrcExpl_ListMultiDefs(list, len) endif " Is the tags file in the current directory ? - if tagfiles()[0] ==# "tags" + if tagfiles()[0] ==# g:SrcExpl_tagsPath " We'll get the operating system environment " in order to judge the slash type if s:SrcExpl_isWinOS == 1 @@ -1164,7 +1171,7 @@ function! SrcExpl_ViewOneDef(fpath, excmd) " The tags file is in the current directory and it " should be generated by 'ctags --sort=foldcase -R .' - if tagfiles()[0] ==# "tags" && a:fpath[0] == '.' + if tagfiles()[0] ==# g:SrcExpl_tagsPath && a:fpath[0] == '.' call SrcExpl_WinEdit(expand('%:p:h') . '/' . a:fpath) " Up to other directories else @@ -1493,7 +1500,7 @@ function! SrcExpl_Init() " Auto change current work directory exe "set autochdir" " Let Vim find the possible tags file - exe "set tags=tags;" + let &tags = g:SrcExpl_tagsPath " Set the actual update time according to user's requirement " 100 milliseconds by default exe "set updatetime=" . string(g:SrcExpl_refreshTime)