Skip to content

Commit

Permalink
Refactor automatic command registration, include more events
Browse files Browse the repository at this point in the history
The new events are FocusGained, ShellCmdPost and ShellFilterPost but
they're only used when g:easytags_always_enabled is enabled (it's
disabled by default).

Users can now define their own list of preferred events to override the
defaults by setting the new g:easytags_events option to a list of event
names. I haven't documented the new option yet because I'm not convinced
it's an improvement in terms of usability over the old situation.
  • Loading branch information
xolox committed Jun 12, 2011
1 parent 6c959d2 commit 1de4f3d
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions plugin/easytags.vim
Expand Up @@ -4,7 +4,7 @@
" URL: http://peterodding.com/code/vim/easytags/ " URL: http://peterodding.com/code/vim/easytags/
" Requires: Exuberant Ctags (http://ctags.sf.net) " Requires: Exuberant Ctags (http://ctags.sf.net)
" License: MIT " License: MIT
" Version: 2.2.11 " Version: 2.2.12


" Support for automatic update using the GLVS plug-in. " Support for automatic update using the GLVS plug-in.
" GetLatestVimScripts: 3114 1 :AutoInstall: easytags.zip " GetLatestVimScripts: 3114 1 :AutoInstall: easytags.zip
Expand Down Expand Up @@ -34,12 +34,14 @@ if !exists('g:easytags_resolve_links')
let g:easytags_resolve_links = 0 let g:easytags_resolve_links = 0
endif endif


if !exists('g:easytags_always_enabled') if !exists('g:easytags_events')
let g:easytags_always_enabled = 0 let g:easytags_events = []
endif if !exists('g:easytags_on_cursorhold') || g:easytags_on_cursorhold

call extend(g:easytags_events, ['CursorHold', 'CursorHoldI'])
if !exists('g:easytags_on_cursorhold') endif
let g:easytags_on_cursorhold = 1 if exists('g:easytags_always_enabled') && g:easytags_always_enabled
call extend(g:easytags_events, ['BufReadPost', 'BufWritePost', 'FocusGained', 'ShellCmdPost', 'ShellFilterPost'])
endif
endif endif


if !exists('g:easytags_ignored_filetypes') if !exists('g:easytags_ignored_filetypes')
Expand Down Expand Up @@ -174,14 +176,13 @@ augroup PluginEasyTags
" the automatic command event "VimEnter". Apparently this makes the " the automatic command event "VimEnter". Apparently this makes the
" plug-in behave better when used together with tplugin? " plug-in behave better when used together with tplugin?
autocmd VimEnter * call s:RegisterTagsFile() autocmd VimEnter * call s:RegisterTagsFile()
if g:easytags_always_enabled " Define the automatic commands to perform updating/highlighting.
" TODO Also on FocusGained because tags files might be updated externally? for s:eventname in g:easytags_events
autocmd BufReadPost,BufWritePost * call xolox#easytags#autoload() execute 'autocmd' s:eventname '* call xolox#easytags#autoload()'
endif endfor
if g:easytags_on_cursorhold " After reloading a buffer the dynamic syntax highlighting is lost. The
autocmd CursorHold,CursorHoldI * call xolox#easytags#autoload() " following code makes sure the highlighting is refreshed afterwards.
autocmd BufReadPost * unlet! b:easytags_last_highlighted autocmd BufReadPost * unlet! b:easytags_last_highlighted
endif
augroup END augroup END


" }}}1 " }}}1
Expand Down

0 comments on commit 1de4f3d

Please sign in to comment.