vifm / vifm.vim

Vim plugin that allows use of vifm as a file picker
333 stars 19 forks source link

relative path and non-existant file to Vifm gives error #12

Open phinxy opened 6 years ago

phinxy commented 6 years ago

When calling Vifm with a relative path and a non-existant file like so:

:EditVifm some/directory/NULL.txt

Vim spits out the error:

Got non-zero code from vifm: 1

On the other hand, when using an absolute path the behavior is much better, Vifm starts and opens the folder.

:EditVifm ~/some/directory/NULL.txt

Thanks

xaizek commented 6 years ago

On the other hand, when using an absolute path the behavior is much better, Vifm starts and opens the folder.

Actually, this part looks like a bug. Both kinds of paths should be treated identically, in this case give an error.

Argument should be a directory, why are you trying to pass path to a file?

phinxy commented 6 years ago

why are you trying to pass path to a file?

When a file is passed to Vifm the file opens in vim, is this not intended? I have replaced :e and :vs built-in vim commands with the Vifm equivalents. Does not the built-in :e(dit) handle file paths? Vifm - or is it Vifm.vim - should too.

If i had to pick between the two behaviors when a file is not found, I would choose the one where Vifm opens the parent directory of the supposed file. Versus giving an error message. What is your opinion xaizek?

The docs says that file or files is part of the argument. Should it not mention directories as well?

:EditVifm select a file or files to open in the current buffer.

xaizek commented 6 years ago

The docs says that file or files is part of the argument. Should it not mention directories as well?

That's description of a command, not its arguments. Arguments are specified below:

Each command accepts up to two arguments: left pane directory and right pane directory.

When a file is passed to Vifm the file opens in vim, is this not intended?

It is intended, but when file exists and therefore user probably meant just that.

Does not the built-in :e(dit) handle file paths? Vifm - or is it Vifm.vim - should too.

Not necessarily. :edit and command-line arguments of vifm don't have to work identically.

The reason why it errors is because when file doesn't exist, you might have made a typo. And if vifm won't fail, user might proceed doing something else without noticing that he's in the wrong directory.

I have replaced :e and :vs built-in vim commands with the Vifm equivalents.

That doesn't seem optimal. Instead of Vim just opening a file, it runs vifm, which returns path and only then Vim opens it. An external process is spawn for no reason. Just to avoid this, it seems to make sense to invoke the plugin only when directory/directories or no arguments are passed. This way you also won't break use of wildcards in arguments for :e (e.g., :EditVifm *.vim won't work).