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

Binding to open in Neovim not working #203

Closed
euglevi opened this issue Oct 28, 2021 · 8 comments
Closed

Binding to open in Neovim not working #203

euglevi opened this issue Oct 28, 2021 · 8 comments

Comments

@euglevi
Copy link

euglevi commented Oct 28, 2021

Describe the bug

First of all, thank you for the great plugin! I have quite a minimal config in my config.fish:

fzf_configure_bindings --directory=\cx
set fzf_fd_opts --hidden -E .git -E .virtualenvs -E .cargo -E .cache -E .fonts -E .steam -E .local/lib -E .local/etc -E .local/state -E .rustup -E .themes -E dotfiles
set fzf_dir_opts --bind "ctrl-v:execute(nvim {})+abort,tab:down,shift-tab:up,ctrl-a:toggle+down" --border=none

Everything seems to be working except for the ctrl-v binding. Whenever I try it, I get the following:

28_10_21_10_00_01

I can get out of this screen by pressing \cc.

When I try the same with ls | fzf --bind "ctrl-v:execute(nvim {})", everything works as expected.

Environment

Versions installed:

  • Fish: 3.3.1
  • fzf.fish: last one
  • plugin manager: fisher 4.3.0
  • terminal: kitty
  • OS: Ubuntu Hirsute
@PatrickF1
Copy link
Owner

Hi @euglevi. Thank you for your kind words!

I have confirmed your bug. It is an use case I want fzf.fish to support but looks like it doesn't. Based on the limited debugging I did so far (I work a full time job so am not able to spend hours on this), I think it has to do with the strings disappearing when they get passed around as flags. So can you try different permutations of wrapping the --bind "ctrl-v:execute(nvim {})" in single quotes to see if that helps?

@euglevi
Copy link
Author

euglevi commented Nov 1, 2021

I tried but with no luck. If I substitute nvim with another app, like libreoffice, the keybinding works. So I suspect this issue has not to do with strings as much as with terminals. I am sorry I cannot be of further help as I know very little fish programming.

@PatrickF1
Copy link
Owner

Got it. I will try to find some time to look into it. Thanks for your patience!

@PatrickF1
Copy link
Owner

Ok I think I figured it out. The reason executing nvim doesn't work is because fzf is executed in a command substitution.
To see this for yourself, see that

ls | fzf --bind "ctrl-v:execute(nvim {})"

works but this does not

set v (ls | fzf --bind "ctrl-v:execute(nvim {})")

Let me find a way around this. This is a pretty limiting :(

@PatrickF1
Copy link
Owner

PatrickF1 commented Nov 8, 2021

Aw man, I don't think there's a way around it. I tried using

ls | fzf --bind "ctrl-v:execute(nvim {})" | read v

but had the same problem. I'll ask the maintainers for fish-shell for ideas or a patch, but it looks grim. Sorry. I will need to remove the idea of using --bind to do cool things from the readme.

EDIT: asked question here https://gitter.im/fish-shell/fish-shell?at=6188ba1dfb3dcd4e8873db1b

@euglevi
Copy link
Author

euglevi commented Nov 8, 2021

I could indeed replicate your debug. By the way, it is the same also with the keybindings provided by the official fzf page, so this is clearly not an issue related to the plugin itself. Let us see if maintainers of fish-shell have ideas. Notice that this is not related to Neovim only because the same problem arises also with Vim or with Nano so it must have to do with stdin, as you were suggesting.

Thank you very much for your time and effort!

@euglevi
Copy link
Author

euglevi commented Nov 8, 2021

Ok I think I solved this. Try this:

set v (ls | fzf --bind "ctrl-v:execute(nvim {} &> /dev/tty)")

You need to redirect both input and output to tty.

@PatrickF1
Copy link
Owner

Thanks @euglevi! I will add this to the troubleshooting

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

No branches or pull requests

2 participants