vim-dirvish
vim-dirvish copied to clipboard
Allow autochdir
Would it be possible to save &autochdir
, unset it while Dirvish does its thing and restore it afterwards, with the rest of the "state" ?
P.S. I do agree, of course, to be the guinea pig if one is needed ^^
---deleted---
Sorry, had set autochdir in my vimrc, preventing Dirvish from working. Guesss these would be a nice feature, haha. Side note, would be great if some more docs on using Dirvish were included.
@bobmonteverde more docs in addition to https://github.com/justinmk/vim-dirvish/blob/master/doc/dirvish.txt ?
I do plan to add support for 'autochdir', though it's not high priority.
@soli: I tried that, but it's not so simple. I think because there are multiple places where dirvish "does it's thing?"
I messed around with this for a bit and made idbrii/vim-dirvish/autochdir-workaround (see above). It's probably not pull-request worthy, but might be a starting point.
@idbrii Thanks for looking at that. If s:set_altbuf
is the main issue, then on Vim versions where @#
is writable, are there any other problems?
Thanks @idbrii I'll have a look!
s:set_altbuf is the main issue for my workaround, but there seem to be more problems with autochdir. I only tested it enough to see that it was still broken.
+1
+1
You can use autocmd
command to change current working directory, and I've tested that it has no conflicts with vim-dirvish.
set noautochdir
augroup auto_ch_dir
autocmd!
autocmd BufEnter * silent! lcd %:p:h
augroup END
You can use
autocmd
command to change current working directory, and I've tested that it has no conflicts with vim-dirvish.set noautochdir augroup auto_ch_dir autocmd! autocmd BufEnter * silent! lcd %:p:h augroup END
This conflicts when using Shdo since its changes the directory.
A fix for Shdo
would be adding cd dir-path
command at the top of the generated script. You may add it manually every time, or change vim-dirvish/autoload/dirvish.vim
function! dirvish#shdo(paths, cmd) abort
…
endfor
call insert(lines, 'cd '.shellescape(dir)) " ++
execute 'silent split' tmpfile '|' (2==exists(':lcd')?('lcd '.dir):'')
…
That reminds me to send PR #200!
It a different fix for shdo: write the cd
command into the script. I often go off and do other things between :Shdo
and running the script, so I don't want the script to rely on vim's cwd.