|
1 |
+ |
scriptencoding utf-8 |
|
2 |
+ |
|
|
3 |
+ |
let s:LOGGER =SpaceVim#logger#derive('gtags') |
|
4 |
+ |
|
|
5 |
+ |
if !executable('gtags') |
|
6 |
+ |
call s:LOGGER.warn('gtags is not executable, you need to install gnu global!') |
|
7 |
+ |
finish |
|
8 |
+ |
endif |
|
9 |
+ |
|
|
10 |
+ |
if exists('g:loaded_gtags') |
|
11 |
+ |
finish |
|
12 |
+ |
endif |
|
13 |
+ |
let s:JOB = SpaceVim#api#import('job') |
|
14 |
+ |
let s:FILE = SpaceVim#api#import('file') |
|
15 |
+ |
|
|
16 |
+ |
let g:loaded_gtags = 1 |
|
17 |
+ |
let s:version = split(matchstr(split(system('gtags --version'), '\n')[0], '[0-9]\+\.[0-9]\+'), '\.') |
|
18 |
+ |
|
|
19 |
+ |
"" |
|
20 |
+ |
" Set the global command name. If it is not set, will use $GTAGSGLOBAL, and if |
|
21 |
+ |
" $GTAGSGLOBAL still is an empty string, then will use 'global'. |
|
22 |
+ |
let g:gtags_global_command = get(g:, 'gtags_global_command', |
|
23 |
+ |
\ empty($GTAGSGLOBAL) ? 'global' : $GTAGSGLOBAL |
|
24 |
+ |
\ ) |
|
25 |
+ |
|
|
26 |
+ |
"" |
|
27 |
+ |
" Enable/Disable default mappings. By default it is disabled. |
|
28 |
+ |
let g:gtags_auto_map = get(g:, 'gtags_auto_map', 0) |
|
29 |
+ |
|
|
30 |
+ |
"" |
|
31 |
+ |
" This setting will open the |quickfix| list when adding entries. A value of 2 will |
|
32 |
+ |
" preserve the cursor position when the |quickfix| window is |
|
33 |
+ |
" opened. Defaults to 2. |
|
34 |
+ |
let g:gtags_open_list = get(g:, 'gtags_open_list', 2) |
|
35 |
+ |
|
|
36 |
+ |
" -- ctags-x format |
|
37 |
+ |
" let Gtags_Result = "ctags-x" |
|
38 |
+ |
" let Gtags_Efm = "%*\\S%*\\s%l%\\s%f%\\s%m" |
|
39 |
+ |
" |
|
40 |
+ |
" -- ctags format |
|
41 |
+ |
" let Gtags_Result = "ctags" |
|
42 |
+ |
" let Gtags_Efm = "%m\t%f\t%l" |
|
43 |
+ |
" |
|
44 |
+ |
" Gtags_Use_Tags_Format is obsoleted. |
|
45 |
+ |
if exists('g:Gtags_Use_Tags_Format') |
|
46 |
+ |
let g:Gtags_Result = 'ctags' |
|
47 |
+ |
let g:Gtags_Efm = "%m\t%f\t%l" |
|
48 |
+ |
endif |
|
49 |
+ |
if !exists('g:Gtags_Result') |
|
50 |
+ |
let g:Gtags_Result = 'ctags-x' |
|
51 |
+ |
endif |
|
52 |
+ |
if !exists('g:Gtags_Efm') |
|
53 |
+ |
let g:Gtags_Efm = "%*\\S%*\\s%l%\\s%f%\\s%m" |
|
54 |
+ |
endif |
|
55 |
+ |
" Character to use to quote patterns and file names before passing to global. |
|
56 |
+ |
" (This code was drived from 'grep.vim'.) |
|
57 |
+ |
if !exists('g:Gtags_Shell_Quote_Char') |
|
58 |
+ |
if has('win32') || has('win16') || has('win95') |
|
59 |
+ |
let g:Gtags_Shell_Quote_Char = '"' |
|
60 |
+ |
else |
|
61 |
+ |
let g:Gtags_Shell_Quote_Char = "'" |
|
62 |
+ |
endif |
|
63 |
+ |
endif |
|
64 |
+ |
if !exists('g:Gtags_Single_Quote_Char') |
|
65 |
+ |
if has('win32') || has('win16') || has('win95') |
|
66 |
+ |
let g:Gtags_Single_Quote_Char = "'" |
|
67 |
+ |
let g:Gtags_Double_Quote_Char = '\"' |
|
68 |
+ |
else |
|
69 |
+ |
let s:sq = "'" |
|
70 |
+ |
let s:dq = '"' |
|
71 |
+ |
let g:Gtags_Single_Quote_Char = s:sq . s:dq . s:sq . s:dq . s:sq |
|
72 |
+ |
let g:Gtags_Double_Quote_Char = '"' |
|
73 |
+ |
endif |
|
74 |
+ |
endif |
|
75 |
+ |
|
|
76 |
+ |
" |
|
77 |
+ |
" Stack Object. |
|
78 |
+ |
" |
|
79 |
+ |
function! s:Stack() abort |
|
80 |
+ |
let l:this = {} |
|
81 |
+ |
let l:this.container = [] |
|
82 |
+ |
|
|
83 |
+ |
function! l:this.push(item) abort |
|
84 |
+ |
call add(self.container, a:item) |
|
85 |
+ |
endfunction |
|
86 |
+ |
|
|
87 |
+ |
function! l:this.pop() abort |
|
88 |
+ |
if len(self.container) <= 0 |
|
89 |
+ |
throw 'Stack Empty' |
|
90 |
+ |
endif |
|
91 |
+ |
|
|
92 |
+ |
let l:item = self.container[-1] |
|
93 |
+ |
unlet self.container[-1] |
|
94 |
+ |
|
|
95 |
+ |
return l:item |
|
96 |
+ |
endfunction |
|
97 |
+ |
|
|
98 |
+ |
return l:this |
|
99 |
+ |
endfunction |
|
100 |
+ |
|
|
101 |
+ |
function! s:Memorize() abort |
|
102 |
+ |
let l:data = { |
|
103 |
+ |
\'file': expand('%'), |
|
104 |
+ |
\'position': getpos('.'), |
|
105 |
+ |
\} |
|
106 |
+ |
call s:crumbs.push(l:data) |
|
107 |
+ |
endfunction |
|
108 |
+ |
|
|
109 |
+ |
function! gtags#remind() abort |
|
110 |
+ |
try |
|
111 |
+ |
let l:data = s:crumbs.pop() |
|
112 |
+ |
catch |
|
113 |
+ |
call s:Error(v:exception) |
|
114 |
+ |
return |
|
115 |
+ |
endtry |
|
116 |
+ |
|
|
117 |
+ |
execute 'e ' . l:data.file |
|
118 |
+ |
call setpos('.', l:data.position) |
|
119 |
+ |
endfunction |
|
120 |
+ |
|
|
121 |
+ |
if ! exists('s:crumbs') |
|
122 |
+ |
let s:crumbs = s:Stack() |
|
123 |
+ |
endif |
|
124 |
+ |
|
|
125 |
+ |
" |
|
126 |
+ |
" Display error message. |
|
127 |
+ |
" |
|
128 |
+ |
function! s:Error(msg) abort |
|
129 |
+ |
echohl WarningMsg | |
|
130 |
+ |
\ echomsg 'Error: ' . a:msg | |
|
131 |
+ |
\ echohl None |
|
132 |
+ |
endfunction |
|
133 |
+ |
" |
|
134 |
+ |
" Extract pattern or option string. |
|
135 |
+ |
" |
|
136 |
+ |
function! s:Extract(line, target) abort |
|
137 |
+ |
let l:option = '' |
|
138 |
+ |
let l:pattern = '' |
|
139 |
+ |
let l:force_pattern = 0 |
|
140 |
+ |
let l:length = strlen(a:line) |
|
141 |
+ |
let l:i = 0 |
|
142 |
+ |
|
|
143 |
+ |
" skip command name. |
|
144 |
+ |
if a:line =~# '^Gtags' |
|
145 |
+ |
let l:i = 5 |
|
146 |
+ |
endif |
|
147 |
+ |
while l:i < l:length && a:line[l:i] ==# ' ' |
|
148 |
+ |
let l:i = l:i + 1 |
|
149 |
+ |
endwhile |
|
150 |
+ |
while l:i < l:length |
|
151 |
+ |
if a:line[l:i] ==# '-' && l:force_pattern == 0 |
|
152 |
+ |
let l:i = l:i + 1 |
|
153 |
+ |
" Ignore long name option like --help. |
|
154 |
+ |
if l:i < l:length && a:line[l:i] ==# '-' |
|
155 |
+ |
while l:i < l:length && a:line[l:i] !=# ' ' |
|
156 |
+ |
let l:i = l:i + 1 |
|
157 |
+ |
endwhile |
|
158 |
+ |
else |
|
159 |
+ |
let l:c = '' |
|
160 |
+ |
while l:i < l:length && a:line[l:i] !=# ' ' |
|
161 |
+ |
let l:c = a:line[l:i] |
|
162 |
+ |
let l:option = l:option . l:c |
|
163 |
+ |
let l:i = l:i + 1 |
|
164 |
+ |
endwhile |
|
165 |
+ |
if l:c ==# 'e' |
|
166 |
+ |
let l:force_pattern = 1 |
|
167 |
+ |
endif |
|
168 |
+ |
endif |
|
169 |
+ |
else |
|
170 |
+ |
let l:pattern = '' |
|
171 |
+ |
" allow pattern includes blanks. |
|
172 |
+ |
while l:i < l:length |
|
173 |
+ |
if a:line[l:i] ==# "'" |
|
174 |
+ |
let l:pattern = l:pattern . g:Gtags_Single_Quote_Char |
|
175 |
+ |
elseif a:line[l:i] ==# '"' |
|
176 |
+ |
let l:pattern = l:pattern . g:Gtags_Double_Quote_Char |
|
177 |
+ |
else |
|
178 |
+ |
let l:pattern = l:pattern . a:line[l:i] |
|
179 |
+ |
endif |
|
180 |
+ |
let l:i = l:i + 1 |
|
181 |
+ |
endwhile |
|
182 |
+ |
if a:target ==# 'pattern' |
|
183 |
+ |
return l:pattern |
|
184 |
+ |
endif |
|
185 |
+ |
endif |
|
186 |
+ |
" Skip blanks. |
|
187 |
+ |
while l:i < l:length && a:line[l:i] ==# ' ' |
|
188 |
+ |
let l:i = l:i + 1 |
|
189 |
+ |
endwhile |
|
190 |
+ |
endwhile |
|
191 |
+ |
if a:target ==# 'option' |
|
192 |
+ |
return l:option |
|
193 |
+ |
endif |
|
194 |
+ |
return '' |
|
195 |
+ |
endfunction |
|
196 |
+ |
|
|
197 |
+ |
" |
|
198 |
+ |
" Trim options to avoid errors. |
|
199 |
+ |
" |
|
200 |
+ |
function! s:TrimOption(option) abort |
|
201 |
+ |
let l:option = '' |
|
202 |
+ |
let l:length = strlen(a:option) |
|
203 |
+ |
let l:i = 0 |
|
204 |
+ |
|
|
205 |
+ |
while l:i < l:length |
|
206 |
+ |
let l:c = a:option[l:i] |
|
207 |
+ |
if l:c !~# '[cenpquv]' |
|
208 |
+ |
let l:option = l:option . l:c |
|
209 |
+ |
endif |
|
210 |
+ |
let l:i = l:i + 1 |
|
211 |
+ |
endwhile |
|
212 |
+ |
return l:option |
|
213 |
+ |
endfunction |
|
214 |
+ |
|
|
215 |
+ |
" |
|
216 |
+ |
" Execute global and load the result into quickfix window. |
|
217 |
+ |
" |
|
218 |
+ |
function! s:ExecLoad(option, long_option, pattern) abort |
|
219 |
+ |
" Execute global(1) command and write the result to a temporary file. |
|
220 |
+ |
let l:isfile = 0 |
|
221 |
+ |
let l:option = '' |
|
222 |
+ |
let l:result = '' |
|
223 |
+ |
|
|
224 |
+ |
if a:option =~# 'f' |
|
225 |
+ |
let l:isfile = 1 |
|
226 |
+ |
if filereadable(a:pattern) == 0 |
|
227 |
+ |
call s:Error('File ' . a:pattern . ' not found.') |
|
228 |
+ |
return |
|
229 |
+ |
endif |
|
230 |
+ |
endif |
|
231 |
+ |
if a:long_option !=# '' |
|
232 |
+ |
let l:option = a:long_option . ' ' |
|
233 |
+ |
endif |
|
234 |
+ |
" if s:version[0] > 6 || (s:version[0] == 6 && s:version[1] >= 5) |
|
235 |
+ |
" let l:option = l:option . '--nearness=' . expand('%:p:h') . ' ' |
|
236 |
+ |
" endif |
|
237 |
+ |
let l:option = l:option . '--result=' . g:Gtags_Result . ' -q' |
|
238 |
+ |
let l:option = l:option . s:TrimOption(a:option) |
|
239 |
+ |
if l:isfile == 1 |
|
240 |
+ |
let l:cmd = g:gtags_global_command . ' ' . l:option . ' ' . g:Gtags_Shell_Quote_Char . a:pattern . g:Gtags_Shell_Quote_Char |
|
241 |
+ |
else |
|
242 |
+ |
let l:cmd = g:gtags_global_command . ' ' . l:option . 'e ' . g:Gtags_Shell_Quote_Char . a:pattern . g:Gtags_Shell_Quote_Char |
|
243 |
+ |
endif |
|
244 |
+ |
|
|
245 |
+ |
let l:restore_gtagsroot = 0 |
|
246 |
+ |
if empty($GTAGSROOT) |
|
247 |
+ |
let $GTAGSROOT = SpaceVim#plugins#projectmanager#current_root() |
|
248 |
+ |
let l:restore_gtagsroot = 1 |
|
249 |
+ |
endif |
|
250 |
+ |
|
|
251 |
+ |
let l:restore_gtagsdbpath = 0 |
|
252 |
+ |
if empty($GTAGSDBPATH) |
|
253 |
+ |
let $GTAGSDBPATH = s:FILE.unify_path(g:gtags_cache_dir) . s:FILE.path_to_fname($GTAGSROOT) |
|
254 |
+ |
let l:restore_gtagsdbpath = 1 |
|
255 |
+ |
endif |
|
256 |
+ |
|
|
257 |
+ |
let l:result = system(l:cmd) |
|
258 |
+ |
|
|
259 |
+ |
" restore $GTAGSROOT and $GTAGSDBPATH to make it possible to switch |
|
260 |
+ |
" between multiple projects or parent/child projects |
|
261 |
+ |
if l:restore_gtagsroot |
|
262 |
+ |
let $GTAGSROOT = '' |
|
263 |
+ |
endif |
|
264 |
+ |
|
|
265 |
+ |
if l:restore_gtagsdbpath |
|
266 |
+ |
let $GTAGSDBPATH = '' |
|
267 |
+ |
endif |
|
268 |
+ |
|
|
269 |
+ |
e |
|
270 |
+ |
if v:shell_error != 0 |
|
271 |
+ |
if v:shell_error == 2 |
|
272 |
+ |
call s:Error('invalid arguments. (gtags.vim requires GLOBAL 5.7 or later)') |
|
273 |
+ |
elseif v:shell_error == 3 |
|
274 |
+ |
call s:Error('GTAGS not found.') |
|
275 |
+ |
else |
|
276 |
+ |
call s:Error('global command failed. command line: ' . l:cmd) |
|
277 |
+ |
endif |
|
278 |
+ |
return |
|
279 |
+ |
endif |
|
280 |
+ |
if l:result ==# '' |
|
281 |
+ |
if a:option =~# 'f' |
|
282 |
+ |
call s:Error('No tags found in ' . a:pattern) |
|
283 |
+ |
elseif a:option =~# 'P' |
|
284 |
+ |
call s:Error('No path matches found for ' . a:pattern) |
|
285 |
+ |
elseif a:option =~# 'g' |
|
286 |
+ |
call s:Error('No line matches found for ' . a:pattern) |
|
287 |
+ |
else |
|
288 |
+ |
call s:Error('No tag matches found for ' . g:Gtags_Shell_Quote_Char . a:pattern . g:Gtags_Shell_Quote_Char) |
|
289 |
+ |
endif |
|
290 |
+ |
return |
|
291 |
+ |
endif |
|
292 |
+ |
|
|
293 |
+ |
call s:Memorize() |
|
294 |
+ |
|
|
295 |
+ |
" Open the quickfix window |
|
296 |
+ |
if g:gtags_open_list == 1 |
|
297 |
+ |
botright copen |
|
298 |
+ |
elseif g:gtags_open_list == 2 |
|
299 |
+ |
call s:save_prev_windows() |
|
300 |
+ |
botright copen |
|
301 |
+ |
call s:restore_prev_windows() |
|
302 |
+ |
endif |
|
303 |
+ |
" Parse the output of 'global -x or -t' and show in the quickfix window. |
|
304 |
+ |
let l:efm_org = &efm |
|
305 |
+ |
let &efm = g:Gtags_Efm |
|
306 |
+ |
cexpr! l:result |
|
307 |
+ |
let &efm = l:efm_org |
|
308 |
+ |
endfunction |
|
309 |
+ |
|
|
310 |
+ |
let s:prev_windows = [] |
|
311 |
+ |
function! s:save_prev_windows() abort |
|
312 |
+ |
let aw = winnr('#') |
|
313 |
+ |
let pw = winnr() |
|
314 |
+ |
if exists('*win_getid') |
|
315 |
+ |
let aw_id = win_getid(aw) |
|
316 |
+ |
let pw_id = win_getid(pw) |
|
317 |
+ |
else |
|
318 |
+ |
let aw_id = 0 |
|
319 |
+ |
let pw_id = 0 |
|
320 |
+ |
endif |
|
321 |
+ |
call add(s:prev_windows, [aw, pw, aw_id, pw_id]) |
|
322 |
+ |
endfunction |
|
323 |
+ |
|
|
324 |
+ |
function! s:restore_prev_windows() abort |
|
325 |
+ |
let [aw, pw, aw_id, pw_id] = remove(s:prev_windows, 0) |
|
326 |
+ |
if winnr() != pw |
|
327 |
+ |
" Go back, maintaining the '#' window (CTRL-W_p). |
|
328 |
+ |
if pw_id |
|
329 |
+ |
let aw = win_id2win(aw_id) |
|
330 |
+ |
let pw = win_id2win(pw_id) |
|
331 |
+ |
endif |
|
332 |
+ |
if pw |
|
333 |
+ |
if aw |
|
334 |
+ |
exec aw . 'wincmd w' |
|
335 |
+ |
endif |
|
336 |
+ |
exec pw . 'wincmd w' |
|
337 |
+ |
endif |
|
338 |
+ |
endif |
|
339 |
+ |
endfunction |
|
340 |
+ |
|
|
341 |
+ |
" |
|
342 |
+ |
" RunGlobal() |
|
343 |
+ |
" |
|
344 |
+ |
function! gtags#global(line) abort |
|
345 |
+ |
call gtags#logger#log('info', a:line) |
|
346 |
+ |
let l:pattern = s:Extract(a:line, 'pattern') |
|
347 |
+ |
|
|
348 |
+ |
if l:pattern ==# '%' |
|
349 |
+ |
let l:pattern = expand('%') |
|
350 |
+ |
elseif l:pattern ==# '#' |
|
351 |
+ |
let l:pattern = expand('#') |
|
352 |
+ |
endif |
|
353 |
+ |
let l:option = s:Extract(a:line, 'option') |
|
354 |
+ |
" If no pattern supplied then get it from user. |
|
355 |
+ |
if l:pattern ==# '' && l:option !=# 'P' |
|
356 |
+ |
let s:option = l:option |
|
357 |
+ |
if l:option =~# 'f' |
|
358 |
+ |
let l:line = input('Gtags for file: ', expand('%'), 'file') |
|
359 |
+ |
else |
|
360 |
+ |
let l:line = input('Gtags for pattern: ', expand('<cword>'), 'custom,GtagsCandidateCore') |
|
361 |
+ |
endif |
|
362 |
+ |
let l:pattern = s:Extract(l:line, 'pattern') |
|
363 |
+ |
if l:pattern ==# '' |
|
364 |
+ |
call s:Error('Pattern not specified.') |
|
365 |
+ |
return |
|
366 |
+ |
endif |
|
367 |
+ |
endif |
|
368 |
+ |
call s:ExecLoad(l:option, '', l:pattern) |
|
369 |
+ |
endfunction |
|
370 |
+ |
|
|
371 |
+ |
" |
|
372 |
+ |
" Execute RunGlobal() depending on the current position. |
|
373 |
+ |
" |
|
374 |
+ |
function! gtags#cursor() abort |
|
375 |
+ |
let l:pattern = expand('<cword>') |
|
376 |
+ |
let l:option = "--from-here=\"" . line('.') . ':' . expand('%') . "\"" |
|
377 |
+ |
call s:ExecLoad('', l:option, l:pattern) |
|
378 |
+ |
endfunction |
|
379 |
+ |
|
|
380 |
+ |
" |
|
381 |
+ |
" Core Gtags function |
|
382 |
+ |
" |
|
383 |
+ |
function! gtags#func(type, pattern) abort |
|
384 |
+ |
let l:option = '' |
|
385 |
+ |
if a:type ==# 'g' |
|
386 |
+ |
let l:option .= ' -x ' |
|
387 |
+ |
elseif a:type ==# 'r' |
|
388 |
+ |
let l:option .= ' -x -r ' |
|
389 |
+ |
elseif a:type ==# 's' |
|
390 |
+ |
let l:option .= ' -x -s ' |
|
391 |
+ |
elseif a:type ==# 'e' |
|
392 |
+ |
let l:option .= ' -x -g ' |
|
393 |
+ |
elseif a:type ==# 'f' |
|
394 |
+ |
let l:option .= ' -x -P ' |
|
395 |
+ |
endif |
|
396 |
+ |
call s:ExecLoad('', l:option, a:pattern) |
|
397 |
+ |
endfunction |
|
398 |
+ |
|
|
399 |
+ |
" |
|
400 |
+ |
" Show the current position on mozilla. |
|
401 |
+ |
" (You need to execute htags(1) in your source directory.) |
|
402 |
+ |
" |
|
403 |
+ |
function! gtags#gozilla() abort |
|
404 |
+ |
let l:lineno = line('.') |
|
405 |
+ |
let l:filename = expand('%') |
|
406 |
+ |
call system('gozilla +' . l:lineno . ' ' . l:filename) |
|
407 |
+ |
endfunction |
|
408 |
+ |
|
|
409 |
+ |
" |
|
410 |
+ |
" Custom completion. |
|
411 |
+ |
" |
|
412 |
+ |
function! gtags#complete(lead, line, pos) abort |
|
413 |
+ |
let s:option = s:Extract(a:line, 'option') |
|
414 |
+ |
return s:GtagsCandidateCore(a:lead, a:line, a:pos) |
|
415 |
+ |
endfunction |
|
416 |
+ |
|
|
417 |
+ |
function! s:GtagsCandidateCore(lead, ...) abort |
|
418 |
+ |
if s:option ==# 'g' |
|
419 |
+ |
return '' |
|
420 |
+ |
elseif s:option ==# 'f' |
|
421 |
+ |
if isdirectory(a:lead) |
|
422 |
+ |
if a:lead =~# '/$' |
|
423 |
+ |
let l:pattern = a:lead . '*' |
|
424 |
+ |
else |
|
425 |
+ |
let l:pattern = a:lead . '/*' |
|
426 |
+ |
endif |
|
427 |
+ |
else |
|
428 |
+ |
let l:pattern = a:lead . '*' |
|
429 |
+ |
endif |
|
430 |
+ |
return glob(l:pattern) |
|
431 |
+ |
else |
|
432 |
+ |
let l:cands = system(g:gtags_global_command . ' ' . '-c' . s:option . ' ' . a:lead) |
|
433 |
+ |
if v:shell_error == 0 |
|
434 |
+ |
return l:cands |
|
435 |
+ |
endif |
|
436 |
+ |
return '' |
|
437 |
+ |
endif |
|
438 |
+ |
endfunction |
|
439 |
+ |
|
|
440 |
+ |
function! gtags#show_lib_path() abort |
|
441 |
+ |
echo $GTAGSLIBPATH |
|
442 |
+ |
endfunction |
|
443 |
+ |
|
|
444 |
+ |
function! gtags#add_lib(path) abort |
|
445 |
+ |
let $GTAGSLIBPATH .= ':'.a:path |
|
446 |
+ |
echo $GTAGSLIBPATH |
|
447 |
+ |
endfunction |
|
448 |
+ |
|
|
449 |
+ |
|
|
450 |
+ |
function! gtags#update(single_update) abort |
|
451 |
+ |
let dir = s:FILE.unify_path(g:tags_cache_dir) |
|
452 |
+ |
\ . s:FILE.path_to_fname(SpaceVim#plugins#projectmanager#current_root()) |
|
453 |
+ |
let cmd = ['gtags'] |
|
454 |
+ |
if !empty(g:gtags_gtagslabel) |
|
455 |
+ |
let cmd += ['--gtagslabel=' . g:gtags_gtagslabel] |
|
456 |
+ |
endif |
|
457 |
+ |
if a:single_update && filereadable(dir . '/GTAGS') |
|
458 |
+ |
let cmd += ['--single-update', expand('%:p')] |
|
459 |
+ |
else |
|
460 |
+ |
let cmd += ['--skip-unreadable'] |
|
461 |
+ |
endif |
|
462 |
+ |
if !isdirectory(dir) |
|
463 |
+ |
call mkdir(dir, 'p') |
|
464 |
+ |
endif |
|
465 |
+ |
let cmd += ['-O', dir] |
|
466 |
+ |
call s:JOB.start(cmd, {'on_exit' : funcref('s:on_update_exit')}) |
|
467 |
+ |
endfunction |
|
468 |
+ |
|
|
469 |
+ |
function! s:on_update_exit(...) abort |
|
470 |
+ |
if str2nr(a:2) > 0 && !g:gtags_silent |
|
471 |
+ |
call s:LOGGER.warn('failed to update gtags, exit data: ' . a:2) |
|
472 |
+ |
endif |
|
473 |
+ |
endfunction |
|
474 |
+ |
|