Skip to content

Commit c9cd1f9

Browse files
committed
Handle negated patterns in ignore files
Fix #4
1 parent 018f5ed commit c9cd1f9

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

doc/vim-tags.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
*vim-tags.txt* For Vim version 7.3 Last change: 2013-04-09
1+
*vim-tags.txt* For Vim version 7.3 Last change: 2013-04-28
22
*vim-tags*
33

44

55

66

77

8-
Vim-Tags version 0.0.7~
8+
Vim-Tags version 0.0.8~
99

1010
The Ctags generator for Vim~
1111

plugin/tags.vim

+15-3
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.7
3+
" Version: 0.0.8
44
"
55
" Installation:
66
" Place in ~/.vim/plugin/tags.vim or in case of Pathogen:
@@ -73,11 +73,15 @@ command! -bang -nargs=0 TagsGenerate :call s:generate_tags(<bang>0, 1)
7373
let options = ['--tag-relative']
7474
let s:custom_dirs = []
7575

76-
" Exclude ignored files and directories
76+
let s:files_to_include = []
77+
78+
" Exclude ignored files and directories (also handle negated patterns (!))
7779
for ignore_file in g:vim_tags_ignore_files
7880
if filereadable(ignore_file)
7981
for line in readfile(ignore_file)
80-
if strlen(line) > 1 && match(line, g:vim_tags_ignore_file_comment_pattern) == -1
82+
if match(line, '^!') != -1
83+
call add(s:files_to_include, substitute(substitute(line, '^!', '', ''), '^/', '', ''))
84+
elseif strlen(line) > 1 && match(line, g:vim_tags_ignore_file_comment_pattern) == -1
8185
call add(options, '--exclude=' . shellescape(substitute(line, '^/', '', '')))
8286
endif
8387
endfor
@@ -146,6 +150,14 @@ fun! s:generate_tags(bang, redraw)
146150
let project_tags_command = substitute(project_tags_command, '{DIRECTORY}', '.', '')
147151
call s:execute_async_command(project_tags_command)
148152

153+
" Append files from negated patterns
154+
if !empty(s:files_to_include)
155+
let append_command_template = substitute(g:vim_tags_project_tags_command, '{OPTIONS}', '--tag-relative -a -f ' . s:tags_directory . '/' . g:vim_tags_main_file, '')
156+
for file_to_include in s:files_to_include
157+
call s:execute_async_command(substitute(append_command_template, '{DIRECTORY}', file_to_include, ''))
158+
endfor
159+
endif
160+
149161
"Gemfile.lock
150162
let gemfile_time = getftime('Gemfile.lock')
151163
if gemfile_time > -1

0 commit comments

Comments
 (0)