aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjohannes karoff <johannes@karoff.net>2015-02-08 01:49:17 +0100
committerjohannes karoff <johannes@karoff.net>2015-02-08 02:33:28 +0100
commita60b1cfd8236cc008ec7c6c18dd8708cdfb1ce01 (patch)
treea5a4152124b58f9b384d7bed50cbe556ee2dbfa1
parentf711ff64133e2d20145352a5020ea1b9c019828e (diff)
downloadvim-easytags-a60b1cfd8236cc008ec7c6c18dd8708cdfb1ce01.tar.gz
give precedence to dynamic files over storage by filetype
whenever g:easytags_by_filetype and g:easytags_dynamic_files are both set, easytags now writes to the dynamic tags file. fixes #102
-rw-r--r--autoload/xolox/easytags.vim46
1 files changed, 36 insertions, 10 deletions
diff --git a/autoload/xolox/easytags.vim b/autoload/xolox/easytags.vim
index 2eab07a..0fc91ba 100644
--- a/autoload/xolox/easytags.vim
+++ b/autoload/xolox/easytags.vim
@@ -170,8 +170,7 @@ function! xolox#easytags#update(silent, filter_tags, filenames) " {{{2
let have_args = !empty(a:filenames)
let starttime = xolox#misc#timer#start()
let cfile = s:check_cfile(a:silent, a:filter_tags, have_args)
- let tagsfile = xolox#easytags#get_tagsfile()
- let command_line = s:prep_cmdline(cfile, tagsfile, a:filenames)
+ let command_line = s:prep_cmdline(cfile, a:filenames)
if empty(command_line)
return 0
endif
@@ -183,11 +182,14 @@ function! xolox#easytags#update(silent, filter_tags, filenames) " {{{2
let params['default_filetype'] = xolox#easytags#filetypes#canonicalize(&filetype)
let params['filter_tags'] = a:filter_tags || async
let params['have_args'] = have_args
- if !empty(g:easytags_by_filetype)
+ let dynamic_tagsfile = xolox#easytags#get_dynamic_tagsfile()
+ if !empty(dynamic_tagsfile)
+ let params['tagsfile'] = dynamic_tagsfile
+ elseif !empty(g:easytags_by_filetype)
let params['directory'] = xolox#misc#path#absolute(g:easytags_by_filetype)
let params['filetypes'] = g:xolox#easytags#filetypes#ctags_to_vim
else
- let params['tagsfile'] = tagsfile
+ let params['tagsfile'] = xolox#easytags#get_global_tagsfile()
endif
if async
call xolox#misc#async#call({'function': 'xolox#easytags#update#with_vim', 'arguments': [params], 'callback': 'xolox#easytags#async_callback'})
@@ -234,7 +236,7 @@ function! s:check_cfile(silent, filter_tags, have_args) " {{{3
return cfile
endfunction
-function! s:prep_cmdline(cfile, tagsfile, arguments) " {{{3
+function! s:prep_cmdline(cfile, arguments) " {{{3
let vim_file_type = xolox#easytags#filetypes#canonicalize(&filetype)
let custom_languages = xolox#misc#option#get('easytags_languages', {})
let language = get(custom_languages, vim_file_type, {})
@@ -447,7 +449,7 @@ function! xolox#easytags#ctags_command() " {{{2
return ''
endfunction
-function! xolox#easytags#get_tagsfile() " {{{2
+function xolox#easytags#get_dynamic_tagsfile() " {{{2
let tagsfile = ''
" Look for a suitable project specific tags file?
let dynamic_files = xolox#misc#option#get('easytags_dynamic_files', 0)
@@ -463,12 +465,23 @@ function! xolox#easytags#get_tagsfile() " {{{2
let tagsfile = ''
endif
endif
+ " If the tags file exists, make sure it is writable!
+ if filereadable(tagsfile) && filewritable(tagsfile) != 1
+ let message = "The dynamic tags file %s isn't writable!"
+ throw printf(message, fnamemodify(tagsfile, ':~'))
+ endif
if !empty(tagsfile)
call xolox#misc#msg#debug("easytags.vim %s: Selected dynamic tags file %s.", g:xolox#easytags#version, tagsfile)
- endif
+ return xolox#misc#path#absolute(tagsfile)
+ end
+ return ''
+endfunction
+
+function xolox#easytags#get_global_tagsfile() " {{{2
+ let tagsfile = ''
" Check if a file type specific tags file is useful?
let vim_file_type = xolox#easytags#filetypes#canonicalize(&filetype)
- if empty(tagsfile) && !empty(g:easytags_by_filetype) && !empty(vim_file_type)
+ if !empty(g:easytags_by_filetype) && !empty(vim_file_type)
let directory = xolox#misc#path#absolute(g:easytags_by_filetype)
let tagsfile = xolox#misc#path#merge(directory, vim_file_type)
if !empty(tagsfile)
@@ -484,10 +497,23 @@ function! xolox#easytags#get_tagsfile() " {{{2
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!"
+ let message = "The global tags file %s isn't writable!"
throw printf(message, fnamemodify(tagsfile, ':~'))
endif
- return xolox#misc#path#absolute(tagsfile)
+ if !empty(tagsfile)
+ return xolox#misc#path#absolute(tagsfile)
+ endif
+ return ''
+endfunction
+
+function! xolox#easytags#get_tagsfile() " {{{2
+ " Try to get a dynamic tags file
+ let tagsfile = xolox#easytags#get_dynamic_tagsfile()
+ " Otherwise get a global tags file
+ if empty(tagsfile)
+ let tagsfile = xolox#easytags#get_global_tagsfile()
+ endif
+ return tagsfile
endfunction
function! xolox#easytags#syntax_groups_to_ignore() " {{{2