aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--autoload/xolox/easytags.vim35
-rw-r--r--autoload/xolox/easytags/update.vim14
-rw-r--r--plugin/easytags.vim7
3 files changed, 42 insertions, 14 deletions
diff --git a/autoload/xolox/easytags.vim b/autoload/xolox/easytags.vim
index 213175d..1cd6071 100644
--- a/autoload/xolox/easytags.vim
+++ b/autoload/xolox/easytags.vim
@@ -1,6 +1,6 @@
" Vim script
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: June 22, 2014
+" Last Change: June 29, 2014
" URL: http://peterodding.com/code/vim/easytags/
let g:xolox#easytags#version = '3.5'
@@ -117,7 +117,8 @@ endfunction
function! xolox#easytags#autoload(event) " {{{2
try
- let do_update = xolox#misc#option#get('easytags_auto_update', 1)
+ let session_loading = xolox#easytags#session_is_loading() && a:event == 'BufReadPost'
+ let do_update = xolox#misc#option#get('easytags_auto_update', 1) && !session_loading
let do_highlight = xolox#misc#option#get('easytags_auto_highlight', 1) && &eventignore !~? '\<syntax\>'
" Don't execute this function for unsupported file types (doesn't load
" the list of file types if updates and highlighting are both disabled).
@@ -326,7 +327,11 @@ function! xolox#easytags#highlight() " {{{2
endif
endif
endfor
- redraw
+ " Avoid flashing each highlighted buffer in front of the user when
+ " loading a session.
+ if !xolox#easytags#session_is_loading()
+ redraw
+ endif
let bufname = expand('%:p:~')
if bufname == ''
let bufname = 'unnamed buffer #' . bufnr('%')
@@ -373,7 +378,7 @@ function! xolox#easytags#get_tagsfile() " {{{2
let message = "The tags file %s isn't writable!"
throw printf(message, fnamemodify(tagsfile, ':~'))
endif
- return tagsfile
+ return xolox#misc#path#absolute(tagsfile)
endfunction
function! xolox#easytags#syntax_groups_to_ignore() " {{{2
@@ -408,6 +413,22 @@ function! xolox#easytags#async_callback(response) " {{{2
endif
endfunction
+function! xolox#easytags#session_is_loading() " {{{2
+ return exists('g:SessionLoad')
+endfunction
+
+function! xolox#easytags#disable_automatic_updates() " {{{2
+ let s:easytags_auto_update_save = xolox#misc#option#get('easytags_auto_update', 1)
+ let g:easytags_auto_update = 0
+endfunction
+
+function! xolox#easytags#restore_automatic_updates() " {{{2
+ if exists('s:easytags_auto_update_save')
+ let g:easytags_auto_update = s:easytags_auto_update_save
+ unlet s:easytags_auto_update_save
+ else
+endfunction
+
" Public API for definition of file type specific dynamic syntax highlighting. {{{1
function! xolox#easytags#define_tagkind(object) " {{{2
@@ -425,7 +446,7 @@ endfunction
" Miscellaneous script-local functions. {{{1
-function! s:report_results(response, async) " {{{1
+function! s:report_results(response, async) " {{{2
let actions = []
if a:response['num_updated'] > 0
call add(actions, printf('updated %i tags', a:response['num_updated']))
@@ -434,8 +455,10 @@ function! s:report_results(response, async) " {{{1
call add(actions, printf('filtered %i invalid tags', a:response['num_filtered']))
endif
if !empty(actions)
+ let function = a:async ? 'xolox#misc#msg#debug' : 'xolox#misc#msg#info'
let actions_string = xolox#misc#str#ucfirst(join(actions, ' and '))
- call xolox#misc#msg#info("easytags.vim %s: %s in %s (%s).", g:xolox#easytags#version, actions_string, a:response['elapsed_time'], a:async ? 'asynchronously' : 'synchronously')
+ let command_type = a:async ? 'asynchronously' : 'synchronously'
+ call call(function, ["easytags.vim %s: %s in %s (%s).", g:xolox#easytags#version, actions_string, a:response['elapsed_time'], command_type])
endif
endfunction
diff --git a/autoload/xolox/easytags/update.vim b/autoload/xolox/easytags/update.vim
index 82f49de..55ce8b6 100644
--- a/autoload/xolox/easytags/update.vim
+++ b/autoload/xolox/easytags/update.vim
@@ -1,6 +1,6 @@
" Vim script
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: June 22, 2014
+" Last Change: June 29, 2014
" URL: http://peterodding.com/code/vim/easytags/
" This Vim auto-load script contains the parts of vim-easytags that are used
@@ -254,13 +254,13 @@ endfunction
function! s:create_cache() " {{{1
let cache = {'canonicalize_cache': {}, 'exists_cache': {}}
function cache.canonicalize(pathname) dict
- if a:pathname == ''
- return ''
- endif
- if !has_key(self, a:pathname)
- let self[a:pathname] = xolox#easytags#utils#canonicalize(a:pathname)
+ if !empty(a:pathname)
+ if !has_key(self, a:pathname)
+ let self[a:pathname] = xolox#easytags#utils#canonicalize(a:pathname)
+ endif
+ return self[a:pathname]
endif
- return self[a:pathname]
+ return ''
endfunction
function cache.exists(pathname) dict
if !has_key(self, a:pathname)
diff --git a/plugin/easytags.vim b/plugin/easytags.vim
index a20b85c..4da7962 100644
--- a/plugin/easytags.vim
+++ b/plugin/easytags.vim
@@ -1,6 +1,6 @@
" Vim plug-in
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: June 22, 2014
+" Last Change: June 29, 2014
" URL: http://peterodding.com/code/vim/easytags/
" Requires: Exuberant Ctags (http://ctags.sf.net)
@@ -122,6 +122,11 @@ augroup PluginEasyTags
" After reloading a buffer the dynamic syntax highlighting is lost. The
" following code makes sure the highlighting is refreshed afterwards.
autocmd BufReadPost * unlet! b:easytags_last_highlighted
+ " During :vimgrep each searched buffer triggers an asynchronous tags file
+ " update resulting in races for the tags file. To avoid this we temporarily
+ " disable automatic tags file updates during :vimgrep.
+ "autocmd QuickFixCmdPre *vimgrep* call xolox#easytags#disable_automatic_updates()
+ "autocmd QuickFixCmdPost *vimgrep* call xolox#easytags#restore_automatic_updates()
augroup END
" Use vim-misc to register an event handler for Vim's CursorHold and