-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid saving lcd
#10
Comments
As documented in the help, the persistent local working directory is a side effect of how Vim’s view sessions work. If you have a version of Vim recent enough to support augroup stay_no_lcd
autocmd!
autocmd User BufStaySavePre if haslocaldir() | let w:lcd = getcwd() | cd - | cd - | endif
autocmd User BufStaySavePost if exists('w:lcd') | execute 'lcd' fnameescape(w:lcd) | unlet w:lcd | endif
augroup END As you will have noticed, this is somewhat hacky, needing an actual, redundant directory change (the double |
Works like a charm so far, thank you for the complete solution! |
Good to hear that. One important caveat: currently, the |
PS: I’d be interested in knowing why you prefer to suppress local working directory persistence. Would you care to elucidate? |
When dealing with multiple projects, I like designating each project a tab and change each tab's
|
Point 1 is a valid concern – I find the local working directory restoration a bit disorienting myself at times, which is why I have toyed with remedies. Unluckily, all of these are gross hacks of the kind I showed above, thanks to Vim’s geriatrically demented Point 2 is one where I’d been remiss not to warn you that vim-session is not entirely without problems of its own; in its efforts to not inherit the warts of Vim’s session management, it has re-implemented all of that feature instead of piggy-backing on it. I found it often left my Vim in a confused and confusing state, which is why I removed it from my setup. |
Thanks for all this viable information. About xolox/vim-session - it's been acting pretty good for me. I've also ported Shougo's session unite source to use vim-session. Out of curiousity - what session persistency alternative are you using now? |
None, really: per project tabs with a tab scoped working directory courtesy of my fork of Kana’s vim-tabpagecd, vim-stay for file level persistence, but mostly simply leaving my MacVim instance running all the time suffice to my needs :). |
You could have a version / patch check for this - if it's known which version is required. For what it's worth, I am not getting a For older versions it might be even possible to remove it, based on |
@blueyed the whole local working directory issue is some thing I am still mulling possible solutions over. One thing I want to avoid is adding features that only work in certain Vim versions and patch levels. A consistent set of features for all versions of Vim stay supports is a design priority of mine, hence the statement you quoted above. |
@kopischke |
What about removing the |
@blueyed absolutely none; as you probably have noticed, development of my plugins has been dormant for quite a while now, mostly because life has left me precious little time for dev work these last two years. Sorry for that. For what it’s worth, I will add that even should I find time to pick up development again, I still probably would not go the rewriting route: keeping the breakage potential low by sticking to a well defined API (in this case: the |
Understood. augroup stay_no_lcd
autocmd!
if exists(':tcd') == 2
autocmd User BufStaySavePre if haslocaldir() | let w:lcd = getcwd() | exe 'cd '.fnameescape(getcwd(-1, -1)) | endif
else
autocmd User BufStaySavePre if haslocaldir() | let w:lcd = getcwd() | cd - | cd - | endif
endif
autocmd User BufStaySavePost if exists('w:lcd') | execute 'lcd' fnameescape(w:lcd) | unlet w:lcd | endif
augroup END |
How could I make vim-stay avoid saving
lcd
variable?Reading the doc, seems the Autocommand API might be a good direction,
but I'm not sure how to work it out. Could you help? :)
The text was updated successfully, but these errors were encountered: