aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Odding <peter@peterodding.com>2011-06-13 16:02:51 +0200
committerPeter Odding <peter@peterodding.com>2011-06-13 16:02:51 +0200
commitbda802cf6b09b380b5692ff8c1ee2cb4f202ab55 (patch)
tree528e05b745b05bae272507214d7c17c56bd60fd8
parentdc167e4d42265f9d9fbe764570b1b6b199794e98 (diff)
downloadvim-easytags-bda802cf6b09b380b5692ff8c1ee2cb4f202ab55.tar.gz
Move tags file registration to auto load function
(in preparation for file type specific tags files)
-rw-r--r--autoload/xolox/easytags.vim26
-rw-r--r--plugin/easytags.vim32
2 files changed, 29 insertions, 29 deletions
diff --git a/autoload/xolox/easytags.vim b/autoload/xolox/easytags.vim
index 10bb650..00b5baf 100644
--- a/autoload/xolox/easytags.vim
+++ b/autoload/xolox/easytags.vim
@@ -7,6 +7,32 @@ let s:script = expand('<sfile>:p:~')
" Public interface through (automatic) commands. {{{1
+function! xolox#easytags#register() " {{{2
+ " Parse the &tags option and get a list of all tags files *including
+ " non-existing files* (this is why we can't just call tagfiles()).
+ let tagfiles = xolox#misc#option#split_tags(&tags)
+ let expanded = map(copy(tagfiles), 'resolve(expand(v:val))')
+ " Add the filename to the &tags option when the user hasn't done so already.
+ if index(expanded, xolox#misc#path#absolute(g:easytags_file)) == -1
+ " This is a real mess because of bugs in Vim?! :let &tags = '...' doesn't
+ " work on UNIX and Windows, :set tags=... doesn't work on Windows. What I
+ " mean with "doesn't work" is that tagfiles() == [] after the :let/:set
+ " command even though the tags file exists! One easy way to confirm that
+ " this is a bug in Vim is to type :set tags= then press <Tab> followed by
+ " <CR>. Now you entered the exact same value that the code below also did
+ " but suddenly Vim sees the tags file and tagfiles() != [] :-S
+ call add(tagfiles, g:easytags_file)
+ let value = xolox#misc#option#join_tags(tagfiles)
+ let cmd = 'set tags=' . escape(value, '\ ')
+ if xolox#misc#os#is_win() && v:version < 703
+ " TODO How to clear the expression from Vim's status line?
+ call feedkeys(":" . cmd . "|let &ro=&ro\<CR>", 'n')
+ else
+ execute cmd
+ endif
+ endif
+endfunction
+
function! xolox#easytags#autoload() " {{{2
try
" Update the entries for the current file in the global tags file?
diff --git a/plugin/easytags.vim b/plugin/easytags.vim
index d3edde3..bb2d441 100644
--- a/plugin/easytags.vim
+++ b/plugin/easytags.vim
@@ -4,7 +4,7 @@
" URL: http://peterodding.com/code/vim/easytags/
" Requires: Exuberant Ctags (http://ctags.sf.net)
" License: MIT
-" Version: 2.2.13
+" Version: 2.2.14
" Support for automatic update using the GLVS plug-in.
" GetLatestVimScripts: 3114 1 :AutoInstall: easytags.zip
@@ -132,36 +132,10 @@ if !s:InitEasyTags(55)
finish
endif
-function! s:RegisterTagsFile()
- " Parse the &tags option and get a list of all tags files *including
- " non-existing files* (this is why we can't just call tagfiles()).
- let tagfiles = xolox#misc#option#split_tags(&tags)
- let expanded = map(copy(tagfiles), 'resolve(expand(v:val))')
- " Add the filename to the &tags option when the user hasn't done so already.
- if index(expanded, resolve(expand(g:easytags_file))) == -1
- " This is a real mess because of bugs in Vim?! :let &tags = '...' doesn't
- " work on UNIX and Windows, :set tags=... doesn't work on Windows. What I
- " mean with "doesn't work" is that tagfiles() == [] after the :let/:set
- " command even though the tags file exists! One easy way to confirm that
- " this is a bug in Vim is to type :set tags= then press <Tab> followed by
- " <CR>. Now you entered the exact same value that the code below also did
- " but suddenly Vim sees the tags file and tagfiles() != [] :-S
- call add(tagfiles, g:easytags_file)
- let value = xolox#misc#option#join_tags(tagfiles)
- let cmd = 'set tags=' . escape(value, '\ ')
- if xolox#misc#os#is_win() && v:version < 703
- " TODO How to clear the expression from Vim's status line?
- call feedkeys(":" . cmd . "|let &ro=&ro\<CR>", 'n')
- else
- execute cmd
- endif
- endif
-endfunction
-
" 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 &tags is
" reset, we'll try again on the "VimEnter" automatic command event (below).
-call s:RegisterTagsFile()
+call xolox#easytags#register()
" The :UpdateTags and :HighlightTags commands. {{{1
@@ -175,7 +149,7 @@ augroup PluginEasyTags
" This is the alternative way of registering the global tags file using
" the automatic command event "VimEnter". Apparently this makes the
" plug-in behave better when used together with tplugin?
- autocmd VimEnter * call s:RegisterTagsFile()
+ autocmd VimEnter * call xolox#easytags#register()
" Define the automatic commands to perform updating/highlighting.
for s:eventname in g:easytags_events
execute 'autocmd' s:eventname '* call xolox#easytags#autoload()'