From d727ac0cb7b03747d0688d939210af07da4cad60 Mon Sep 17 00:00:00 2001 From: Kenny Stuart Date: Fri, 24 Jun 2011 02:23:48 +0200 Subject: Allow enabling both dynamic and file type tags files When both options are enabled, project specific tags files take precedence if they exist and are writable, otherwise a file type tags file is used. (Stuart wrote this code, Peter added the check for supported file types) --- autoload/xolox/easytags.vim | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'autoload/xolox') diff --git a/autoload/xolox/easytags.vim b/autoload/xolox/easytags.vim index e9944c9..6a1de96 100644 --- a/autoload/xolox/easytags.vim +++ b/autoload/xolox/easytags.vim @@ -1,6 +1,6 @@ " Vim script " Author: Peter Odding -" Last Change: June 18, 2011 +" Last Change: June 24, 2011 " URL: http://peterodding.com/code/vim/easytags/ " Public interface through (automatic) commands. {{{1 @@ -483,16 +483,21 @@ function! s:cache_tagged_files_in(fname, ftime, entries) " {{{3 endfunction function! xolox#easytags#get_tagsfile() " {{{2 + " Look for a writable project specific tags file? + if g:easytags_dynamic_files + let files = tagfiles() + if len(files) > 0 && filewritable(files[0]) == 1 + return files[0] + endif + endif + " Default to the global tags file. let tagsfile = expand(g:easytags_file) - if !empty(g:easytags_by_filetype) && !empty(&filetype) + " Check if a file type specific tags file is useful? + if !empty(g:easytags_by_filetype) && index(xolox#easytags#supported_filetypes(), &ft) >= 0 let directory = xolox#misc#path#absolute(g:easytags_by_filetype) let tagsfile = xolox#misc#path#merge(directory, &filetype) - elseif g:easytags_dynamic_files - let files = tagfiles() - if len(files) > 0 - let tagsfile = files[0] - endif endif + " If the tags file exists, make sure it is writable! if filereadable(tagsfile) && filewritable(tagsfile) != 1 let message = "The tags file %s isn't writable!" throw printf(message, fnamemodify(tagsfile, ':~')) -- cgit v1.2.3