Skip to content
This repository
Browse code

Support for automatic recursion using ctags -R

  • Loading branch information...
commit 0d9567900f23e8ca243db16df80004aa7c658623 1 parent 8084725
Peter Odding authored August 10, 2010
10  README.md
Source Rendered
@@ -68,6 +68,16 @@ As I explained above the plug-in by default doesn't update or highlight your tag
68 68
 
69 69
 Note: Like the `g:easytags_always_enabled` option, if you change this option it won't apply until you restart Vim, so you'll have to set this option in your [vimrc script][vimrc].
70 70
 
  71
+### The `g:easytags_autorecurse` option
  72
+
  73
+When the `:UpdateTags` command is executed automatically or without arguments, it defaults to updating just the tags for the current file. If you'd rather have it recursively scan everything below the directory of the current file then set this option to true (1):
  74
+
  75
+    :let g:easytags_autorecurse = 1
  76
+
  77
+You have to explicitly enable this option because it should only be used while navigating around small directory trees. Imagine always having this option enabled and then having to edit a file in e.g. the root of your home directory: The `easytags.vim` plug-in would freeze Vim for a long time while you'd have to wait for Exuberant Cags to scan thousands of files...
  78
+
  79
+Note that when you enable this option the `easytags.vim` might ignore other options like `g:easytags_resolve_links`. This is an implementation detail which I intend to fix.
  80
+
71 81
 ### The `g:easytags_resolve_links` option
72 82
 
73 83
 UNIX has [symbolic links](http://en.wikipedia.org/wiki/Symbolic_link) and [hard links](http://en.wikipedia.org/wiki/Hard_link), both of which conflict with the concept of having one unique location for every identifier. With regards to hard links there's not much anyone can do, but because I use symbolic links quite a lot I've added this option. It's disabled by default since it has a small performance impact and might not do what unknowing users expect it to: When you enable this option the plug-in will resolve symbolic links in pathnames, which means your tags file will only contain entries with [canonical pathnames](http://en.wikipedia.org/wiki/Canonicalization). To enable this option (which I strongly suggest doing when you run UNIX and use symbolic links) execute the following Vim command:
22  autoload.vim
@@ -67,8 +67,16 @@ function! s:check_cfile(silent, filter_tags, have_args) " {{{3
67 67
   if a:have_args
68 68
     return ''
69 69
   endif
70  
-  let cfile = s:resolve(expand('%:p'))
71 70
   let silent = a:silent || a:filter_tags
  71
+  if g:easytags_autorecurse
  72
+    let cdir = s:resolve(expand('%:p:h'))
  73
+    if !isdirectory(cdir)
  74
+      if silent | return '' | endif
  75
+      throw "The directory of the current file doesn't exist yet!"
  76
+    endif
  77
+    return cdir
  78
+  endif
  79
+  let cfile = s:resolve(expand('%:p'))
72 80
   if cfile == '' || !filereadable(cfile)
73 81
     if silent | return '' | endif
74 82
     throw "You'll need to save your file before using :UpdateTags!"
@@ -92,9 +100,14 @@ function! s:prep_cmdline(cfile, tagsfile, firstrun, arguments) " {{{3
92 100
     call add(cmdline, '-f-')
93 101
   endif
94 102
   if a:cfile != ''
95  
-    let filetype = easytags#to_ctags_ft(&filetype)
96  
-    call add(cmdline, shellescape('--language-force=' . filetype))
97  
-    call add(cmdline, shellescape(a:cfile))
  103
+    if g:easytags_autorecurse
  104
+      call add(cmdline, '-R')
  105
+      call add(cmdline, shellescape(a:cfile))
  106
+    else
  107
+      let filetype = easytags#to_ctags_ft(&filetype)
  108
+      call add(cmdline, shellescape('--language-force=' . filetype))
  109
+      call add(cmdline, shellescape(a:cfile))
  110
+    endif
98 111
   else
99 112
     for fname in a:arguments
100 113
       let matches = split(expand(fname), "\n")
@@ -108,6 +121,7 @@ endfunction
108 121
 function! s:run_ctags(starttime, cfile, tagsfile, firstrun, cmdline) " {{{3
109 122
   let output = []
110 123
   if a:cmdline != ''
  124
+    call xolox#debug("%s: Executing %s", s:script, a:cmdline)
111 125
     try
112 126
       let output = xolox#shell#execute(a:cmdline, 1)
113 127
     catch /^Vim\%((\a\+)\)\=:E117/
8  easytags.vim
... ...
@@ -1,10 +1,10 @@
1 1
 " Vim plug-in
2 2
 " Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: August 9, 2010
  3
+" Last Change: August 10, 2010
4 4
 " URL: http://peterodding.com/code/vim/easytags/
5 5
 " Requires: Exuberant Ctags (http://ctags.sf.net)
6 6
 " License: MIT
7  
-" Version: 2.0
  7
+" Version: 2.1
8 8
 
9 9
 " Support for automatic update using the GLVS plug-in.
10 10
 " GetLatestVimScripts: 3114 1 :AutoInstall: easytags.zip
@@ -42,6 +42,10 @@ if !exists('g:easytags_ignored_filetypes')
42 42
   let g:easytags_ignored_filetypes = '^tex$'
43 43
 endif
44 44
 
  45
+if !exists('g:easytags_autorecurse')
  46
+  let g:easytags_autorecurse = 0
  47
+endif
  48
+
45 49
 function! s:InitEasyTags(version)
46 50
   " Check that the location of Exuberant Ctags has been configured or that the
47 51
   " correct version of the program exists in one of its default locations.

0 notes on commit 0d95679

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