diff options
Diffstat (limited to 'autoload/xolox')
-rw-r--r-- | autoload/xolox/easytags.vim | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/autoload/xolox/easytags.vim b/autoload/xolox/easytags.vim index 3c7f7dd..c78b261 100644 --- a/autoload/xolox/easytags.vim +++ b/autoload/xolox/easytags.vim @@ -7,13 +7,14 @@ let s:script = expand('<sfile>:p:~') " Public interface through (automatic) commands. {{{1 -function! xolox#easytags#register() " {{{2 +function! xolox#easytags#register(global) " {{{2 " Parse the &tags option and get a list of all tags files *including " non-existing files* (this is why we can't just call tagfiles()). let tagfiles = xolox#misc#option#split_tags(&tags) let expanded = map(copy(tagfiles), 'resolve(expand(v:val))') " Add the filename to the &tags option when the user hasn't done so already. - if index(expanded, xolox#misc#path#absolute(g:easytags_file)) == -1 + let tagsfile = a:global ? g:easytags_file : xolox#easytags#get_tagsfile() + if index(expanded, xolox#misc#path#absolute(tagsfile)) == -1 " This is a real mess because of bugs in Vim?! :let &tags = '...' doesn't " work on UNIX and Windows, :set tags=... doesn't work on Windows. What I " mean with "doesn't work" is that tagfiles() == [] after the :let/:set @@ -21,9 +22,9 @@ function! xolox#easytags#register() " {{{2 " this is a bug in Vim is to type :set tags= then press <Tab> followed by " <CR>. Now you entered the exact same value that the code below also did " but suddenly Vim sees the tags file and tagfiles() != [] :-S - call add(tagfiles, g:easytags_file) + call add(tagfiles, tagsfile) let value = xolox#misc#option#join_tags(tagfiles) - let cmd = 'set tags=' . escape(value, '\ ') + let cmd = (a:global ? 'set' : 'setl') . ' tags=' . escape(value, '\ ') if xolox#misc#os#is_win() && v:version < 703 " TODO How to clear the expression from Vim's status line? call feedkeys(":" . cmd . "|let &ro=&ro\<CR>", 'n') @@ -35,7 +36,7 @@ endfunction function! xolox#easytags#autoload() " {{{2 try - " Update the entries for the current file in the global tags file? + " Update entries for current file in tags file? let pathname = s:resolve(expand('%:p')) if pathname != '' let tags_outdated = getftime(pathname) > getftime(xolox#easytags#get_tagsfile()) @@ -43,7 +44,7 @@ function! xolox#easytags#autoload() " {{{2 call xolox#easytags#update(1, 0, []) endif endif - " Apply highlighting of tags in global tags file to current buffer? + " Apply highlighting of tags to current buffer? if &eventignore !~? '\<syntax\>' if !exists('b:easytags_last_highlighted') call xolox#easytags#highlight() @@ -376,7 +377,10 @@ endfunction function! xolox#easytags#get_tagsfile() " {{{2 let tagsfile = expand(g:easytags_file) - if g:easytags_dynamic_files + if !empty(g:easytags_by_filetype) && !empty(&filetype) + 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] |