1
1
" Vim script
2
2
" Author: Peter Odding <peter@peterodding.com>
3
- " Last Change: April 30 , 2013
3
+ " Last Change: May 5 , 2013
4
4
" URL: http://peterodding.com/code/vim/easytags/
5
5
6
- let g: xolox #easytags#version = ' 3.1.8 '
6
+ let g: xolox #easytags#version = ' 3.2 '
7
7
8
8
call xolox#misc#compat#check (' easytags' , 2 )
9
9
@@ -68,7 +68,7 @@ function! xolox#easytags#autoload(event) " {{{2
68
68
let do_highlight = xolox#misc#option#get (' easytags_auto_highlight' , 1 ) && &eventignore !~? ' \<syntax\>'
69
69
" Don't execute this function for unsupported file types (doesn't load
70
70
" the list of file types if updates and highlighting are both disabled).
71
- if (do_update || do_highlight) && index (xolox#easytags#supported_filetypes (), &ft ) >= 0
71
+ if (do_update || do_highlight) && ! empty (xolox#easytags#select_supported_filetypes ( &ft ))
72
72
" Update entries for current file in tags file?
73
73
if do_update
74
74
let pathname = s: resolve (expand (' %:p' ))
@@ -161,7 +161,7 @@ function! s:check_cfile(silent, filter_tags, have_args) " {{{3
161
161
elseif g: easytags_ignored_filetypes != ' ' && &ft = ~ g: easytags_ignored_filetypes
162
162
if silent | return ' ' | endif
163
163
throw " The " . string (&ft ) . " file type is explicitly ignored."
164
- elseif index (xolox#easytags#supported_filetypes (), &ft ) == -1
164
+ elseif empty (xolox#easytags#select_supported_filetypes ( &ft ))
165
165
if silent | return ' ' | endif
166
166
throw " Exuberant Ctags doesn't support the " . string (&ft ) . " file type!"
167
167
endif
@@ -170,7 +170,8 @@ endfunction
170
170
171
171
function ! s: prep_cmdline (cfile , tagsfile, firstrun, arguments, context) " {{{3
172
172
let languages = xolox#misc#option#get (' easytags_languages' , {})
173
- let ctags_language_name = xolox#easytags#to_ctags_ft (&filetype )
173
+ let applicable_filetypes = xolox#easytags#select_supported_filetypes (&ft )
174
+ let ctags_language_name = xolox#easytags#to_ctags_ft (applicable_filetypes[0 ])
174
175
let language = get (languages, ctags_language_name, {})
175
176
if empty (language )
176
177
let program = xolox#misc#option#get (' easytags_cmd' )
@@ -207,7 +208,7 @@ function! s:prep_cmdline(cfile, tagsfile, firstrun, arguments, context) " {{{3
207
208
if empty (language )
208
209
" TODO Should --language-force distinguish between C and C++?
209
210
" TODO --language-force doesn't make sense for JavaScript tags in HTML files?
210
- let filetype = xolox#easytags#to_ctags_ft (& filetype )
211
+ let filetype = xolox#easytags#to_ctags_ft (applicable_filetypes[ 0 ] )
211
212
call add (cmdline, xolox#misc#escape#shell (' --language-force=' . filetype ))
212
213
endif
213
214
call add (cmdline, xolox#misc#escape#shell (a: cfile ))
@@ -518,6 +519,17 @@ function! s:check_filetype(listing, cline)
518
519
return xolox#easytags#to_vim_ft (a: cline )
519
520
endfunction
520
521
522
+ function ! xolox#easytags#select_supported_filetypes (vim_ft) " {{{2
523
+ let supported_filetypes = xolox#easytags#supported_filetypes ()
524
+ let applicable_filetypes = []
525
+ for ft in split (&filetype , ' \.' )
526
+ if index (supported_filetypes, ft ) >= 0
527
+ call add (applicable_filetypes, ft )
528
+ endif
529
+ endfor
530
+ return applicable_filetypes
531
+ endfunction
532
+
521
533
function ! xolox#easytags#read_tagsfile (tagsfile) " {{{2
522
534
" I'm not sure whether this is by design or an implementation detail but
523
535
" it's possible for the "!_TAG_FILE_SORTED" header to appear after one or
@@ -660,9 +672,10 @@ function! xolox#easytags#get_tagsfile() " {{{2
660
672
endif
661
673
endif
662
674
" Check if a file type specific tags file is useful?
663
- if empty (tagsfile) && ! empty (g: easytags_by_filetype ) && index (xolox#easytags#supported_filetypes (), &ft ) >= 0
675
+ let applicable_filetypes = xolox#easytags#select_supported_filetypes (&ft )
676
+ if empty (tagsfile) && ! empty (g: easytags_by_filetype ) && ! empty (applicable_filetypes)
664
677
let directory = xolox#misc#path#absolute (g: easytags_by_filetype )
665
- let tagsfile = xolox#misc#path#merge (directory , & filetype )
678
+ let tagsfile = xolox#misc#path#merge (directory , applicable_filetypes[ 0 ] )
666
679
endif
667
680
" Default to the global tags file?
668
681
if empty (tagsfile)
@@ -780,7 +793,8 @@ function! s:highlight_with_python(syntax_group, tagkind) " {{{2
780
793
let context = {}
781
794
let context[' tagsfiles' ] = tagfiles ()
782
795
let context[' syntaxgroup' ] = a: syntax_group
783
- let context[' filetype' ] = xolox#easytags#to_ctags_ft (&ft )
796
+ let applicable_filetypes = xolox#easytags#select_supported_filetypes (&ft )
797
+ let context[' filetype' ] = xolox#easytags#to_ctags_ft (applicable_filetypes[0 ])
784
798
let context[' tagkinds' ] = get (a: tagkind , ' tagkinds' , ' ' )
785
799
let context[' prefix' ] = get (a: tagkind , ' pattern_prefix' , ' ' )
786
800
let context[' suffix' ] = get (a: tagkind , ' pattern_suffix' , ' ' )
@@ -823,6 +837,7 @@ call xolox#easytags#map_filetypes(exists('g:filetype_asp') ? g:filetype_asp : 'a
823
837
let s: aliases = {}
824
838
let s: canonical_aliases = {}
825
839
call xolox#easytags#alias_filetypes (' c' , ' cpp' , ' objc' , ' objcpp' )
840
+ call xolox#easytags#alias_filetypes (' html' , ' htmldjango' )
826
841
827
842
" Enable line continuation.
828
843
let s: cpo_save = &cpo
0 commit comments