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

Invalid directory error when invoking <plug>(dirvish_up) from Vim terminal #134

Open
lifepillar opened this issue Dec 31, 2018 · 7 comments

Comments

@lifepillar
Copy link
Contributor

Possibly related to #127. To reproduce, open Vim, then open a terminal (:terminal), go to Normal mode and type - (or whatever mapping for <plug>(dirvish_up) you have). Instead of opening the file browser, Vim displays:

invalid directory: '!/bin'

NeoVim works as expected under the same circumstances. Using Vim 8.1.0650 under macOS.

@lifepillar
Copy link
Contributor Author

Forgot to mention: :Dirvish works as expected (and is my current workaround). The issue occurs only when using the plug.

@justinmk justinmk added bug and removed bug labels Dec 31, 2018
@justinmk
Copy link
Owner

justinmk commented Dec 31, 2018

I think Vim doesn't have the term:// scheme in the buffer name. We could check the 'buftype', I guess ... can you see if that works? Probably requires a few lines of ugly code.

@lifepillar
Copy link
Contributor Author

echo bufname("%") returns only the command (e.g., !/bin/bash), so expand("%:h") is !/bin; buftype is set to terminal in both Vim and NeoVim, so that likely the way to go (but in older versions of Vim, IIRC, buftype was not set in terminal windows, so there may be backward compatibility to take into account).

I think that Dirvish should open getcwd(): this will do it (in plugin/dirvish.vim):

nnoremap <silent> <Plug>(dirvish_up) :<C-U>exe
  \ 'Dirvish '.(getbufvar('%','&buftype') ==# 'terminal' ? getcwd() : '%:p'.repeat(':h',v:count1))<CR>

I still get the “invalid directory” error (also in NeoVim now), but the file browser is opened. Besides, <plug>(dirvish_up) is defined also in ftplugin/dirvish.vim. And everything should work with counts, too (the above doesn't). So, there is a bit of work to do…

@yzlnew
Copy link

yzlnew commented May 19, 2020

Got invalid dir error when starting with gvim . on Winodows.

@CrispyDrone
Copy link

I actually get dirvish: E37: No write since last change

@justinmk
Copy link
Owner

justinmk commented Dec 4, 2023

I actually get dirvish: E37: No write since last change

er... what does :echo &modified say?

@CrispyDrone
Copy link

CrispyDrone commented Dec 4, 2023

I actually get dirvish: E37: No write since last change

er... what does :echo &modified say?

1

But, it makes sense to me because in the vim documentation, it says:

So long as the job is running the window behaves like it contains a modified
buffer.

Just to be clear, this is not something I ever encountered before. I came across an issue where I wanted to use ctrlp from a dirvish buffer. It would preview the previous file instead of start a ctrlp search. In my search, I just happened to stumble on this and I got curious what it was about. I managed to fix my original issue by disabling the filetype mapping (as described in the documentation).

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

4 participants