Skip to content

Commit ffa0dee

Browse files
committed
Add a 'bang' version of TagsGenerate command
1 parent e6f1815 commit ffa0dee

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
vim-tags
22
========
33

4-
Vim-Tags version 0.0.2
4+
Vim-Tags version 0.0.3
55
----------------------
66

77
The Ctags generator for Vim
@@ -58,6 +58,12 @@ support just create empty "tags" file:
5858

5959
and start Vim. On first file saving (any file is considered), the tags will be generated.
6060

61+
The `:TagsGenerate` command has also a `bang` version:
62+
63+
:TagsGenerate!
64+
65+
The `bang` version of the command forces generation for all "tags" files.
66+
6167
Additionally, you can exclude some directories from the main "tags" file, especially if they
6268
contains rarely changed and heavy content, i.e. third-party libraries. Those directories must be
6369
placed directly at the root.

doc/vim-tags.txt

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
*vim-tags.txt* For Vim version 7.3 Last change: 2012-12-29
1+
*vim-tags.txt* For Vim version 7.3 Last change: 2013-01-18
22
*vim-tags*
33

44

55

66

77

8-
Vim-Tags version 0.0.2~
8+
Vim-Tags version 0.0.3~
99

1010
The Ctags generator for Vim~
1111

@@ -65,6 +65,14 @@ file: >
6565
and start Vim. On first file saving (any file is considered), the tags will be
6666
generated.
6767

68+
The :TagsGenerate command has also a 'bang' version: >
69+
70+
:TagsGenerate!
71+
72+
<
73+
74+
The 'bang' version of the command forces generation of all 'tags' files.
75+
6876
Additionally, you can exclude some directories from the main "tags" file,
6977
especially if they contains rarely changed and heavy content, i.e.
7078
third-party libraries. Those directories must be placed directly at the root.

plugin/tags.vim

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" vim-tags - The Ctags generator for Vim
22
" Maintainer: Szymon Wrozynski
3-
" Version: 0.0.2
3+
" Version: 0.0.3
44
"
55
" Installation:
66
" Place in ~/.vim/plugin/tags.vim or in case of Pathogen:
@@ -36,7 +36,7 @@ if !exists('g:vim_tags_gems_tags_command')
3636
let g:vim_tags_gems_tags_command = "ctags -R -f Gemfile.lock.tags `bundle show --paths` 2>/dev/null &"
3737
endif
3838

39-
command! -nargs=0 TagsGenerate :call s:generate_tags(1)
39+
command! -bang -nargs=0 TagsGenerate :call s:generate_tags('<bang>', 1)
4040

4141
" Generate options and custom dirs list
4242
let options = []
@@ -56,7 +56,14 @@ endfor
5656

5757
let s:options = join(options, ' ')
5858

59-
fun! s:generate_tags(redraw)
59+
fun! s:generate_tags(bang, redraw)
60+
"Remove existing tags
61+
if a:bang == '!'
62+
for f in split(globpath('.', '*.tags', 1), '\n') + ['tags']
63+
call writefile([], f, 'b')
64+
endfor
65+
endif
66+
6067
"Custom tags files
6168
for dir_name in s:custom_dirs
6269
let file_name = dir_name . '.tags'
@@ -79,7 +86,7 @@ fun! s:generate_tags(redraw)
7986
if gemfile_time > -1
8087
let gems_time = getftime('Gemfile.lock.tags')
8188
if gems_time > -1
82-
if gems_time < gemfile_time
89+
if (gems_time < gemfile_time) || (getfsize('Gemfile.lock.tags') == 0)
8390
silent! exe '!' . g:vim_tags_gems_tags_command
8491
endif
8592
else
@@ -94,5 +101,5 @@ fun! s:generate_tags(redraw)
94101
endfun
95102

96103
if filereadable('tags') && g:vim_tags_auto_generate
97-
au BufWritePost * call s:generate_tags(0)
104+
au BufWritePost * call s:generate_tags('', 0)
98105
endif

0 commit comments

Comments
 (0)