Skip to content

Commit

Permalink
Added easytags_ignored_filetypes option
Browse files Browse the repository at this point in the history
While writing a LaTeX document I found out that Exuberant Ctags was
corrupting my tags file by writing invalid entries. Because half my
self-developed Vim plug-ins deal with Exuberant Ctags integration
which I use constantly this broke my whole environment :-)

Since the main point of easytags.vim is to fully automate tags
generation, corrupt files that need to be repaired by hand are
unacceptable. Therefor I've added an option to enable ignoring selected
file types and defined the default to exclude `*.tex` files.

If you disagree with me, feel free to set the option
`easytags_ignored_filetypes` to an empty string,
in which case no file types will be ignored.
  • Loading branch information
xolox committed Jun 9, 2010
1 parent 65ad69a commit 6dd0b7a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
13 changes: 7 additions & 6 deletions autoload.vim
@@ -1,6 +1,6 @@
" Vim script " Vim script
" Maintainer: Peter Odding <peter@peterodding.com> " Maintainer: Peter Odding <peter@peterodding.com>
" Last Change: June 6, 2010 " Last Change: June 9, 2010
" URL: http://peterodding.com/code/vim/easytags " URL: http://peterodding.com/code/vim/easytags


function! easytags#autoload() " {{{1 function! easytags#autoload() " {{{1
Expand Down Expand Up @@ -34,8 +34,9 @@ endfunction


function! easytags#update_cmd(filter_invalid_tags) " {{{1 function! easytags#update_cmd(filter_invalid_tags) " {{{1
try try
let supported_filetype = index(easytags#supported_filetypes(), &ft) >= 0 let ft_supported = index(easytags#supported_filetypes(), &ft) >= 0
if supported_filetype || a:filter_invalid_tags let ft_ignored = g:easytags_ignored_filetypes != '' && &ft =~ g:easytags_ignored_filetypes
if (ft_supported && !ft_ignored) || a:filter_invalid_tags
let start = xolox#timer#start() let start = xolox#timer#start()
let tagsfile = easytags#get_tagsfile() let tagsfile = easytags#get_tagsfile()
let filename = expand('%:p') let filename = expand('%:p')
Expand All @@ -48,7 +49,7 @@ function! easytags#update_cmd(filter_invalid_tags) " {{{1
let start_filter = xolox#timer#start() let start_filter = xolox#timer#start()
let lines = readfile(tagsfile) let lines = readfile(tagsfile)
let filters = [] let filters = []
if supported_filetype if ft_supported && !ft_ignored
let filename_pattern = '\s' . xolox#escape#pattern(filename) . '\s' let filename_pattern = '\s' . xolox#escape#pattern(filename) . '\s'
call add(filters, 'v:val !~ filename_pattern') call add(filters, 'v:val !~ filename_pattern')
endif endif
Expand All @@ -64,12 +65,12 @@ function! easytags#update_cmd(filter_invalid_tags) " {{{1
endif endif
call xolox#timer#stop(start_filter, "easytags.vim: Filtered tags file in %s second(s)") call xolox#timer#stop(start_filter, "easytags.vim: Filtered tags file in %s second(s)")
endif endif
if supported_filetype if ft_supported && !ft_ignored
call add(command, '--language-force=' . easytags#to_ctags_ft(&ft)) call add(command, '--language-force=' . easytags#to_ctags_ft(&ft))
call add(command, shellescape(filename)) call add(command, shellescape(filename))
let listing = system(join(command)) let listing = system(join(command))
if v:shell_error if v:shell_error
throw "Failed to update tags file!" throw "Failed to update tags file! (Ctags output: `" . listing . "')"
endif endif
endif endif
call xolox#timer#stop(start, "easytags.vim: Updated tags in %s second(s)") call xolox#timer#stop(start, "easytags.vim: Updated tags in %s second(s)")
Expand Down
6 changes: 5 additions & 1 deletion easytags.vim
@@ -1,6 +1,6 @@
" Vim plug-in " Vim plug-in
" Maintainer: Peter Odding <peter@peterodding.com> " Maintainer: Peter Odding <peter@peterodding.com>
" Last Change: June 6, 2010 " Last Change: June 8, 2010
" URL: http://peterodding.com/code/vim/easytags " URL: http://peterodding.com/code/vim/easytags
" Requires: Exuberant Ctags (http://ctags.sf.net) " Requires: Exuberant Ctags (http://ctags.sf.net)
" License: MIT " License: MIT
Expand Down Expand Up @@ -36,6 +36,10 @@ if !exists('g:easytags_on_cursorhold')
let g:easytags_on_cursorhold = 1 let g:easytags_on_cursorhold = 1
endif endif


if !exists('g:easytags_ignored_filetypes')
let g:easytags_ignored_filetypes = '^tex$'
endif

" Before sourcing the rest of the plug-in first check that the location of the " Before sourcing the rest of the plug-in first check that the location of the
" "Exuberant Ctags" program has been configured or that the program exists in " "Exuberant Ctags" program has been configured or that the program exists in
" one of its default locations. " one of its default locations.
Expand Down

0 comments on commit 6dd0b7a

Please sign in to comment.