kevinhughes27 / dotfiles

4 stars 1 forks source link

Fzf only (no more fzf.vim) #10

Closed kevinhughes27 closed 1 year ago

kevinhughes27 commented 1 year ago

Rewrite my fzf config to use only fzf and not fzf.vim.

Why?

fzf.vim provides many functions of which I only use 4 and already overwrote config for 2 of them.

From the fzf.vim readme: emphasis mine

fzf itself is not a Vim plugin, and the official repository only provides the basic wrapper function for Vim. It's up to the users to write their own Vim commands with it. However, I've learned that many users of fzf are not familiar with Vimscript and are looking for the "default" implementation of the features they can find in the alternative Vim plugins.

This repository is a bundle of fzf-based commands and mappings extracted from my .vimrc to address such needs. They are not designed to be flexible or configurable, and there's no guarantee of backward-compatibility.

I don't use most of what fzf.vim provides, it is difficult to customize because it was not intended to be and it is difficult to understand and trace through how a command works because there are multiple layers of wrapping that span the two repos.

fzf/README-VIM explains how to use the basic wrapper to write your own commands which seems like a better fit. There are still a few layers of wrapping involved but it is now pretty easy to trace through how a command works.

My first implementation crafted a string to nvim_exec which worked for a few commands until I got to RG which needs a bind:change with the rg passed again and I ran into quote escaping issues. Then I pivoted to use vim.fn calls which allowed for passing arguments directly from lua. This worked except that some of the functionality added by fzf#wrap does so with an anonymous function which is not available in the second vim.fn call to fzf#run. I found this issue https://github.com/junegunn/fzf/issues/1778 which clued me in to just writing my own sinks which ended up working quite well.

Overall this was fun and I learned a lot about how fzf vim works.