aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--autoload/xolox/easytags.vim54
-rw-r--r--doc/easytags.txt44
3 files changed, 94 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..926ccaa
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+doc/tags
diff --git a/autoload/xolox/easytags.vim b/autoload/xolox/easytags.vim
index 9168eba..22200df 100644
--- a/autoload/xolox/easytags.vim
+++ b/autoload/xolox/easytags.vim
@@ -1,9 +1,9 @@
" Vim script
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: January 15, 2012
+" Last Change: April 19, 2013
" URL: http://peterodding.com/code/vim/easytags/
-let g:xolox#easytags#version = '2.8.1'
+let g:xolox#easytags#version = '2.9'
" Public interface through (automatic) commands. {{{1
@@ -99,8 +99,11 @@ function! xolox#easytags#update(silent, filter_tags, filenames) " {{{2
let tagsfile = xolox#easytags#get_tagsfile()
let firstrun = !filereadable(tagsfile)
let cmdline = s:prep_cmdline(cfile, tagsfile, firstrun, a:filenames, context)
- let output = s:run_ctags(starttime, cfile, tagsfile, firstrun, cmdline)
+ let [output, has_updates] = s:run_ctags(starttime, cfile, tagsfile, firstrun, cmdline)
if !firstrun
+ if !has_updates
+ return 1
+ endif
if have_args && !empty(g:easytags_by_filetype)
" TODO Get the headers from somewhere?!
call s:save_by_filetype(a:filter_tags, [], output, context)
@@ -222,10 +225,12 @@ endfunction
function! s:run_ctags(starttime, cfile, tagsfile, firstrun, cmdline) " {{{3
let lines = []
+ let has_updates = 1
if a:cmdline != ''
call xolox#misc#msg#debug("easytags.vim %s: Executing %s.", g:xolox#easytags#version, a:cmdline)
try
let lines = xolox#shell#execute(a:cmdline, 1)
+ let has_updates = a:firstrun || s:has_updates(a:cfile, join(lines, "\n"))
catch /^Vim\%((\a\+)\)\=:E117/
" Ignore missing shell.vim plug-in.
let output = system(a:cmdline)
@@ -234,6 +239,7 @@ function! s:run_ctags(starttime, cfile, tagsfile, firstrun, cmdline) " {{{3
throw printf(msg, fnamemodify(a:tagsfile, ':~'), strtrans(output))
endif
let lines = split(output, "\n")
+ let has_updates = a:firstrun || s:has_updates(a:cfile, output)
endtry
if a:firstrun
if a:cfile != ''
@@ -244,9 +250,47 @@ function! s:run_ctags(starttime, cfile, tagsfile, firstrun, cmdline) " {{{3
return []
endif
endif
- return xolox#easytags#parse_entries(lines)
+ return [xolox#easytags#parse_entries(lines), has_updates]
endfunction
+" Vim 7.3 now has the sha256() function. We use it below to recognize when the
+" tags haven't changed from the last time we ran Exuberant Ctags on a file; in
+" this case the tags file doesn't have to be written to disk which makes the
+" plug-in much faster for a very common case.
+
+let s:fingerprints = {}
+
+function! s:has_updates(cfile, output)
+ if empty(a:cfile)
+ " The cache doesn't work when tags aren't created for the current file.
+ return 1
+ endif
+ let fingerprint = s:get_fingerprint(a:cfile, a:output)
+ call xolox#misc#msg#debug("easytags.vim %s: Fingerprint of tags in %s is %s.", g:xolox#easytags#version, a:cfile, string(fingerprint))
+ if !empty(fingerprint) && get(s:fingerprints, a:cfile, '') ==# fingerprint
+ call xolox#misc#msg#debug("easytags.vim %s: The fingerprint didn't change! We can take a shortcut :-)", g:xolox#easytags#version)
+ return 0
+ endif
+ let s:fingerprints[a:cfile] = fingerprint
+ return 1
+endfunction
+
+if exists('*sha256')
+ function! s:get_fingerprint(cfile, output)
+ return sha256(a:output)
+ endfunction
+else
+ function! s:get_fingerprint(cfile, output)
+ " Don't want to re-implement a costly hashing function in Vimscript. Just
+ " handle files that never had any tags.
+ if empty(a:output)
+ return get(s:fingerprints, a:cfile, 1)
+ else
+ return ''
+ endif
+ endfunction
+endif
+
function! s:filter_merge_tags(filter_tags, tagsfile, output, context) " {{{3
let [headers, entries] = xolox#easytags#read_tagsfile(a:tagsfile)
let filters = []
@@ -945,7 +989,7 @@ call xolox#easytags#define_tagkind({
\ 'filetype': 'sh',
\ 'hlgroup': 'shFunctionTag',
\ 'tagkinds': 'f',
- \ 'pattern_suffix': '\(\s*()\)\@!'})
+ \ 'pattern_suffix': '\(\w\|\s*()\)\@!'})
highlight def link shFunctionTag Operator
diff --git a/doc/easytags.txt b/doc/easytags.txt
index 3747971..3158f7e 100644
--- a/doc/easytags.txt
+++ b/doc/easytags.txt
@@ -1,5 +1,49 @@
*easytags.txt* Automated tag generation and syntax highlighting in Vim
+===============================================================================
+ *easytags-contents*
+Contents ~
+
+ 1. Introduction |easytags-introduction|
+ 2. Installation |easytags-installation|
+ 1. A note about Windows |easytags-a-note-about-windows|
+ 3. Commands |easytags-commands|
+ 1. The |:UpdateTags| command
+ 2. The |:HighlightTags| command
+ 4. Options |easytags-options|
+ 1. The |g:easytags_cmd| option
+ 2. The |g:easytags_file| option
+ 3. The |g:easytags_dynamic_files| option
+ 4. The |g:easytags_by_filetype| option
+ 5. The |g:easytags_always_enabled| option
+ 6. The |g:easytags_on_cursorhold| option
+ 7. The |g:easytags_updatetime_min| option
+ 8. The |g:easytags_updatetime_autodisable| option
+ 9. The |g:easytags_auto_update| option
+ 10. The |g:easytags_auto_highlight| option
+ 11. The |g:easytags_autorecurse| option
+ 12. The |g:easytags_include_members| option
+ 13. The |g:easytags_resolve_links| option
+ 14. The |g:easytags_suppress_ctags_warning| option
+ 15. The |g:easytags_ignored_syntax_groups| option
+ 5. Faster syntax highlighting using Python |easytags-faster-syntax-highlighting-using-python|
+ 1. The |g:easytags_python_enabled| option
+ 2. The |g:easytags_python_script| option
+ 6. How to customize the highlighting colors?
+ 7. Passing custom command line arguments to Exuberant Ctags
+ 8. Troubleshooting |easytags-troubleshooting|
+ 1. |:HighlightTags| only works for the tags file created by |:UpdateTags|
+ 2. The plug-in complains that Exuberant Ctags isn't installed
+ 3. Vim locks up while the plug-in is running
+ 4. Failed to highlight tags because pattern is too big!
+ 5. The plug-in doesn't seem to work in Cygwin
+ 9. Contact |easytags-contact|
+ 10. License |easytags-license|
+
+===============================================================================
+ *easytags-introduction*
+Introduction ~
+
Vim has long been my favorite text editor and combined with Exuberant Ctags
[1] it has the potential to provide most of what I expect from an integrated
development environment [2]. Exuberant Ctags is the latest incarnation of a