Skip to content

Commit

Permalink
Make "easytags_dynamic_files" create missing tags files
Browse files Browse the repository at this point in the history
Suggested by Strahinja Marković in GitHub issue #15:
#15
  • Loading branch information
xolox committed Aug 31, 2011
1 parent 2860329 commit d2a2cb5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 27 deletions.
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -72,19 +72,19 @@ You can enable this option so that the project specific tags files are written i

:let g:easytags_dynamic_files = 1

When you enable this option, the easytags plug-in will use the first filename returned by [tagfiles()] [tagfiles_fun] as the tags file to write. Note that `tagfiles()` is reevaluated every time the plug-in runs.
When you enable this option, the easytags plug-in will expand the ['tags' option] [tags_opt] and use the first filename (whether the file exists or not). The tags option is reevaluated each time the plug-in runs, so the results can differ depending on the location of the current buffer or working directory.

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.
Note that this option takes precedence over `g:easytags_by_filetype`.

### 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 the `g:easytags_dynamic_files` option takes precedence over this option.

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`.
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

Expand Down
20 changes: 10 additions & 10 deletions autoload/xolox/easytags.vim
@@ -1,9 +1,9 @@
" Vim script
" Author: Peter Odding <peter@peterodding.com>
" Last Change: August 27, 2011
" Last Change: August 31, 2011
" URL: http://peterodding.com/code/vim/easytags/

let g:xolox#easytags#version = '2.4.12'
let g:xolox#easytags#version = '2.5'

" Public interface through (automatic) commands. {{{1

Expand Down Expand Up @@ -518,20 +518,20 @@ 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?
let tagsfile = ''
" Look for a suitable project specific tags file?
if xolox#misc#option#get('easytags_dynamic_files', 0)
let files = tagfiles()
if len(files) > 0 && filewritable(files[0]) == 1
return files[0]
endif
let tagsfile = xolox#misc#option#eval_tags(&tags, 1)
endif
" Default to the global tags file.
let tagsfile = expand(xolox#misc#option#get('easytags_file'))
" Check if a file type specific tags file is useful?
if !empty(g:easytags_by_filetype) && index(xolox#easytags#supported_filetypes(), &ft) >= 0
if empty(tagsfile) && !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)
endif
" Default to the global tags file?
if empty(tagsfile)
let tagsfile = expand(xolox#misc#option#get('easytags_file'))
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!"
Expand Down
22 changes: 9 additions & 13 deletions doc/easytags.txt
Expand Up @@ -149,13 +149,12 @@ instead of the global tags file:
>
:let g:easytags_dynamic_files = 1
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.
When you enable this option, the easytags plug-in will expand the |'tags'|
option and use the first filename (whether the file exists or not). The tags
option is reevaluated each time the plug-in runs, so the results can differ
depending on the location of the current buffer or working directory.

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.
Note that this option takes precedence over |g:easytags_by_filetype|.

-------------------------------------------------------------------------------
The *g:easytags_by_filetype* option
Expand All @@ -169,14 +168,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 the |g:easytags_dynamic_files| option takes precedence over this
option.

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'.
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
Expand Down

0 comments on commit d2a2cb5

Please sign in to comment.