vifm / vifm.vim

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

Merge neovim-vifm? #16

Closed rbong closed 5 years ago

rbong commented 6 years ago

Since vim 8 now supports asyncronous actions, I have added vim 8 support to neovim-vifm.

The neovim plugin is now very redundant. I am hoping to get your feedback on the possibility of merging in neovim-vifm into vifm.vim and deprecating neovim-vifm.

A couple things from my perspective will be nice to have in vifm.vim: live directory switching and running vifm in a :term. Bad things that I don't want to merge in: neovim-vifm is probably more platform dependent than vifm.vim since it relies on bash and cat currently for live directory switching. I would want to fix this before merging.

Let me know what you think, or if you have any alternative suggestions. Thanks!

xaizek commented 6 years ago

This would be a nice way of resolving vifm/neovim-vifm#6.

[...] it relies on bash and cat currently for live directory switching.

Well, cat is part of POSIX and bash there isn't needed sh would do, I think. But it won't work on Windows, that's true.

The most portable way I could think of to communicate current path back to Vim is to use --remote-*, however Vim might be compiled without it and neovim doesn't have it builtin and needs a plugin. So maybe live directory switching should be a POSIX-only feature.

rbong commented 6 years ago

Thanks for your feedback. I'll start on a PR.

jwijenbergh commented 5 years ago

Any updates on this?

rbong commented 5 years ago

I compared the two codebases shortly after my previous comment. There's not a lot of overlap, stylistically or structurally. I'm not sure there's a lot of code they can share, since most of neovim-vifm is just job management, which would be new to vifm.vim. It will be some work to make sure that merging the two projects together is as nice in practice as it is in theory. I've had a lot of time to stew on this and I'm between personal projects, so I can spend some time putting something together now to at least see if it's worth it.

rbong commented 5 years ago

Interface Changes

I have gotten caught up on changes to the repository and need some feedback on possible complications with the merge. I'll only be going into surface-level interface changes, and I can go more into implementation details later.

Netrw replacement

neovim-vifm replaces Netrw, whereas vifm.vim does not. If replacing Netrw isn't too much of a departure from vifm.vim's intention I'm comfortable enough to add this as an option.

There can also be a global option for which modifier (split/vertical/tab) to use to open files when using it as a Netrw replacement, although that's not a great interface, but hardcoding one option isn't great either. If there was some way to specify how you wanted to open the file within vifm that would be amazing, but it would change the entire plugin.

I'm just as comfortable with dropping this option, since it creates even more opening confusion (see below). However, note that if this is dropped, if the interface doesn't change otherwise, it will only be possible to open up terminal vifm in a split, since opening it in the current window is only available when replacing Netrw.

Opening strategy

With vifm opened up in a :term window it makes :SplitVifm, :TabVifm, etc. commands confusing since you're not splitting vifm, you're splitting the files it opens. One solution I can think of is to keep neovim-vifm's current style of always opening in a vertical split and keep all of the commands as they are. It's a good option because it changes nothing, but it doesn't eliminate the confusion of merging the two interfaces.

Another solution is to not split the terminal window of vifm and to instead open it in the current window so that people can open it however they want. However, this will attempt to change out of whatever is in the current window, and it is not very Vim-like.

The Vim way to do it would be to support modifiers, although using commands like :tab SplitVifm would probably be even more confusing. Entering :tabe then :SplitVifm like previously mentioned would probably make more sense in this case.

Summary

I need feedback on which avenues to take, or information on other options. There are a few tradeoffs here no matter what route we take - please make it known if you think the best option is to not merge the two plugins.

I know that was a lot of different options, so just to recap, this is the interface I'm currently in favour of actually implementing:

This is the pie-in-the-sky solution that requires more thought, feedback, and changes:

Sorry for the giant post.

xaizek commented 5 years ago

If there was some way to specify how you wanted to open the file within vifm that would be amazing, but it would change the entire plugin.

It's already there:

https://github.com/vifm/vifm.vim/blob/02c74ef56206f6996c601bf4c32069f7fe53e46d/doc/plugin/vifm-plugin.txt#L30-L39

vifm.vim doesn't override Netrw because it was never considered, I don't have anything against it.

Adding another command to start vifm should be fine too. I don't find naming of *Vifm commands great, so another way of specifying default way of opening a file in a new command is welcomed (maybe via -option to it), but the old ones will have to stay for compatibility reasons. The old commands probably don't have to respect modifies like :vertical.

How does the above affect your considerations about interface changes? You didn't see that :*Vim commands do exist, so I'm trying to just provide more information instead of evaluating proposed solutions.

rbong commented 5 years ago

That does change a lot. The interface I'll go with if no one has any problems with it is as follows:

xaizek commented 5 years ago

That sounds good to me.

xaizek commented 5 years ago

Just found out that since Vim v8.0.1647, there is terminal API. It's only a year old and I don't see a way to test for its presence, but this thing could be used to implement live directory switching at least in the future (or just require it for this feature to work).

Example

In vimrc:

function! Tapi_Echo(buf, args)
    echo a:args
endfunction

In vifm:

:autocmd DirEnter * !echo -e '\e]51;["call", "Tapi_Echo", %"d]\a'

Update: looks like neovim doesn't have terminal API.

rbong commented 5 years ago

I ended up implementing live directory switching using jobs just like in neovim-vifm for now

xaizek commented 5 years ago

22 + #23 close this.