aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Odding <peter@peterodding.com>2010-08-10 18:57:22 +0200
committerPeter Odding <peter@peterodding.com>2010-08-10 18:57:22 +0200
commit0d9567900f23e8ca243db16df80004aa7c658623 (patch)
tree1b92261a6f2ab1eb7d4313f412cf987af470d031
parent80847259b7c3dd5781384f31914a7d7465ed0069 (diff)
downloadvim-easytags-0d9567900f23e8ca243db16df80004aa7c658623.tar.gz
Support for automatic recursion using ctags -R
-rw-r--r--README.md10
-rw-r--r--autoload.vim22
-rw-r--r--easytags.vim8
3 files changed, 34 insertions, 6 deletions
diff --git a/README.md b/README.md
index 14f1fd2..08153e3 100644
--- a/README.md
+++ b/README.md
@@ -68,6 +68,16 @@ As I explained above the plug-in by default doesn't update or highlight your tag
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].
+### The `g:easytags_autorecurse` option
+
+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):
+
+ :let g:easytags_autorecurse = 1
+
+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...
+
+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.
+
### The `g:easytags_resolve_links` option
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:
diff --git a/autoload.vim b/autoload.vim
index 51ef188..1de2e6c 100644
--- a/autoload.vim
+++ b/autoload.vim
@@ -67,8 +67,16 @@ function! s:check_cfile(silent, filter_tags, have_args) " {{{3
if a:have_args
return ''
endif
- let cfile = s:resolve(expand('%:p'))
let silent = a:silent || a:filter_tags
+ if g:easytags_autorecurse
+ let cdir = s:resolve(expand('%:p:h'))
+ if !isdirectory(cdir)
+ if silent | return '' | endif
+ throw "The directory of the current file doesn't exist yet!"
+ endif
+ return cdir
+ endif
+ let cfile = s:resolve(expand('%:p'))
if cfile == '' || !filereadable(cfile)
if silent | return '' | endif
throw "You'll need to save your file before using :UpdateTags!"
@@ -92,9 +100,14 @@ function! s:prep_cmdline(cfile, tagsfile, firstrun, arguments) " {{{3
call add(cmdline, '-f-')
endif
if a:cfile != ''
- let filetype = easytags#to_ctags_ft(&filetype)
- call add(cmdline, shellescape('--language-force=' . filetype))
- call add(cmdline, shellescape(a:cfile))
+ if g:easytags_autorecurse
+ call add(cmdline, '-R')
+ call add(cmdline, shellescape(a:cfile))
+ else
+ let filetype = easytags#to_ctags_ft(&filetype)
+ call add(cmdline, shellescape('--language-force=' . filetype))
+ call add(cmdline, shellescape(a:cfile))
+ endif
else
for fname in a:arguments
let matches = split(expand(fname), "\n")
@@ -108,6 +121,7 @@ endfunction
function! s:run_ctags(starttime, cfile, tagsfile, firstrun, cmdline) " {{{3
let output = []
if a:cmdline != ''
+ call xolox#debug("%s: Executing %s", s:script, a:cmdline)
try
let output = xolox#shell#execute(a:cmdline, 1)
catch /^Vim\%((\a\+)\)\=:E117/
diff --git a/easytags.vim b/easytags.vim
index 79f56e9..f04b7b7 100644
--- a/easytags.vim
+++ b/easytags.vim
@@ -1,10 +1,10 @@
" Vim plug-in
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: August 9, 2010
+" Last Change: August 10, 2010
" URL: http://peterodding.com/code/vim/easytags/
" Requires: Exuberant Ctags (http://ctags.sf.net)
" License: MIT
-" Version: 2.0
+" Version: 2.1
" Support for automatic update using the GLVS plug-in.
" GetLatestVimScripts: 3114 1 :AutoInstall: easytags.zip
@@ -42,6 +42,10 @@ if !exists('g:easytags_ignored_filetypes')
let g:easytags_ignored_filetypes = '^tex$'
endif
+if !exists('g:easytags_autorecurse')
+ let g:easytags_autorecurse = 0
+endif
+
function! s:InitEasyTags(version)
" Check that the location of Exuberant Ctags has been configured or that the
" correct version of the program exists in one of its default locations.