Permalink
Browse files

Allow enabling both dynamic and file type tags files

When both options are enabled, project specific tags files take
precedence if they exist and are writable, otherwise a file type
tags file is used.

(Stuart wrote this code, Peter added the check for supported file types)
  • Loading branch information...
Kenny Stuart authored and xolox committed Jun 24, 2011
1 parent e454233 commit d727ac0cb7b03747d0688d939210af07da4cad60
Showing with 27 additions and 9 deletions.
  1. +4 −0 README.md
  2. +12 −7 autoload/xolox/easytags.vim
  3. +9 −0 doc/easytags.txt
  4. +2 −2 plugin/easytags.vim
View
@@ -66,12 +66,16 @@ 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.
If you've also enabled `g:easytags_by_filetype` the project specific tags file must exist, even if it's empty; otherwise `g:easytags_by_filetype` will take precedence.
### 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.
If you've also enabled `g:easytags_dynamic_files` and the project specific tags file exists, and is writable, it will take precedence. If the project specific tags file doesn't exist you can indicate you want to use project specific tags by creating it.
Note that if you already have a global tags file you can create file type specific tags files from the global tags file using the command `:TagsByFileType`.
### The `g:easytags_always_enabled` option
@@ -1,6 +1,6 @@
" Vim script
" Author: Peter Odding <peter@peterodding.com>
" Last Change: June 18, 2011
" Last Change: June 24, 2011
" URL: http://peterodding.com/code/vim/easytags/
" Public interface through (automatic) commands. {{{1
@@ -483,16 +483,21 @@ function! s:cache_tagged_files_in(fname, ftime, entries) " {{{3
endfunction
function! xolox#easytags#get_tagsfile() " {{{2
" Look for a writable project specific tags file?
if g:easytags_dynamic_files
let files = tagfiles()
if len(files) > 0 && filewritable(files[0]) == 1
return files[0]
endif
endif
" Default to the global tags file.
let tagsfile = expand(g:easytags_file)
if !empty(g:easytags_by_filetype) && !empty(&filetype)
" Check if a file type specific tags file is useful?
if !empty(g:easytags_by_filetype) && index(xolox#easytags#supported_filetypes(), &ft) >= 0
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]
endif
endif
" If the tags file exists, make sure it is writable!
if filereadable(tagsfile) && filewritable(tagsfile) != 1
let message = "The tags file %s isn't writable!"
throw printf(message, fnamemodify(tagsfile, ':~'))
View
@@ -139,6 +139,10 @@ When you enable this option, the easytags plug-in will use the first filename
returned by |tagfiles()| as the tags file to write. Note that 'tagfiles()' is
reevaluated every time the plug-in runs.
If you've also enabled |g:easytags_by_filetype| the project specific tags file
must exist, even if it's empty; otherwise |g:easytags_by_filetype| will take
precedence.
-------------------------------------------------------------------------------
The *g:easytags_by_filetype* option
@@ -151,6 +155,11 @@ 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.
If you've also enabled |g:easytags_dynamic_files| and the project specific
tags file exists, and is writable, it will take precedence. If the project
specific tags file doesn't exist you can indicate you want to use project
specific tags by creating it.
Note that if you already have a global tags file you can create file type
specific tags files from the global tags file using the command
':TagsByFileType'.
View
@@ -1,6 +1,6 @@
" Vim plug-in
" Author: Peter Odding <peter@peterodding.com>
" Last Change: June 18, 2011
" Last Change: June 24, 2011
" URL: http://peterodding.com/code/vim/easytags/
" Requires: Exuberant Ctags (http://ctags.sf.net)
@@ -12,7 +12,7 @@ if &cp || exists('g:loaded_easytags')
finish
endif
let g:easytags_version = '2.4.3'
let g:easytags_version = '2.4.4'
" Configuration defaults and initialization. {{{1

0 comments on commit d727ac0

Please sign in to comment.