fzf.vim icon indicating copy to clipboard operation
fzf.vim copied to clipboard

How do I install fzf.vim using Vim 8 native package loading?

Open dopatraman opened this issue 5 years ago • 11 comments

  • [x] I have read through https://github.com/junegunn/fzf.vim/blob/master/README.md
  • [x] I have read through https://github.com/junegunn/fzf/blob/master/README-VIM.md
  • [x] I have read through the manual page of fzf (man fzf)
  • [x] I have searched through the existing issues

I'm using native vim packages on Vim 8.1

When I do the following:

  1. Add the fzf binary to rtp in my .vimrc
  2. call fzf#install() in my .vimrc

I get the following error:

Not an editor command: fzf#install()

So far all of the documentation related to installation has to do with Vim Plug. How do I install fzf.vim using Vim 8 packages?

dopatraman avatar Aug 23 '20 21:08 dopatraman

I've run into the exact same issue... The instructions are far from clear, with all the confusion of having the plugin from this repo, plus the plugin from the other repo https://github.com/junegunn/fzf (as far as I could understand?).

Any help is welcome for the likes of use that use the native plugin management of Vim.

molecula21 avatar Oct 24 '20 00:10 molecula21

@molecula21 as junegunn said in some comments, we need both fzf and fzf.vim and add the fzf folder to the runtime path. I'm using vim 8.2 with fzf is installed by homebrew.

ls ~/.vim/pack/plugins/opt

fzf fzf.vim

vim ~/.vimrc

packadd! fzf
packadd! fzf.vim
set rtp+=/usr/local/opt/fzf

vuau avatar Oct 24 '20 05:10 vuau

@vuau you mentioned that you installed fzf with homebrew. Is that a symlink to fzf in ~/.vim/pack/plugins/opt or did you also clone fzf into .vim/pack/plugins/opt?

quarterpi avatar Oct 26 '20 18:10 quarterpi

@quarterpi I cloned it. At first, I tried set rtp+=/usr/local/opt/fzf as what the document said. The result was :FZF worked but the :Files command didn't. After that I cloned the fzf repo then it worked. It's weird that for now, I remove fzf and the :Files command still working :-|

vuau avatar Oct 27 '20 01:10 vuau

Thank you! I had also tried set rtp=/usr/local/opt/fzf and got the same results as you. When you showed the contents of ~/.vim/pack/plugins/opt I tried a symbolic link which did not work (If anyone can explain to me why, I would love to know). Cloning fzf and fzf.vim worked for me. However it leaves me questioning if the Vim8 package manager is really supported. It seams like an anti-pattern to have both the cloned version for Vim and the homebrew version for zsh (or whatever shell you prefer).

quarterpi avatar Oct 27 '20 16:10 quarterpi

I have created a pull request detailing installation with vim 8 package manager. Simply put... git clone https://github.com/junegunn/fzf.git ~/.vim/pack/packages/start/fzf git clone https://github.com/junegunn/fzf.vim.git ~/.vim/pack/packages/start/fzf.vim There is no need to set rtp=/usr/local/opt/fzf.

quarterpi avatar Oct 27 '20 17:10 quarterpi

I have created a pull request detailing installation with vim 8 package manager. Simply put... git clone https://github.com/junegunn/fzf.git ~/.vim/pack/packages/start/fzf git clone https://github.com/junegunn/fzf.vim.git ~/.vim/pack/packages/start/fzf.vim There is no need to set rtp=/usr/local/opt/fzf.

Thank you. You saved my time.
But why I downloaded fzf.vim and fzf into ~/.vim/pack/plugins/start doesn't work?

leyafo avatar Jul 23 '22 15:07 leyafo

It seemed overkill to install the full source code for FZF as a subdir of a .vimrc/pack/* directory. And since I installed FZF as a package I assumed that there'd be an approporate fzf.vim somewhere on the system.

I'm running on Ubuntu 22.04.1 LTS. Here is a command sequence that worked for me.

Symlink the apt installed fzf.vim:

cd ~/.vim/pack/packages/
locate fzf.vim
# output includes /usr/share/doc/fzf/examples/fzf.vim from an earlier `apt install fzf`
mkdir -p fzf/plugin
ln -s /usr/share/doc/fzf/examples/fzf.vim fzf/plugin

Now clone the fzf.vim repo into the same package subdir:

git clone https://github.com/junegunn/fzf.vim.git

Now starting vim . for example, and then running :Ag some string does the expected thing.

YMMV

cfedde avatar Dec 17 '22 06:12 cfedde

Install the vim plugin: git clone https://github.com/junegunn/fzf.vim.git ~/.vim/pack/packages/start/fzf.vim

Setup the &runtimepath in .vimrc:

" Use fzf in Vim
if isdirectory('/usr/local/opt/fzf') " Homebrew
	set rtp+=/usr/local/opt/fzf
elseif isdirectory('/opt/homebrew/opt/fzf') " Homebrew on Apple Silicon
  set rtp+=/opt/homebrew/opt/fzf
end

Test: vim -c :Files

Generate help tags: :helptags ~/.vim/pack/packages/start/fzf.vim/doc

Test help: :h Files

piejanssens avatar Aug 16 '23 07:08 piejanssens