aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--autoload/xolox/easytags.vim18
-rw-r--r--doc/easytags.txt12
-rw-r--r--plugin/easytags.vim14
4 files changed, 40 insertions, 10 deletions
diff --git a/README.md b/README.md
index 350c039..7eaf494 100644
--- a/README.md
+++ b/README.md
@@ -62,6 +62,12 @@ You can enable this option so that the project specific tags files are written i
When you enable this option, the easytags plug-in will use the first filename returned by [tagfiles()](http://vimdoc.sourceforge.net/htmldoc/eval.html#tagfiles%28%29) as the tags file to write. Note that `tagfiles()` is reevaluated every time the plug-in runs.
+### The `g:easytags_by_filetype` option
+
+By default all tags are stored in a global tags file. When the tags file grows beyond a certain size Vim will be slowed down by the easytags plug-in because it has to read and process a large number of tags very frequently.
+
+To avoid this problem you can set `g:easytags_by_filetype` to the path of an existing directory. The easytags plug-in will create separate tags files for each file type in the configured directory. These tags files are automatically registered by the easytags plug-in when the file type of a buffer is set.
+
### The `g:easytags_always_enabled` option
By default the plug-in automatically generates and highlights tags when you stop typing for a few seconds (this works using the [CursorHold](http://vimdoc.sourceforge.net/htmldoc/autocmd.html#CursorHold) automatic command). This means that when you edit a file, the dynamic highlighting won't appear until you pause for a moment. If you don't like this you can configure the plug-in to always enable dynamic highlighting:
diff --git a/autoload/xolox/easytags.vim b/autoload/xolox/easytags.vim
index 3c7f7dd..c78b261 100644
--- a/autoload/xolox/easytags.vim
+++ b/autoload/xolox/easytags.vim
@@ -7,13 +7,14 @@ let s:script = expand('<sfile>:p:~')
" Public interface through (automatic) commands. {{{1
-function! xolox#easytags#register() " {{{2
+function! xolox#easytags#register(global) " {{{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
+ let tagsfile = a:global ? g:easytags_file : xolox#easytags#get_tagsfile()
+ if index(expanded, xolox#misc#path#absolute(tagsfile)) == -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
@@ -21,9 +22,9 @@ function! xolox#easytags#register() " {{{2
" 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)
+ call add(tagfiles, tagsfile)
let value = xolox#misc#option#join_tags(tagfiles)
- let cmd = 'set tags=' . escape(value, '\ ')
+ let cmd = (a:global ? 'set' : 'setl') . ' 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')
@@ -35,7 +36,7 @@ endfunction
function! xolox#easytags#autoload() " {{{2
try
- " Update the entries for the current file in the global tags file?
+ " Update entries for current file in tags file?
let pathname = s:resolve(expand('%:p'))
if pathname != ''
let tags_outdated = getftime(pathname) > getftime(xolox#easytags#get_tagsfile())
@@ -43,7 +44,7 @@ function! xolox#easytags#autoload() " {{{2
call xolox#easytags#update(1, 0, [])
endif
endif
- " Apply highlighting of tags in global tags file to current buffer?
+ " Apply highlighting of tags to current buffer?
if &eventignore !~? '\<syntax\>'
if !exists('b:easytags_last_highlighted')
call xolox#easytags#highlight()
@@ -376,7 +377,10 @@ endfunction
function! xolox#easytags#get_tagsfile() " {{{2
let tagsfile = expand(g:easytags_file)
- if g:easytags_dynamic_files
+ if !empty(g:easytags_by_filetype) && !empty(&filetype)
+ let directory = xolox#misc#path#absolute(g:easytags_by_filetype)
+ let tagsfile = xolox#misc#path#merge(directory, &filetype)
+ elseif g:easytags_dynamic_files
let files = tagfiles()
if len(files) > 0
let tagsfile = files[0]
diff --git a/doc/easytags.txt b/doc/easytags.txt
index 5db1301..4a6a394 100644
--- a/doc/easytags.txt
+++ b/doc/easytags.txt
@@ -132,6 +132,18 @@ returned by |tagfiles()| as the tags file to write. Note that 'tagfiles()' is
reevaluated every time the plug-in runs.
-------------------------------------------------------------------------------
+The *g:easytags_by_filetype* option
+
+By default all tags are stored in a global tags file. When the tags file grows
+beyond a certain size Vim will be slowed down by the easytags plug-in because
+it has to read and process a large number of tags very frequently.
+
+To avoid this problem you can set |g:easytags_by_filetype| to the path of an
+existing directory. The easytags plug-in will create separate tags files for
+each file type in the configured directory. These tags files are automatically
+registered by the easytags plug-in when the file type of a buffer is set.
+
+-------------------------------------------------------------------------------
The *g:easytags_always_enabled* option
By default the plug-in automatically generates and highlights tags when you
diff --git a/plugin/easytags.vim b/plugin/easytags.vim
index e0c07a3..61fe3ed 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.15
+" Version: 2.3
" Support for automatic update using the GLVS plug-in.
" GetLatestVimScripts: 3114 1 :AutoInstall: easytags.zip
@@ -30,6 +30,10 @@ if !exists('g:easytags_dynamic_files')
let g:easytags_dynamic_files = 0
endif
+if !exists('g:easytags_by_filetype')
+ let g:easytags_by_filetype = ''
+endif
+
if !exists('g:easytags_resolve_links')
let g:easytags_resolve_links = 0
endif
@@ -135,7 +139,7 @@ endif
" 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 xolox#easytags#register()
+call xolox#easytags#register(1)
" The :UpdateTags and :HighlightTags commands. {{{1
@@ -149,11 +153,15 @@ 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 xolox#easytags#register()
+ autocmd VimEnter * call xolox#easytags#register(1)
" Define the automatic commands to perform updating/highlighting.
for s:eventname in g:easytags_events
execute 'autocmd' s:eventname '* call xolox#easytags#autoload()'
endfor
+ " Define an automatic command to register file type specific tags files?
+ if !empty(g:easytags_by_filetype)
+ autocmd FileType * call xolox#easytags#register(0)
+ endif
" 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