How do I install fzf.vim using Vim 8 native package loading?
- [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:
- Add the fzf binary to
rtpin my.vimrc - 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?
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 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 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 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 :-|
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).
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.
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/fzfgit clone https://github.com/junegunn/fzf.vim.git ~/.vim/pack/packages/start/fzf.vimThere is no need toset 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?
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
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