11" Vim script
22" Author: Peter Odding <peter@peterodding.com>
3- " Last Change: April 30 , 2013
3+ " Last Change: May 5 , 2013
44" URL: http://peterodding.com/code/vim/easytags/
55
6- let g: xolox #easytags#version = ' 3.1.8 '
6+ let g: xolox #easytags#version = ' 3.2 '
77
88call xolox#misc#compat#check (' easytags' , 2 )
99
@@ -68,7 +68,7 @@ function! xolox#easytags#autoload(event) " {{{2
6868 let do_highlight = xolox#misc#option#get (' easytags_auto_highlight' , 1 ) && &eventignore !~? ' \<syntax\>'
6969 " Don't execute this function for unsupported file types (doesn't load
7070 " 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 ))
7272 " Update entries for current file in tags file?
7373 if do_update
7474 let pathname = s: resolve (expand (' %:p' ))
@@ -161,7 +161,7 @@ function! s:check_cfile(silent, filter_tags, have_args) " {{{3
161161 elseif g: easytags_ignored_filetypes != ' ' && &ft = ~ g: easytags_ignored_filetypes
162162 if silent | return ' ' | endif
163163 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 ))
165165 if silent | return ' ' | endif
166166 throw " Exuberant Ctags doesn't support the " . string (&ft ) . " file type!"
167167 endif
@@ -170,7 +170,8 @@ endfunction
170170
171171function ! s: prep_cmdline (cfile , tagsfile, firstrun, arguments, context) " {{{3
172172 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 ])
174175 let language = get (languages, ctags_language_name, {})
175176 if empty (language )
176177 let program = xolox#misc#option#get (' easytags_cmd' )
@@ -207,7 +208,7 @@ function! s:prep_cmdline(cfile, tagsfile, firstrun, arguments, context) " {{{3
207208 if empty (language )
208209 " TODO Should --language-force distinguish between C and C++?
209210 " 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 ] )
211212 call add (cmdline, xolox#misc#escape#shell (' --language-force=' . filetype ))
212213 endif
213214 call add (cmdline, xolox#misc#escape#shell (a: cfile ))
@@ -518,6 +519,17 @@ function! s:check_filetype(listing, cline)
518519 return xolox#easytags#to_vim_ft (a: cline )
519520endfunction
520521
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+
521533function ! xolox#easytags#read_tagsfile (tagsfile) " {{{2
522534 " I'm not sure whether this is by design or an implementation detail but
523535 " it's possible for the "!_TAG_FILE_SORTED" header to appear after one or
@@ -660,9 +672,10 @@ function! xolox#easytags#get_tagsfile() " {{{2
660672 endif
661673 endif
662674 " 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)
664677 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 ] )
666679 endif
667680 " Default to the global tags file?
668681 if empty (tagsfile)
@@ -780,7 +793,8 @@ function! s:highlight_with_python(syntax_group, tagkind) " {{{2
780793 let context = {}
781794 let context[' tagsfiles' ] = tagfiles ()
782795 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 ])
784798 let context[' tagkinds' ] = get (a: tagkind , ' tagkinds' , ' ' )
785799 let context[' prefix' ] = get (a: tagkind , ' pattern_prefix' , ' ' )
786800 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
823837let s: aliases = {}
824838let s: canonical_aliases = {}
825839call xolox#easytags#alias_filetypes (' c' , ' cpp' , ' objc' , ' objcpp' )
840+ call xolox#easytags#alias_filetypes (' html' , ' htmldjango' )
826841
827842" Enable line continuation.
828843let s: cpo_save = &cpo
0 commit comments