comparison autoload/gutentags/ctags.vim @ 117:df3b0ca48013

Merge pull request #64 from GitHub.
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 25 Mar 2016 20:41:38 -0700
parents 05fc1e2172cc be8d47e88ab1
children a66d90fd758b
comparison
equal deleted inserted replaced
112:563fbba43288 117:df3b0ca48013
25 " }}} 25 " }}}
26 26
27 " Gutentags Module Interface {{{ 27 " Gutentags Module Interface {{{
28 28
29 let s:runner_exe = gutentags#get_plat_file('update_tags') 29 let s:runner_exe = gutentags#get_plat_file('update_tags')
30 let s:unix_redir = (&shellredir =~# '%s') ? &shellredir : &shellredir . ' %s'
30 31
31 function! gutentags#ctags#init(project_root) abort 32 function! gutentags#ctags#init(project_root) abort
32 " Figure out the path to the tags file. 33 " Figure out the path to the tags file.
33 let b:gutentags_files['ctags'] = gutentags#get_cachefile( 34 let b:gutentags_files['ctags'] = gutentags#get_cachefile(
34 \a:project_root, g:gutentags_tagfile) 35 \a:project_root, g:gutentags_tagfile)
61 \":GutentagsUpdate!.") 62 \":GutentagsUpdate!.")
62 return 63 return
63 endif 64 endif
64 endif 65 endif
65 66
66 if g:gutentags_cache_dir == "" 67 if empty(g:gutentags_cache_dir)
67 " If we don't use the cache directory, let's just use the tag filename 68 " If we don't use the cache directory, let's just use the tag filename
68 " as specified by the user, and change the working directory to the 69 " as specified by the user, and change the working directory to the
69 " project root. 70 " project root.
70 " Note that if we don't do this and pass a full path, `ctags` gets 71 " Note that if we don't do this and pass a full path, `ctags` gets
71 " confused if the paths have spaces -- but not if you're *in* the 72 " confused if the paths have spaces -- but not if you're *in* the
91 let l:cmd .= ' -s "' . l:full_path . '"' 92 let l:cmd .= ' -s "' . l:full_path . '"'
92 endif 93 endif
93 " Pass the Gutentags options file first, and then the project specific 94 " Pass the Gutentags options file first, and then the project specific
94 " one, so that users can override the default behaviour. 95 " one, so that users can override the default behaviour.
95 let l:cmd .= ' -o "' . gutentags#get_res_file('ctags.options') . '"' 96 let l:cmd .= ' -o "' . gutentags#get_res_file('ctags.options') . '"'
96 let l:proj_options_file = a:proj_dir . '/' . 97 let l:proj_options_file = a:proj_dir . '/' .
97 \g:gutentags_ctags_options_file 98 \g:gutentags_ctags_options_file
98 if filereadable(l:proj_options_file) 99 if filereadable(l:proj_options_file)
99 let l:proj_options_file = s:process_options_file( 100 let l:proj_options_file = s:process_options_file(
100 \a:proj_dir, l:proj_options_file) 101 \a:proj_dir, l:proj_options_file)
101 let l:cmd .= ' -o "' . l:proj_options_file . '"' 102 let l:cmd .= ' -o "' . l:proj_options_file . '"'
111 endif 112 endif
112 if g:gutentags_trace 113 if g:gutentags_trace
113 if has('win32') 114 if has('win32')
114 let l:cmd .= ' -l "' . l:actual_tags_file . '.log"' 115 let l:cmd .= ' -l "' . l:actual_tags_file . '.log"'
115 else 116 else
116 let l:cmd .= ' > "' . l:actual_tags_file . '.log" 2>&1' 117 let l:cmd .= ' ' . printf(s:unix_redir, '"' . l:actual_tags_file . '.log"')
117 endif 118 endif
118 else 119 else
119 if !has('win32') 120 if !has('win32')
120 let l:cmd .= ' > /dev/null 2>&1' 121 let l:cmd .= ' ' . printf(s:unix_redir, '/dev/null')
121 endif 122 endif
122 endif 123 endif
123 let l:cmd .= gutentags#get_execute_cmd_suffix() 124 let l:cmd .= gutentags#get_execute_cmd_suffix()
124 125
125 call gutentags#trace("Running: " . l:cmd) 126 call gutentags#trace("Running: " . l:cmd)
161 return g:gutentags_ctags_executable 162 return g:gutentags_ctags_executable
162 endif 163 endif
163 endfunction 164 endfunction
164 165
165 function! s:process_options_file(proj_dir, path) abort 166 function! s:process_options_file(proj_dir, path) abort
166 if g:gutentags_cache_dir == "" 167 if empty(g:gutentags_cache_dir)
167 " If we're not using a cache directory to store tag files, we can 168 " If we're not using a cache directory to store tag files, we can
168 " use the options file straight away. 169 " use the options file straight away.
169 return a:path 170 return a:path
170 endif 171 endif
171 172
226 call writefile(l:outlines, l:out_path) 227 call writefile(l:outlines, l:out_path)
227 return l:out_path 228 return l:out_path
228 endfunction 229 endfunction
229 230
230 " }}} 231 " }}}
231