Skip to content

Commit fae8ddd

Browse files
committed
Improve easytags_dynamic_files implementation (best of both worlds?)
Some users want the plug-in to use existing project specific tags files but fall back to the global tags file or a file type specific tags file if a project specific tags file does not exist. Other users want the plug-in to automatically create project specific tags files. Both are reasonable options to have. I hope with this change we can all be happy :-) (see also issue #15 and issue #16 on GitHub).
1 parent ef7c6f8 commit fae8ddd

3 files changed

Lines changed: 28 additions & 20 deletions

File tree

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,16 @@ A leading `~` in the `g:easytags_file` variable is expanded to your current home
6464

6565
### The `g:easytags_dynamic_files` option
6666

67-
By default `:UpdateTags` only writes to the global tags file. If you use the following setting to enable project specific tags files:
67+
By default `:UpdateTags` only writes to the global tags file, but it can be configured to look for project specific tags files by adding the following lines to your [vimrc script] [vimrc]:
6868

6969
:set tags=./tags;
70-
71-
You can enable this option so that the project specific tags files are written instead of the global tags file:
72-
7370
:let g:easytags_dynamic_files = 1
7471

75-
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.
72+
You can change the name of the tags file, the important thing is that it's relative to your working directory or the buffer (using a leading `./`). When `g:easytags_dynamic_files` is set to 1 the easytags plug-in will write to the first existing tags file seen by Vim (based on the ['tags' option] [tags_opt]). In other words: If a project specific tags file is found it will be used, otherwise the plug-in falls back to the global tags file (or a file type specific tags file).
73+
74+
If you set `g:easytags_dynamic_files` to 2 the easytags plug-in will automatically create project specific tags based on the first name in the 'tags' option. This disables the global tags file and file type specific tags files.
7675

77-
Note that this option takes precedence over `g:easytags_by_filetype`.
76+
The ['tags' option] [tags_opt] is reevaluated each time the plug-in runs, so which tags file is selected can differ depending on the buffer and working directory.
7877

7978
### The `g:easytags_by_filetype` option
8079

autoload/xolox/easytags.vim

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" Last Change: September 5, 2011
44
" URL: http://peterodding.com/code/vim/easytags/
55

6-
let g:xolox#easytags#version = '2.5.6'
6+
let g:xolox#easytags#version = '2.5.7'
77

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

@@ -530,7 +530,10 @@ endfunction
530530
function! xolox#easytags#get_tagsfile() " {{{2
531531
let tagsfile = ''
532532
" Look for a suitable project specific tags file?
533-
if xolox#misc#option#get('easytags_dynamic_files', 0)
533+
let dynamic_files = xolox#misc#option#get('easytags_dynamic_files', 0)
534+
if dynamic_files == 1
535+
let tagsfile = get(tagfiles(), 0, '')
536+
elseif dynamic_files == 2
534537
let tagsfile = xolox#misc#option#eval_tags(&tags, 1)
535538
endif
536539
" Check if a file type specific tags file is useful?

doc/easytags.txt

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,22 +139,28 @@ home directory ('$HOME' on UNIX, '%USERPROFILE%' on Windows).
139139
-------------------------------------------------------------------------------
140140
The *g:easytags_dynamic_files* option
141141

142-
By default |:UpdateTags| only writes to the global tags file. If you use the
143-
following setting to enable project specific tags files:
142+
By default |:UpdateTags| only writes to the global tags file, but it can be
143+
configured to look for project specific tags files by adding the following
144+
lines to your |vimrc| script:
144145
>
145146
:set tags=./tags;
146-
147-
You can enable this option so that the project specific tags files are written
148-
instead of the global tags file:
149-
>
150147
:let g:easytags_dynamic_files = 1
151148
152-
When you enable this option, the easytags plug-in will expand the |'tags'|
153-
option and use the first filename (whether the file exists or not). The tags
154-
option is reevaluated each time the plug-in runs, so the results can differ
155-
depending on the location of the current buffer or working directory.
156-
157-
Note that this option takes precedence over |g:easytags_by_filetype|.
149+
You can change the name of the tags file, the important thing is that it's
150+
relative to your working directory or the buffer (using a leading './'). When
151+
|g:easytags_dynamic_files| is set to 1 the easytags plug-in will write to the
152+
first existing tags file seen by Vim (based on the |'tags'| option). In other
153+
words: If a project specific tags file is found it will be used, otherwise the
154+
plug-in falls back to the global tags file (or a file type specific tags
155+
file).
156+
157+
If you set |g:easytags_dynamic_files| to 2 the easytags plug-in will
158+
automatically create project specific tags based on the first name in the
159+
'tags' option. This disables the global tags file and file type specific tags
160+
files.
161+
162+
The |'tags'| option is reevaluated each time the plug-in runs, so which tags
163+
file is selected can differ depending on the buffer and working directory.
158164

159165
-------------------------------------------------------------------------------
160166
The *g:easytags_by_filetype* option

0 commit comments

Comments
 (0)