# HG changeset patch # User Ludovic Chabant # Date 1487563213 28800 # Node ID 95afd985a4c36f392a03375983ce3e713224ae9b # Parent 34c57ad6eb451a14dde71f31ed34e9b68253197e# Parent e59321cbaff71a67d78ea52307284a2d5b746ed6 Merge pull request #97 from GitHub. diff -r 34c57ad6eb45 -r 95afd985a4c3 autoload/gutentags.vim --- a/autoload/gutentags.vim Sat Feb 18 21:57:52 2017 -0800 +++ b/autoload/gutentags.vim Sun Feb 19 20:00:13 2017 -0800 @@ -2,6 +2,23 @@ " Utilities {{{ +function! gutentags#pwd() + if has('nvim') + return haslocaldir() ? getcwd(0, 0) : haslocaldir(-1, 0) ? getcwd(-1, 0) : getcwd() + else + return haslocaldir() ? getcwd(0, 0) : getcwd() + endif +endfunction + +function! gutentags#chdir(path) + if has('nvim') + let chdir = haslocaldir() ? 'lcd' : haslocaldir(-1, 0) ? 'tcd' : 'cd' + else + let chdir = haslocaldir() ? 'lcd' : 'cd' + endif + execute chdir a:path +endfunction + " Throw an exception message. function! gutentags#throw(message) throw "gutentags: " . a:message @@ -384,8 +401,8 @@ " Switch to the project root to make the command line smaller, and make " it possible to get the relative path of the filename to parse if we're " doing an incremental update. - let l:prev_cwd = getcwd() - execute "chdir " . fnameescape(l:proj_dir) + let l:prev_cwd = gutentags#pwd() + call gutentags#chdir(fnameescape(l:proj_dir)) try call call("gutentags#".a:module."#generate", \[l:proj_dir, l:tags_file, a:write_mode]) @@ -394,7 +411,7 @@ echom v:exception finally " Restore the current directory... - execute "chdir " . fnameescape(l:prev_cwd) + call gutentags#chdir(fnameescape(l:prev_cwd)) endtry endfunction diff -r 34c57ad6eb45 -r 95afd985a4c3 autoload/gutentags/cscope.vim --- a/autoload/gutentags/cscope.vim Sat Feb 18 21:57:52 2017 -0800 +++ b/autoload/gutentags/cscope.vim Sun Feb 19 20:00:13 2017 -0800 @@ -64,7 +64,7 @@ let l:cmd .= gutentags#get_execute_cmd_suffix() call gutentags#trace("Running: " . l:cmd) - call gutentags#trace("In: " . getcwd()) + call gutentags#trace("In: " . gutentags#pwd()) if !g:gutentags_fake if !(has('nvim') && exists('*jobwait')) if !g:gutentags_trace diff -r 34c57ad6eb45 -r 95afd985a4c3 autoload/gutentags/ctags.vim --- a/autoload/gutentags/ctags.vim Sat Feb 18 21:57:52 2017 -0800 +++ b/autoload/gutentags/ctags.vim Sun Feb 19 20:00:13 2017 -0800 @@ -91,6 +91,7 @@ " directory, for some reason... let l:actual_proj_dir = '.' let l:actual_tags_file = fnamemodify(a:tags_file, ':.') + call gutentags#chdir(fnameescape(a:proj_dir)) else " else: the tags file goes in a cache directory, so we need to specify " all the paths absolutely for `ctags` to do its job correctly. @@ -168,7 +169,7 @@ let l:cmd .= gutentags#get_execute_cmd_suffix() call gutentags#trace("Running: " . l:cmd) - call gutentags#trace("In: " . getcwd()) + call gutentags#trace("In: " . gutentags#pwd()) if !g:gutentags_fake " Run the background process. if !g:gutentags_trace @@ -186,7 +187,7 @@ call gutentags#trace("") finally " Restore the previous working directory. - execute "chdir " . fnameescape(l:prev_cwd) + call gutentags#chdir(fnameescape(l:prev_cwd)) endtry endfunction