Home

Awesome

nvim-finder

nvim-finder is a fuzzy finder built upon popfix fuzzy engine. This repository is a bundle of commands for fuzzy finding various things in neovim.

Popfix's fuzzy engine abstraction is highly extensible and purely written in lua. Infact, it is possible to use different fuzzy engines for different jobs. One of the major goal of popfix's default fuzzy engine is to remain responsive even for big jobs with a good visual performance.

Installation

Install it as any other plugin. For example with vim-plug:

Invoking plugin

Using vimscript commands

nvim-finder ships a Finder command. Any nvim-finder function can be invoked using:

:Finder command init_text

command is the function needed to be invoked (like files, git_files, grep, etc). Tab-completion would also list all the commands available in nvim-finder.

init_text is the initial prompt text with which nvim-finder would be launched. If not provided, then nvim-finder would launch with no initial prompt text (the default behavior).

Example:

This would launch file searcher (default behavior) :

:Finder files

This would launch file searcher with init.vim as initital prompt text:

:Finder files init.vim

Using lua

With default opts

lua require'finder'.command()

With custom opts

Custom opts are passed as lua tables.

lua require'finder'.command{<opts>}

Example:

lua require'finder'.files{preview_disabled = true, height = 24}

Example mapping:

nnoremap <leader>p <cmd>lua require'finder'.files{}<CR>

Currently supported commands

Enabling native sorter

popfix also ships an optional sorter 'native-fzy-sorter' as a separate git submodule. This sorter is written in C and is very fast in compare to other sorters. This gives a huge performance boost.

If you have enabled popfix's native-fzy-sorter (read popfix's README.md for steps) then you can use this sorter as default sorter for nvim-finder using:

vim.g.enable_finder_native_sorter = true

Custom Opts

These are custom opts supported by every nvim-finder command:

cwd [string]

Directory from which command will be launched. By default vim's current working directory is used.

Example: cwd = '/home/user/.config/nvim'

cmd [string]

Command used for find files in directory

Example: cmd = 'find .'

preview_disabled [boolean]

Decides if preview will be disabled for the command. Doesn't effect when command doesn't support preview. Default is false.

Example: preview_disabled = true

height [integer]

Height of finder window.

Example: height = 24

width [integer]

Width of finder window.

Example: width = 24

mode [string]

Render mode of plugin. nvim-finder supports multiple rendering modes.

Supported rendering modes are:

Example: mode = 'split'

init_text [string]

Initial text with which plugin would start.

Example: init_text = 'somefile.cc'

sorter [sorter's instance] [See popfix]

Custom sorter for command. Sorter changes the way plugin sorts the result according to current prompt text. You can pick some predefined sorter from popfix's builtin sorters or can have you own sorter. To read about sorter see popfix

By default fzy native sorter is used.

Example: sorter = require'popfix.sorter':new_fzy_soter()

Custom Highlighting

nvim-finder exposes some highlight group that highlight different elements of fuzzy window.

Border color of nvim-finder's list window

Border color of nvim-finder's preview window

Border color of nvim-finder's prompt window

Defines foreground and background color of list.

Defines foreground and background color of preview.

Defines foreground and background color of prompt window.

Defines the appearance of selected list element.

Defines the appearance of list characters that match with current prompt text.

Defines the appearance of prompt string (default prompt command is >)

Defines the appearance of highlighted line in preview window.

Contribute

Raise an issue or create a PR if you feel some important command is missing. This is possible that some commands are missing because they may not be in my workflow. :smiley:

If you feel there is any bug in fuzzy engine, please raise an issue in popfix issues.

If you feel working of any command is not proper please make an issue here or create a PR.