Skip to content

Commit 1de4f3d

Browse files
committed
Refactor automatic command registration, include more events
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.
1 parent 6c959d2 commit 1de4f3d

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

plugin/easytags.vim

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
" URL: http://peterodding.com/code/vim/easytags/
55
" Requires: Exuberant Ctags (http://ctags.sf.net)
66
" License: MIT
7-
" Version: 2.2.11
7+
" Version: 2.2.12
88

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

37-
if !exists('g:easytags_always_enabled')
38-
let g:easytags_always_enabled = 0
39-
endif
40-
41-
if !exists('g:easytags_on_cursorhold')
42-
let g:easytags_on_cursorhold = 1
37+
if !exists('g:easytags_events')
38+
let g:easytags_events = []
39+
if !exists('g:easytags_on_cursorhold') || g:easytags_on_cursorhold
40+
call extend(g:easytags_events, ['CursorHold', 'CursorHoldI'])
41+
endif
42+
if exists('g:easytags_always_enabled') && g:easytags_always_enabled
43+
call extend(g:easytags_events, ['BufReadPost', 'BufWritePost', 'FocusGained', 'ShellCmdPost', 'ShellFilterPost'])
44+
endif
4345
endif
4446

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

187188
" }}}1

0 commit comments

Comments
 (0)