/nvim-fzf

A minimalistic fzf plugin written in Lua

Primary LanguageLuaMIT LicenseMIT

nvim-fzf

A minimalistic fzf plugin.

This project is heavily inspired by fzf.vim, but has a few differences:

  • Pure Lua implementation
  • Much smaller codebase
  • Fewer dependencies and features

The only dependency is the configured basic fzf plugin that is usually installed with the fzf package. You can use the following command to check that the basic plugin works:

:call fzf#run()

Installation

packer.nvim:

require('packer').startup(function(use)
    use('kupospelov/nvim-fzf')
end)

lazy.nvim:

require('lazy').setup({
    { 'kupospelov/nvim-fzf' },
})

Configuration

The default configuration:

local config = {
    options = {},
    layout = {
        tmux = '-p90%,60%',
        window = { width = 0.9, height = 0.6 },
    },
}

Settings can be changed using the setup function that accepts a table with the following fields:

  • options contains options for fzf.
  • layout configures the size and position of the fzf window.
    • tmux contains the arguments to pass to the fzf-tmux command.
    • window contains the width and height of the popup window in the range from 0.0 to 1.0.

The plugin uses a tmux popup when used in a tmux session. The tmux popup can be disabled by setting a layout that only has window set:

local fzf = require('fzf')
fzf.setup({
    layout = {
        window = {
            width = 0.9,
            height = 0.6,
        },
    },
})

Functions

The plugin exports functions that you can use to create custom mappings or commands:

vim.keymap.set('n', '<C-P>', fzf.files)

vim.keymap.set('n', '<C-P>', function()
    fzf.files('ls')
end)
Function Description
buffers Open buffers.
files Files to open. An optional source command can be passed as a parameter to be used as input instead of $FZF_DEFAULT_COMMAND.