Skip to content
This repository
Browse code

Added `easytags_ignored_filetypes` option

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...
commit 6dd0b7a882d8102f5cff1b2acc927b91cc03e514 1 parent 65ad69a
Peter Odding authored June 09, 2010

Showing 2 changed files with 12 additions and 7 deletions. Show diff stats Hide diff stats

  1. 13  autoload.vim
  2. 6  easytags.vim
13  autoload.vim
... ...
@@ -1,6 +1,6 @@
1 1
 " Vim script
2 2
 " Maintainer: Peter Odding <peter@peterodding.com>
3  
-" Last Change: June 6, 2010
  3
+" Last Change: June 9, 2010
4 4
 " URL: http://peterodding.com/code/vim/easytags
5 5
 
6 6
 function! easytags#autoload() " {{{1
@@ -34,8 +34,9 @@ endfunction
34 34
 
35 35
 function! easytags#update_cmd(filter_invalid_tags) " {{{1
36 36
   try
37  
-    let supported_filetype = index(easytags#supported_filetypes(), &ft) >= 0
38  
-    if supported_filetype || a:filter_invalid_tags
  37
+    let ft_supported = index(easytags#supported_filetypes(), &ft) >= 0
  38
+    let ft_ignored = g:easytags_ignored_filetypes != '' && &ft =~ g:easytags_ignored_filetypes
  39
+    if (ft_supported && !ft_ignored) || a:filter_invalid_tags
39 40
       let start = xolox#timer#start()
40 41
       let tagsfile = easytags#get_tagsfile()
41 42
       let filename = expand('%:p')
@@ -48,7 +49,7 @@ function! easytags#update_cmd(filter_invalid_tags) " {{{1
48 49
         let start_filter = xolox#timer#start()
49 50
         let lines = readfile(tagsfile)
50 51
         let filters = []
51  
-        if supported_filetype
  52
+        if ft_supported && !ft_ignored
52 53
           let filename_pattern = '\s' . xolox#escape#pattern(filename) . '\s'
53 54
           call add(filters, 'v:val !~ filename_pattern')
54 55
         endif
@@ -64,12 +65,12 @@ function! easytags#update_cmd(filter_invalid_tags) " {{{1
64 65
         endif
65 66
         call xolox#timer#stop(start_filter, "easytags.vim: Filtered tags file in %s second(s)")
66 67
       endif
67  
-      if supported_filetype
  68
+      if ft_supported && !ft_ignored
68 69
         call add(command, '--language-force=' . easytags#to_ctags_ft(&ft))
69 70
         call add(command, shellescape(filename))
70 71
         let listing = system(join(command))
71 72
         if v:shell_error
72  
-          throw "Failed to update tags file!"
  73
+          throw "Failed to update tags file! (Ctags output: `" . listing . "')"
73 74
         endif
74 75
       endif
75 76
       call xolox#timer#stop(start, "easytags.vim: Updated tags in %s second(s)")
6  easytags.vim
... ...
@@ -1,6 +1,6 @@
1 1
 " Vim plug-in
2 2
 " Maintainer: Peter Odding <peter@peterodding.com>
3  
-" Last Change: June 6, 2010
  3
+" Last Change: June 8, 2010
4 4
 " URL: http://peterodding.com/code/vim/easytags
5 5
 " Requires: Exuberant Ctags (http://ctags.sf.net)
6 6
 " License: MIT
@@ -36,6 +36,10 @@ if !exists('g:easytags_on_cursorhold')
36 36
   let g:easytags_on_cursorhold = 1
37 37
 endif
38 38
 
  39
+if !exists('g:easytags_ignored_filetypes')
  40
+  let g:easytags_ignored_filetypes = '^tex$'
  41
+endif
  42
+
39 43
 " Before sourcing the rest of the plug-in first check that the location of the
40 44
 " "Exuberant Ctags" program has been configured or that the program exists in
41 45
 " one of its default locations.

0 notes on commit 6dd0b7a

Please sign in to comment.
Something went wrong with that request. Please try again.