comparison autoload/gutentags.vim @ 169:95afd985a4c3

Merge pull request #97 from GitHub.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 19 Feb 2017 20:00:13 -0800
parents 1fe62e7f1fae e59321cbaff7
children 2cf3fb66285b
comparison
equal deleted inserted replaced
167:34c57ad6eb45 169:95afd985a4c3
1 " gutentags.vim - Automatic ctags management for Vim 1 " gutentags.vim - Automatic ctags management for Vim
2 2
3 " Utilities {{{ 3 " Utilities {{{
4
5 function! gutentags#pwd()
6 if has('nvim')
7 return haslocaldir() ? getcwd(0, 0) : haslocaldir(-1, 0) ? getcwd(-1, 0) : getcwd()
8 else
9 return haslocaldir() ? getcwd(0, 0) : getcwd()
10 endif
11 endfunction
12
13 function! gutentags#chdir(path)
14 if has('nvim')
15 let chdir = haslocaldir() ? 'lcd' : haslocaldir(-1, 0) ? 'tcd' : 'cd'
16 else
17 let chdir = haslocaldir() ? 'lcd' : 'cd'
18 endif
19 execute chdir a:path
20 endfunction
4 21
5 " Throw an exception message. 22 " Throw an exception message.
6 function! gutentags#throw(message) 23 function! gutentags#throw(message)
7 throw "gutentags: " . a:message 24 throw "gutentags: " . a:message
8 endfunction 25 endfunction
382 endif 399 endif
383 400
384 " Switch to the project root to make the command line smaller, and make 401 " Switch to the project root to make the command line smaller, and make
385 " it possible to get the relative path of the filename to parse if we're 402 " it possible to get the relative path of the filename to parse if we're
386 " doing an incremental update. 403 " doing an incremental update.
387 let l:prev_cwd = getcwd() 404 let l:prev_cwd = gutentags#pwd()
388 execute "chdir " . fnameescape(l:proj_dir) 405 call gutentags#chdir(fnameescape(l:proj_dir))
389 try 406 try
390 call call("gutentags#".a:module."#generate", 407 call call("gutentags#".a:module."#generate",
391 \[l:proj_dir, l:tags_file, a:write_mode]) 408 \[l:proj_dir, l:tags_file, a:write_mode])
392 catch /^gutentags\:/ 409 catch /^gutentags\:/
393 echom "Error while generating ".a:module." file:" 410 echom "Error while generating ".a:module." file:"
394 echom v:exception 411 echom v:exception
395 finally 412 finally
396 " Restore the current directory... 413 " Restore the current directory...
397 execute "chdir " . fnameescape(l:prev_cwd) 414 call gutentags#chdir(fnameescape(l:prev_cwd))
398 endtry 415 endtry
399 endfunction 416 endfunction
400 417
401 " }}} 418 " }}}
402 419