comparison autoload/gutentags/ctags.vim @ 226:f2fd7d5835d9

Place all the `wildignore` exclude patterns in a generated options file.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 11 Nov 2018 21:48:00 -0800
parents b50b6d0f82dd
children a798f7ad11c5
comparison
equal deleted inserted replaced
225:174cfa3cf21a 226:f2fd7d5835d9
36 " Gutentags Module Interface {{{ 36 " Gutentags Module Interface {{{
37 37
38 let s:did_check_exe = 0 38 let s:did_check_exe = 0
39 let s:runner_exe = gutentags#get_plat_file('update_tags') 39 let s:runner_exe = gutentags#get_plat_file('update_tags')
40 let s:unix_redir = (&shellredir =~# '%s') ? &shellredir : &shellredir . ' %s' 40 let s:unix_redir = (&shellredir =~# '%s') ? &shellredir : &shellredir . ' %s'
41 let s:wildignores_options_path = ''
42 let s:last_wildignores = ''
41 43
42 function! gutentags#ctags#init(project_root) abort 44 function! gutentags#ctags#init(project_root) abort
43 " Figure out the path to the tags file. 45 " Figure out the path to the tags file.
44 " Check the old name for this option, too, before falling back to the 46 " Check the old name for this option, too, before falling back to the
45 " globally defined name. 47 " globally defined name.
145 let l:proj_options_file = s:process_options_file( 147 let l:proj_options_file = s:process_options_file(
146 \a:proj_dir, l:proj_options_file) 148 \a:proj_dir, l:proj_options_file)
147 let l:cmd += ['-o', '"' . l:proj_options_file . '"'] 149 let l:cmd += ['-o', '"' . l:proj_options_file . '"']
148 endif 150 endif
149 if g:gutentags_ctags_exclude_wildignore 151 if g:gutentags_ctags_exclude_wildignore
150 for ign in split(&wildignore, ',') 152 call s:generate_wildignore_options()
151 let l:cmd += ['-x', shellescape(ign, 1)] 153 let l:cmd += ['-x', shellescape('@'.s:wildignores_options_path, 1)]
152 endfor
153 endif 154 endif
154 for exc in g:gutentags_ctags_exclude 155 for exc in g:gutentags_ctags_exclude
155 let l:cmd += ['-x', '"' . exc . '"'] 156 let l:cmd += ['-x', '"' . exc . '"']
156 endfor 157 endfor
157 if g:gutentags_pause_after_update 158 if g:gutentags_pause_after_update
163 let l:cmd = gutentags#make_args(l:cmd) 164 let l:cmd = gutentags#make_args(l:cmd)
164 165
165 call gutentags#trace("Running: " . string(l:cmd)) 166 call gutentags#trace("Running: " . string(l:cmd))
166 call gutentags#trace("In: " . getcwd()) 167 call gutentags#trace("In: " . getcwd())
167 if !g:gutentags_fake 168 if !g:gutentags_fake
168 let l:job_opts = gutentags#build_default_job_options('ctags') 169 let l:job_opts = gutentags#build_default_job_options('ctags')
169 let l:job = gutentags#start_job(l:cmd, l:job_opts) 170 let l:job = gutentags#start_job(l:cmd, l:job_opts)
170 call gutentags#add_job('ctags', a:tags_file, l:job) 171 call gutentags#add_job('ctags', a:tags_file, l:job)
171 else 172 else
172 call gutentags#trace("(fake... not actually running)") 173 call gutentags#trace("(fake... not actually running)")
173 endif 174 endif
193 let l:proj_info = gutentags#get_project_info(a:proj_dir) 194 let l:proj_info = gutentags#get_project_info(a:proj_dir)
194 let l:type = get(l:proj_info, 'type', l:ftype) 195 let l:type = get(l:proj_info, 'type', l:ftype)
195 let exepath = exists('g:gutentags_ctags_executable_{l:type}') 196 let exepath = exists('g:gutentags_ctags_executable_{l:type}')
196 \ ? g:gutentags_ctags_executable_{l:type} : g:gutentags_ctags_executable 197 \ ? g:gutentags_ctags_executable_{l:type} : g:gutentags_ctags_executable
197 return expand(exepath, 1) 198 return expand(exepath, 1)
199 endfunction
200
201 function! s:generate_wildignore_options() abort
202 if s:last_wildignores == &wildignore
203 " The 'wildignore' setting didn't change since last time we did this.
204 call gutentags#trace("Wildignore options file is up to date.")
205 return
206 endif
207
208 if s:wildignores_options_path == ''
209 if empty(g:gutentags_cache_dir)
210 let s:wildignores_options_path = tempname()
211 else
212 let s:wildignores_options_path =
213 \gutentags#stripslash(g:gutentags_cache_dir).
214 \'/_wildignore.options'
215 endif
216 endif
217
218 call gutentags#trace("Generating wildignore options: ".s:wildignores_options_path)
219 let l:opt_lines = []
220 for ign in split(&wildignore, ',')
221 call add(l:opt_lines, '--exclude='.ign)
222 endfor
223 call writefile(l:opt_lines, s:wildignores_options_path)
224 let s:last_wildignores = &wildignore
198 endfunction 225 endfunction
199 226
200 function! s:process_options_file(proj_dir, path) abort 227 function! s:process_options_file(proj_dir, path) abort
201 if empty(g:gutentags_cache_dir) 228 if empty(g:gutentags_cache_dir)
202 " If we're not using a cache directory to store tag files, we can 229 " If we're not using a cache directory to store tag files, we can