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

keybindings seem to conflict with fzf's #24

Closed
sktrinh12 opened this issue Feb 23, 2021 · 17 comments
Closed

keybindings seem to conflict with fzf's #24

sktrinh12 opened this issue Feb 23, 2021 · 17 comments
Assignees

Comments

@sktrinh12
Copy link

hi, thanks for creating this wonderful plugin. I am having trouble getting it working with fzf. My .zshrc file looks like this:

...


# zsh vi mode
source $HOME/.zsh-vi-mode/zsh-vi-mode.plugin.zsh

# fzf
source /usr/share/doc/fzf/examples/key-bindings.zsh
source /usr/share/doc/fzf/examples/completion.zsh

if I comment out ZVM, fzf will work, and if I comment out fzf, ZVM will work. I also tried switching order and same situation. Any ideas how to get these two plugins working in harmony? Thanks.

@jeffreytse
Copy link
Owner

jeffreytse commented Feb 23, 2021

Hi @sktrinh12

I think you can read here. Also, you can refer to #4.

Thanks and regards

@sktrinh12
Copy link
Author

Thanks so much for providing that info. I didn't see that it was already addressed. Sorry to duplicate the issue. So I just append to the end of my .zshrc file any of those commands?

source $HOME/.zsh-vi-mode/zsh-vi-mode.plugin.zsh
zvm_after_init_commands+=('[ -f ~/.fzf ] && source ~/.fzf')

Excuse my ignorance, not experienced at the command line. :)

@jeffreytse
Copy link
Owner

jeffreytse commented Feb 23, 2021

Yes, just append the code as you showed to the end of your .zshrc file. The important thing is that make sure the path of fzf is correct.

@sktrinh12
Copy link
Author

ok, i tried that, but it didn't work. I don't know where this .fzf.zsh file lives. I'm running ubuntu 20.04 LTS. I installed fzf using apt and so the main folder is /usr/share/gocode/src/github.com/junegunn/fzf/...

@jeffreytse
Copy link
Owner

You can check your fzf path by which fzf, my side I got the result /home/seven/.fzf/bin/fzf, so the fzf folder is /home/seven/.fzf.

@sktrinh12
Copy link
Author

which fzf gave me /usr/bin/fzf, i put that into the init command but it didn't work. probably not understanding something.

i put the two original source lines inside:

zvm_after_init_commands+=('source /usr/share/doc/fzf/examples/key-bindings.zsh && source /usr/share/doc/fzf/examples/completion.zsh')

Looks kinda ugly and long, but it works for now. Thanks for the help.

@jeffreytse
Copy link
Owner

jeffreytse commented Feb 23, 2021

Hi @sktrinh12

😃 I'm glad to hear that you have settled down this issue. And Welcome to star this project for further updates in the future.

For better code style, I think you can use below one:

# The plugin will auto execute this zvm_after_init function
zvm_after_init() {
  source /usr/share/doc/fzf/examples/key-bindings.zsh
  source /usr/share/doc/fzf/examples/completion.zsh
}

Alternatively, you can "git clone" this repository to any directory and run install script.

git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install

After installation, just use below one:

zvm_after_init_commands+=('[ -f ~/.fzf ] && source ~/.fzf')

Thanks and regards

@sktrinh12
Copy link
Author

thanks for the suggestion! i starred your repo!

@haberdashPI
Copy link

This seems like more of a work-around than a good final solution. For example, if you configure fzf using oh-my-repl, there is already a nice script that hunts down the location of fzf keybindings and calls source on them for you. All of this logic is made moot when zsh-vi-mode overwrite the bindings.

Isn't there some way to not overwrite existing bindings, and/or record them and re-establish them for insert mode?

@haberdashPI
Copy link

An example use case: my dotfiles are designed to be portable, so they work on multiple environments. I don't want to specify machine specific folders in my .zshrc file because they need to work generically over several different machines (macOS, ubuntu and WSL 2).

@jeffreytse
Copy link
Owner

jeffreytse commented Jul 2, 2021

Hi @haberdashPI

Actually, there is another option for you to config the mode of initialization, and the feature is in progress. As we know, most of plugins do their initialization when they are sourced. However, this plugin's initialization is postponed to a new command line started, it caused the overwriting issues that you have met.

Thanks and regards.

@jeffreytse
Copy link
Owner

Hi @haberdashPI

Now this plugin has provided an option called ZVM_INIT_MODE to configure the initialization mode (#113), you can use this snippet ZVM_INIT_MODE=sourcing for doing the initialization inistantly when this plugin is sourcing.

Thanks and regards

@haberdashPI
Copy link

haberdashPI commented Jul 2, 2021

Thanks for the fast response @jeffreytse! From what I can tell, placing ZVM_INIT_MODE=sourcing before initializing oh-my-zsh and plugins mostly fixes this problem. It is probably with indicating somewhere in your docs that this only fixes the problem if zsh-vi-mode comes after fzf in the list of oh-my-zsh plugins (I tried it the other way first, and that did not resolve the issue with fzf's bindings, only my custom bindings—where were defined after sourcing oh-my-zsh).

@jeffreytse
Copy link
Owner

Hi @haberdashPI

Has your issue been settled? Don't hesitate to tell me the result.

Thanks and Regards

@haberdashPI
Copy link

Hi @jeffreytse: the plugin is working well for me, I haven't had issues since implementing the fix.

@ErwannMillon
Copy link

ErwannMillon commented Apr 27, 2023

Hey there,
just for future people, this solution worked fine, but not when using zplug. I had to make sure I was using the oh-my-zsh plugins for both fzf and zsh-vi-mode.
(https://github.com/unixorn/fzf-zsh-plugin)

i.e

plugins=(
zsh-vi-mode
fzf-zsh-plugin
)

@jeffreytse jeffreytse self-assigned this Apr 27, 2023
@justrajdeep
Copy link

Hey there, just for future people, this solution worked fine, but not when using zplug. I had to make sure I was using the oh-my-zsh plugins for both fzf and zsh-vi-mode. (https://github.com/unixorn/fzf-zsh-plugin)

i.e

plugins=(
zsh-vi-mode
fzf-zsh-plugin
)

This did not work for me

i tried

plugins=(
    gitfast
    zoxide
    # z
    zbell
    vim-interaction
    ripgrep
    rsync
    # git
    # globalias
    # colorize
    common-aliases
    # zsh-autocomplete
    zsh-autosuggestions
    # zsh-syntax-highlighting
    # zsh-expand-all
    fast-syntax-highlighting
    zsh-interactive-cd
    fzf-tab
    dirhistory
    jsontools
    # fzf
    # fd
    emacs
    extract
    poetry
    command-time
    autoupdate
    zsh-vi-mode
    fzf-zsh-plugin
)

As well as

zvm_after_commands+=('[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh')

Emin017 added a commit to Emin017/dotfiles that referenced this issue Oct 23, 2023
Kleinjohann added a commit to Kleinjohann/dotfiles that referenced this issue Jan 19, 2024
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

5 participants