vim-dirvish icon indicating copy to clipboard operation
vim-dirvish copied to clipboard

Allow autochdir

Open soli opened this issue 9 years ago • 13 comments

Would it be possible to save &autochdir, unset it while Dirvish does its thing and restore it afterwards, with the rest of the "state" ?

soli avatar Feb 09 '16 15:02 soli

P.S. I do agree, of course, to be the guinea pig if one is needed ^^

soli avatar Feb 09 '16 15:02 soli

---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 avatar Feb 25 '16 17:02 bobmonteverde

@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.

justinmk avatar Feb 25 '16 18:02 justinmk

@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 avatar May 18 '16 23:05 idbrii

@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?

justinmk avatar May 19 '16 00:05 justinmk

Thanks @idbrii I'll have a look!

soli avatar May 19 '16 08:05 soli

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.

idbrii avatar May 20 '16 15:05 idbrii

+1

phcerdan avatar Dec 06 '16 04:12 phcerdan

+1

timeyyy avatar Feb 17 '17 15:02 timeyyy

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

voldikss avatar Aug 23 '18 11:08 voldikss

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.

Gavinok avatar May 20 '20 22:05 Gavinok

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):'')
  …

agguser avatar Oct 02 '20 06:10 agguser

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.

idbrii avatar Oct 13 '20 23:10 idbrii