Skip to content

Commit

Permalink
Enable deferring tags file registration (VimEnter)
Browse files Browse the repository at this point in the history
By default the plug-in initializes the &tags option as soon as possible
so that the global tags file is available when using "vim -t some_tag".
If you don't use "vim -t" and want to defer registering the global tags
file until the interface has been initialized you can now set the global
variable g:easytags_register_late = 1.

This commit is based on a pull request from Daniel Hahler, I added the
option to enable either mode of initialization (I guess Daniel doesn't
use "vim -t some_tag", but I certainly do :-). Here's the original
commit message:

    Move calling RegisterTagsFile to `au VimEnter`.

    Calling RegisterTagsFile on VimEnter instead of when including the
    plugin appears to make it behave better when (re)setting 'tags' in
    vimrc.

    I do not remember if this is related to using tplugin only.
  • Loading branch information
blueyed authored and xolox committed Apr 11, 2011
1 parent fffde42 commit 3466f61
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions plugin/easytags.vim
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
" Vim plug-in
" Author: Peter Odding <peter@peterodding.com>
" Last Change: March 19, 2011
" Last Change: April 11, 2011
" URL: http://peterodding.com/code/vim/easytags/
" Requires: Exuberant Ctags (http://ctags.sf.net)
" License: MIT
" Version: 2.2.2
" Version: 2.2.3

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

if !exists('g:easytags_register_late')
let g:easytags_register_late = 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.
Expand Down Expand Up @@ -152,8 +156,13 @@ function! s:RegisterTagsFile()
endif
endfunction

" Let Vim know about the global tags file created by this plug-in.
call s:RegisterTagsFile()
" By default this plug-in initializes the &tags option as soon as possible so
" that the global tags file is available when using "vim -t some_tag". If you
" don't use "vim -t" and want to defer registering the global tags file until
" the interface has been initialized you can set g:easytags_register_late=1.
if !g:easytags_register_late
call s:RegisterTagsFile()
endif

" The :UpdateTags and :HighlightTags commands. {{{1

Expand All @@ -164,6 +173,12 @@ command! -bar HighlightTags call xolox#easytags#highlight()

augroup PluginEasyTags
autocmd!
if g:easytags_register_late
" This is the alternative way of registering the global tags file using
" the automatic command event "VimEnter". Apparently this makes the
" easytags plug-in behave better when used together with tplugin?
autocmd VimEnter * call s:RegisterTagsFile()
endif
if g:easytags_always_enabled
" TODO Also on FocusGained because tags files might be updated externally?
autocmd BufReadPost,BufWritePost * call xolox#easytags#autoload()
Expand Down

0 comments on commit 3466f61

Please sign in to comment.