Skip to content
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

Allow autochdir #19

Open
soli opened this issue Feb 9, 2016 · 13 comments
Open

Allow autochdir #19

soli opened this issue Feb 9, 2016 · 13 comments

Comments

@soli
Copy link

soli commented Feb 9, 2016

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
Copy link
Author

soli commented Feb 9, 2016

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

@bobmonteverde
Copy link

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

@justinmk
Copy link
Owner

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

idbrii added a commit to idbrii/vim-dirvish that referenced this issue May 18, 2016
Related to justinmk#19

Allow the :cd on autocmd emulation of autochdir to work with dirvish.
Describe this workaround for autochdir-like behavior in the help.

This change might be a first step towards autochdir, but it's not enough
yet.

The autocmd breaks dirvish when we try to force an alternate file
because we're :cd-ing while dirvish is trying to do stuff and we end up
with an empty buffername. This change tracks when we're in set_altbuf so
the autocmd can be disabled during that region (using noau didn't work
and replacing set_altbuf with keepalt everywhere didn't work either).

Ideally, we detect if autochdir is enabled and re-enable it when we're
clear of set_altbuf, but it doesn't work yet.
@idbrii
Copy link

idbrii commented May 18, 2016

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

@justinmk
Copy link
Owner

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

@soli
Copy link
Author

soli commented May 19, 2016

Thanks @idbrii I'll have a look!

@idbrii
Copy link

idbrii commented May 20, 2016

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 added a commit to idbrii/vim-dirvish that referenced this issue May 24, 2016
Related to justinmk#19

Allow the :cd on autocmd emulation of autochdir to work with dirvish.
Describe this workaround for autochdir-like behavior in the help.

This change might be a first step towards autochdir, but it's not enough
yet.

The autocmd breaks dirvish when we try to force an alternate file
because we're :cd-ing while dirvish is trying to do stuff and we end up
with an empty buffername. This change tracks when we're in set_altbuf so
the autocmd can be disabled during that region (using noau didn't work
and replacing set_altbuf with keepalt everywhere didn't work either).

Ideally, we detect if autochdir is enabled and re-enable it when we're
clear of set_altbuf, but it doesn't work yet.
idbrii added a commit to idbrii/vim-dirvish that referenced this issue May 26, 2016
Related to justinmk#19

Allow the :cd on autocmd emulation of autochdir to work with dirvish.
Describe this workaround for autochdir-like behavior in the help.

This change might be a first step towards autochdir, but it's not enough
yet.

The autocmd breaks dirvish when we try to force an alternate file
because we're :cd-ing while dirvish is trying to do stuff and we end up
with an empty buffername. This change tracks when we're in set_altbuf so
the autocmd can be disabled during that region (using noau didn't work
and replacing set_altbuf with keepalt everywhere didn't work either).

Ideally, we detect if autochdir is enabled and re-enable it when we're
clear of set_altbuf, but it doesn't work yet.
@phcerdan
Copy link

phcerdan commented Dec 6, 2016

+1

1 similar comment
@timeyyy
Copy link

timeyyy commented Feb 17, 2017

+1

idbrii added a commit to idbrii/vim-dirvish that referenced this issue May 10, 2017
Related to justinmk#19

Allow the :cd on autocmd emulation of autochdir to work with dirvish.
Describe this workaround for autochdir-like behavior in the help.

This change might be a first step towards autochdir, but it's not enough
yet.

The autocmd breaks dirvish when we try to force an alternate file
because we're :cd-ing while dirvish is trying to do stuff and we end up
with an empty buffername. This change tracks when we're in set_altbuf so
the autocmd can be disabled during that region (using noau didn't work
and replacing set_altbuf with keepalt everywhere didn't work either).

Ideally, we detect if autochdir is enabled and re-enable it when we're
clear of set_altbuf, but it doesn't work yet.
@voldikss
Copy link

voldikss commented Aug 23, 2018

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

idbrii added a commit to idbrii/vim-dirvish that referenced this issue May 8, 2020
Related to justinmk#19

Allow the :cd on autocmd emulation of autochdir to work with dirvish.
Describe this workaround for autochdir-like behavior in the help.

This change might be a first step towards autochdir, but it's not enough
yet.

The autocmd breaks dirvish when we try to force an alternate file
because we're :cd-ing while dirvish is trying to do stuff and we end up
with an empty buffername. This change tracks when we're in set_altbuf so
the autocmd can be disabled during that region (using noau didn't work
and replacing set_altbuf with keepalt everywhere didn't work either).

Ideally, we detect if autochdir is enabled and re-enable it when we're
clear of set_altbuf, but it doesn't work yet.
@Gavinok
Copy link

Gavinok commented May 20, 2020

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.

@agguser
Copy link

agguser commented Oct 2, 2020

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) abortendfor
  call insert(lines, 'cd '.shellescape(dir))   " ++
  execute 'silent split' tmpfile '|' (2==exists(':lcd')?('lcd '.dir):'')
  …

@idbrii
Copy link

idbrii commented Oct 13, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants