2021-07-22 00:52:05 +00:00
< div align = "center" >
2021-07-14 21:25:37 +00:00
# fzf :heart: lua
2021-07-22 00:52:05 +00:00
![Neovim version ](https://img.shields.io/badge/Neovim-0.5-57A143?style=flat-square&logo=neovim )
2021-07-22 02:59:18 +00:00
[Installation ](#installation ) • [Usage ](#usage ) • [Commands ](#commands ) • [Customization ](#customization ) • [Wiki ](https://github.com/ibhagwan/fzf-lua/wiki )
2021-07-22 00:52:05 +00:00
2021-10-04 18:32:14 +00:00
![Demo ](https://raw.githubusercontent.com/wiki/ibhagwan/fzf-lua/demo.gif )
2021-07-14 21:25:37 +00:00
2021-07-19 00:35:42 +00:00
[fzf ](https://github.com/junegunn/fzf ) changed my life, it can change yours too, if you allow it.
2021-07-14 21:25:37 +00:00
2021-07-22 00:52:05 +00:00
< / div >
2021-09-20 02:04:55 +00:00
## Rationale
2021-07-14 21:25:37 +00:00
What more can be said about [fzf ](https://github.com/junegunn/fzf )? It is the
single most impactful tool for my command line workflow, once I started using
fzf I couldn’ t see myself living without it.
> **To understand fzf properly I highly recommended [fzf
> screencast](https://www.youtube.com/watch?v=qgG5Jhi_Els) by
> [@samoshkin](https://github.com/samoshkin)**
This is my take on the original
[fzf.vim ](https://github.com/junegunn/fzf.vim ), written in lua for neovim 0.5,
it builds on the elegant
[nvim-fzf ](https://github.com/vijaymarupudi/nvim-fzf ) as an async interface to
create a performant and lightweight fzf client for neovim that rivals any of
the new shiny fuzzy finders for neovim.
2021-09-20 02:04:55 +00:00
## Why Fzf-Lua
2021-07-14 21:25:37 +00:00
... and not, to name a few,
[telescope ](https://github.com/nvim-telescope/telescope.nvim ) or
[vim-clap ](https://github.com/liuchengxu/vim-clap )?
As [@junegunn ](https://github.com/junegunn ) himself put it, “because you can
and you love `fzf` ”.
If you’ re happy with your current setup there is absolutely no reason to switch.
That said, without taking anything away from the greatness of other plugins I
found it more efficient having a uniform experience between my shell and my
nvim. In addition `fzf` has been a rock for me since I started using it and
hadn’ t failed me once, it never hangs and can handle almost anything you throw
at it. That, **and colorful file icons and git indicators!** .
2021-09-20 02:04:55 +00:00
## Dependencies
2021-07-14 21:25:37 +00:00
2021-11-19 03:40:12 +00:00
- `Linux` or `MacOS`
- [`neovim` ](https://github.com/neovim/neovim/releases ) version > 0.5.0
2021-12-27 18:59:23 +00:00
- [`fzf` ](https://github.com/junegunn/fzf ) version > 0.24.0 **or**
2021-08-04 16:58:59 +00:00
[`skim` ](https://github.com/lotabout/skim ) binary installed
2021-07-14 21:25:37 +00:00
- [nvim-web-devicons ](https://github.com/kyazdani42/nvim-web-devicons )
(optional)
2021-12-22 04:52:57 +00:00
### Optional dependencies
2021-07-14 21:25:37 +00:00
2021-11-19 03:40:12 +00:00
- [fd ](https://github.com/sharkdp/fd ) - better `find` utility
- [rg ](https://github.com/BurntSushi/ripgrep ) - better `grep` utility
- [bat ](https://github.com/sharkdp/bat ) - syntax highlighted previews when
using fzf's native previewer
- [delta ](https://github.com/dandavison/delta ) - syntax highlighted git pager
for git status previews
2022-03-13 06:51:59 +00:00
- [viu ](https://github.com/atanunq/viu ) - terminal image previews (needs to be
2022-03-13 12:26:10 +00:00
configured via `previewer.builtin.extensions` )
- [ueberzug ](https://github.com/seebye/ueberzug ) - X11 image previews (needs to
be configured via `previewer.builtin.extensions` )
2022-02-12 01:30:25 +00:00
- [nvim-dap ](https://github.com/mfussenegger/nvim-dap ) - for Debug Adapter
Protocol (DAP) support
2021-11-19 03:40:12 +00:00
2021-09-20 02:04:55 +00:00
## Installation
2021-07-14 21:25:37 +00:00
Using [vim-plug ](https://github.com/junegunn/vim-plug )
```vim
2022-03-08 12:51:11 +00:00
Plug 'ibhagwan/fzf-lua', {'branch': 'main'}
2021-12-28 00:25:18 +00:00
" optional for icon support
2021-07-22 02:59:18 +00:00
Plug 'kyazdani42/nvim-web-devicons'
2021-07-14 21:25:37 +00:00
```
Using [packer.nvim ](https://github.com/wbthomason/packer.nvim )
```lua
use { 'ibhagwan/fzf-lua',
2021-12-12 18:36:54 +00:00
-- optional for icon support
requires = { 'kyazdani42/nvim-web-devicons' }
2021-07-14 21:25:37 +00:00
}
```
2021-08-04 22:22:10 +00:00
> **Note:** if you already have fzf installed you do not need to install `fzf`
2021-07-14 21:25:37 +00:00
> or `fzf.vim`, however if you do not have it installed, **you only need** fzf
> which can be installed with (fzf.vim is not a requirement nor conflict):
> ```vim
> Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
> ```
> or with [packer.nvim](https://github.com/wbthomason/packer.nvim):
>```lua
>use = { 'junegunn/fzf', run = './install --bin', }
>```
## Usage
Fzf-lua aims to be as plug and play as possible with sane defaults, you can
run any fzf-lua command like this:
```lua
:lua require('fzf-lua').files()
2021-08-05 16:34:27 +00:00
-- or using the `FzfLua` vim command:
:FzfLua files
2021-07-14 21:25:37 +00:00
```
or with arguments:
```lua
:lua require('fzf-lua').files({ cwd = '~/.config' })
2021-08-05 16:34:27 +00:00
-- or using the `FzfLua` vim command:
:FzfLua files cwd=~/.config
2021-07-14 21:25:37 +00:00
```
which can be easily mapped to:
```vim
nnoremap < c-P > < cmd > lua require('fzf-lua').files()< CR >
```
2021-09-03 20:28:50 +00:00
or if using `init.lua` :
```lua
vim.api.nvim_set_keymap('n', '< c-P > ',
"< cmd > lua require('fzf-lua').files()< CR > ",
{ noremap = true, silent = true })
```
2021-07-14 21:25:37 +00:00
## Commands
2021-09-20 02:04:55 +00:00
### Buffers and Files
| Command | List |
| ---------------- | ------------------------------------------ |
| `buffers` | open buffers |
| `files` | `find` or `fd` on a path |
| `oldfiles` | opened files history |
| `quickfix` | quickfix list |
| `loclist` | location list |
| `lines` | open buffers lines |
| `blines` | current buffer lines |
| `tabs` | open tabs |
2021-10-05 15:43:28 +00:00
| `args` | argument list |
2021-08-14 21:39:19 +00:00
### Search
2021-09-20 02:04:55 +00:00
| Command | List |
| ---------------- | ------------------------------------------ |
| `grep` | search for a pattern with `grep` or `rg` |
| `grep_last` | run search again with the last pattern |
| `grep_cword` | search word under cursor |
| `grep_cWORD` | search WORD under cursor |
| `grep_visual` | search visual selection |
2021-11-13 18:20:40 +00:00
| `grep_project` | search all project lines (fzf.vim's `:Rg` ) |
2021-12-01 16:58:51 +00:00
| `grep_curbuf` | search current buffer lines |
| `lgrep_curbuf` | live grep current buffer |
2021-09-20 02:04:55 +00:00
| `live_grep` | live grep current project |
| `live_grep_resume` | live grep continue last search |
2021-11-13 18:36:05 +00:00
| `live_grep_glob` | live_grep with `rg --glob` support |
| `live_grep_native` | performant version of `live_grep` |
2021-08-14 21:39:19 +00:00
2022-03-06 08:59:11 +00:00
### Tags
| Command | List |
| ---------------- | ------------------------------------------ |
| `tags` | search project tags |
| `btags` | search buffer tags |
| `tags_grep` | grep project tags |
| `tags_grep_cword` | `tags_grep` word under cursor |
| `tags_grep_cWORD` | `tags_grep` WORD under cursor |
| `tags_grep_visual` | `tags_grep` visual selection |
| `tags_live_grep` | live grep project tags |
2021-08-14 21:39:19 +00:00
### Git
2021-09-20 02:04:55 +00:00
| Command | List |
| ---------------- | ------------------------------------------ |
| `git_files` | `git ls-files` |
| `git_status` | `git status` |
| `git_commits` | git commit log (project) |
| `git_bcommits` | git commit log (buffer) |
| `git_branches` | git branches |
2021-07-14 21:25:37 +00:00
2021-08-14 21:39:19 +00:00
### LSP
2021-09-20 02:04:55 +00:00
| Command | List |
| ---------------- | ------------------------------------------ |
| `lsp_references` | References |
| `lsp_definitions` | Definitions |
| `lsp_declarations` | Declarations |
| `lsp_typedefs` | Type Definitions |
| `lsp_implementations` | Implementations |
| `lsp_document_symbols` | Document Symbols |
| `lsp_workspace_symbols` | Workspace Symbols |
| `lsp_live_workspace_symbols` | Workspace Symbols (live query) |
| `lsp_code_actions` | Code Actions |
| `lsp_document_diagnostics` | Document Diagnostics |
| `lsp_workspace_diagnostics` | Workspace Diagnostics |
2021-07-20 06:21:20 +00:00
2021-08-14 21:39:19 +00:00
### Misc
2021-09-20 02:04:55 +00:00
| Command | List |
| ---------------- | ------------------------------------------ |
2021-12-16 23:39:09 +00:00
| `resume` | resume last command/query |
2021-09-20 02:04:55 +00:00
| `builtin` | fzf-lua builtin commands |
| `help_tags` | help tags |
| `man_pages` | man pages |
| `colorschemes` | color schemes |
| `commands` | neovim commands |
| `command_history` | command history |
| `search_history` | search history |
| `marks` | :marks |
2021-12-16 17:46:37 +00:00
| `jumps` | :jumps |
2021-12-17 06:03:46 +00:00
| `changes` | :changes |
2021-09-20 02:04:55 +00:00
| `registers` | :registers |
2022-02-05 20:29:20 +00:00
| `tagstack` | :tags |
2021-09-20 02:04:55 +00:00
| `keymaps` | key mappings |
| `spell_suggest` | spelling suggestions |
| `filetypes` | neovim filetypes |
| `packadd` | :packadd < package > |
2021-08-14 21:39:19 +00:00
2022-01-18 23:01:26 +00:00
### Neovim API
> `:help vim.ui.select` for more info
| Command | List
| -------------------- | -------------------------------------- |
| `register_ui_select` | register fzf-lua as the UI interface for `vim.ui.select` |
| `deregister_ui_select` | de-register fzf-lua with `vim.ui.select` |
2022-02-12 01:30:25 +00:00
### nvim-dap
> Requires [`nvim-dap`](https://github.com/mfussenegger/nvim-dap)
| Command | List |
| -------------------- | ------------------------------------------ |
| `dap_commands` | list,run `nvim-dap` builtin commands |
| `dap_configurations` | list,run debug configurations |
| `dap_breakpoints` | list,delete breakpoints |
| `dap_variables` | active session variables |
| `dap_frames` | active session jump to frame |
2022-01-18 23:01:26 +00:00
2021-07-14 21:25:37 +00:00
## Customization
I tried to make it as customizable as possible, if you find you need to change something that isn’ t below, open an issue and I’ ll do my best to add it.
customization can be achieved by calling the `setup()` function or individually sending parameters to a builtin command, for exmaple:
```lua
2021-09-21 23:16:29 +00:00
:lua require('fzf-lua').files({ fzf_opts = {['--layout'] = 'reverse-list'} })
2021-07-14 21:25:37 +00:00
```
Consult the list below for available settings:
```lua
2021-07-21 14:50:20 +00:00
local actions = require "fzf-lua.actions"
2021-07-14 21:25:37 +00:00
require'fzf-lua'.setup {
2021-12-28 00:25:18 +00:00
-- fzf_bin = 'sk', -- use skim instead of fzf?
-- https://github.com/lotabout/skim
2021-12-17 06:26:44 +00:00
global_resume = true, -- enable global `resume` ?
2021-12-21 02:12:37 +00:00
-- can also be sent individually:
-- `<any_function>.({ gl ... })`
global_resume_query = true, -- include typed query in `resume` ?
2021-07-27 16:18:12 +00:00
winopts = {
2021-09-09 17:28:19 +00:00
-- split = "belowright new",-- open in a split instead?
-- "belowright new" : split below
-- "aboveleft new" : split above
-- "belowright vnew" : split right
-- "aboveleft vnew : split left
2021-10-03 05:42:02 +00:00
-- Only valid when using a float window
2021-12-28 00:25:18 +00:00
-- (i.e. when 'split' is not defined, default)
2021-10-11 08:23:00 +00:00
height = 0.85, -- window height
width = 0.80, -- window width
row = 0.35, -- window row position (0=top, 1=bottom)
col = 0.50, -- window col position (0=left, 1=right)
-- border argument passthrough to nvim_open_win(), also used
-- to manually draw the border characters around the preview
-- window, can be set to 'false' to remove all borders or to
-- 'none', 'single', 'double' or 'rounded' (default)
border = { '╭', '─', '╮', '│', '╯', '─', '╰', '│' },
2021-10-03 05:42:02 +00:00
fullscreen = false, -- start fullscreen?
2021-10-11 08:23:00 +00:00
hl = {
normal = 'Normal', -- window normal color (fg+bg)
border = 'Normal', -- border color (try 'FloatBorder')
-- Only valid with the builtin previewer:
cursor = 'Cursor', -- cursor highlight (grep/LSP matches)
cursorline = 'CursorLine', -- cursor line
2021-12-11 21:16:58 +00:00
search = 'Search', -- search matches (ctags)
2021-10-11 08:23:00 +00:00
-- title = 'Normal', -- preview border title (file/buffer)
-- scrollbar_f = 'PmenuThumb', -- scrollbar "full" section highlight
-- scrollbar_e = 'PmenuSbar', -- scrollbar "empty" section highlight
},
preview = {
-- default = 'bat', -- override the default previewer?
-- default uses the 'builtin' previewer
border = 'border', -- border|noborder, applies only to
-- native fzf previewers (bat/cat/git/etc)
wrap = 'nowrap', -- wrap|nowrap
hidden = 'nohidden', -- hidden|nohidden
vertical = 'down:45%', -- up|down:size
horizontal = 'right:60%', -- right|left:size
layout = 'flex', -- horizontal|vertical|flex
flip_columns = 120, -- #cols to switch to horizontal on flex
-- Only valid with the builtin previewer:
title = true, -- preview border title (file/buf)?
scrollbar = 'float', -- `false` or string:'float|border'
-- float: in-window floating border
-- border: in-border chars (see below)
scrolloff = '-2', -- float scrollbar offset from right
-- applies only when scrollbar = 'float'
scrollchars = {'█', '' }, -- scrollbar chars ({ < full > , < empty > }
-- applies only when scrollbar = 'border'
2021-12-03 15:24:53 +00:00
delay = 100, -- delay(ms) displaying the preview
-- prevents lag on fast scrolling
2021-11-20 01:13:19 +00:00
winopts = { -- builtin previewer window options
number = true,
relativenumber = false,
cursorline = true,
cursorlineopt = 'both',
cursorcolumn = false,
signcolumn = 'no',
list = false,
foldenable = false,
foldmethod = 'manual',
},
2021-10-11 08:23:00 +00:00
},
on_create = function()
2021-10-06 19:52:38 +00:00
-- called once upon creation of the fzf main window
-- can be used to add custom fzf-lua mappings, e.g:
-- vim.api.nvim_buf_set_keymap(0, "t", "< C-j > ", "< Down > ",
-- { silent = true, noremap = true })
end,
2021-07-27 16:18:12 +00:00
},
2021-10-03 05:42:02 +00:00
keymap = {
-- These override the default tables completely
-- no need to set to `false` to disable a bind
-- delete or modify is sufficient
builtin = {
-- neovim `:tmap` mappings for the fzf win
2022-01-15 05:45:57 +00:00
["< F1 > "] = "toggle-help",
2021-10-03 05:42:02 +00:00
["< F2 > "] = "toggle-fullscreen",
-- Only valid with the 'builtin' previewer
["< F3 > "] = "toggle-preview-wrap",
["< F4 > "] = "toggle-preview",
2021-10-04 18:32:14 +00:00
-- Rotate preview clockwise/counter-clockwise
["< F5 > "] = "toggle-preview-ccw",
["< F6 > "] = "toggle-preview-cw",
2021-10-03 05:42:02 +00:00
["< S-down > "] = "preview-page-down",
["< S-up > "] = "preview-page-up",
["< S-left > "] = "preview-page-reset",
},
fzf = {
-- fzf '--bind=' options
2021-10-07 15:35:00 +00:00
["ctrl-z"] = "abort",
2021-10-03 05:42:02 +00:00
["ctrl-u"] = "unix-line-discard",
["ctrl-f"] = "half-page-down",
["ctrl-b"] = "half-page-up",
["ctrl-a"] = "beginning-of-line",
["ctrl-e"] = "end-of-line",
["alt-a"] = "toggle-all",
-- Only valid with fzf previewers (bat/cat/git/etc)
["f3"] = "toggle-preview-wrap",
["f4"] = "toggle-preview",
["shift-down"] = "preview-page-down",
["shift-up"] = "preview-page-up",
},
2021-10-19 17:02:04 +00:00
},
2022-02-01 04:00:20 +00:00
actions = {
-- These override the default tables completely
-- no need to set to `false` to disable an action
-- delete or modify is sufficient
files = {
2022-02-02 19:54:17 +00:00
-- providers that inherit these actions:
-- files, git_files, git_status, grep, lsp
-- oldfiles, quickfix, loclist, tags, btags
-- args
2022-02-01 04:00:20 +00:00
-- default action opens a single selection
-- or sends multiple selection to quickfix
-- replace the default action with the below
-- to open all files whether single or multiple
-- ["default"] = actions.file_edit,
["default"] = actions.file_edit_or_qf,
["ctrl-s"] = actions.file_split,
["ctrl-v"] = actions.file_vsplit,
["ctrl-t"] = actions.file_tabedit,
["alt-q"] = actions.file_sel_to_qf,
},
buffers = {
2022-02-02 19:54:17 +00:00
-- providers that inherit these actions:
-- buffers, tabs, lines, blines
2022-02-01 04:00:20 +00:00
["default"] = actions.buf_edit,
["ctrl-s"] = actions.buf_split,
["ctrl-v"] = actions.buf_vsplit,
["ctrl-t"] = actions.buf_tabedit,
}
},
2021-09-21 23:16:29 +00:00
fzf_opts = {
-- options are sent as `<left>=<right>`
-- set to `false` to remove a flag
-- set to '' for a non-value flag
-- for raw args use `fzf_args` instead
['--ansi'] = '',
2021-10-31 19:40:12 +00:00
['--prompt'] = '> ',
2021-09-21 23:16:29 +00:00
['--info'] = 'inline',
['--height'] = '100%',
['--layout'] = 'reverse',
},
2021-10-03 05:42:02 +00:00
-- fzf '--color=' options (optional)
--[[ fzf_colors = {
2021-12-28 00:25:18 +00:00
["fg"] = { "fg", "CursorLine" },
["bg"] = { "bg", "Normal" },
["hl"] = { "fg", "Comment" },
["fg+"] = { "fg", "Normal" },
["bg+"] = { "bg", "CursorLine" },
["hl+"] = { "fg", "Statement" },
["info"] = { "fg", "PreProc" },
["prompt"] = { "fg", "Conditional" },
["pointer"] = { "fg", "Exception" },
["marker"] = { "fg", "Keyword" },
["spinner"] = { "fg", "Label" },
["header"] = { "fg", "Comment" },
["gutter"] = { "bg", "Normal" },
2021-09-07 17:47:02 +00:00
}, ]]
2021-08-03 22:43:51 +00:00
previewers = {
cat = {
cmd = "cat",
args = "--number",
},
bat = {
cmd = "bat",
args = "--style=numbers,changes --color always",
theme = 'Coldark-Dark', -- bat preview theme (bat --list-themes)
config = nil, -- nil uses $BAT_CONFIG_PATH
},
head = {
cmd = "head",
args = nil,
},
2021-08-07 21:01:01 +00:00
git_diff = {
2021-12-19 09:32:36 +00:00
cmd_deleted = "git diff --color HEAD --",
cmd_modified = "git diff --color HEAD",
cmd_untracked = "git diff --color --no-index /dev/null",
2021-11-19 03:40:12 +00:00
-- pager = "delta", -- if you have `delta` installed
2021-08-07 21:01:01 +00:00
},
2021-10-11 22:15:19 +00:00
man = {
2021-10-13 21:27:16 +00:00
cmd = "man -c %s | col -bx",
2021-10-11 22:15:19 +00:00
},
2021-08-28 04:30:28 +00:00
builtin = {
syntax = true, -- preview syntax highlight?
2021-08-30 15:35:36 +00:00
syntax_limit_l = 0, -- syntax limit (lines), 0=nolimit
syntax_limit_b = 1024*1024, -- syntax limit (bytes), 0=nolimit
2022-03-06 07:05:41 +00:00
limit_b = 1024*1024*10, -- preview limit (bytes), 0=nolimit
2022-03-13 06:51:59 +00:00
-- preview extensions using a custom shell command:
-- for example, use `viu` for image previews
-- will do nothing if `viu` isn't executable
extensions = {
["gif"] = { "viu" },
["png"] = { "viu" },
},
2022-03-13 12:26:10 +00:00
-- if using `ueberzug` in the above extensions map
-- set the default image scaler, possible scalers:
-- false (none), "crop", "distort", "fit_contain",
-- "contain", "forced_cover", "cover"
-- https://github.com/seebye/ueberzug
ueberzug_scaler = "cover",
2021-08-28 04:30:28 +00:00
},
2021-08-03 22:43:51 +00:00
},
2021-07-27 16:18:12 +00:00
-- provider setup
2021-07-14 21:25:37 +00:00
files = {
2021-12-28 00:25:18 +00:00
-- previewer = "bat", -- uncomment to override previewer
-- (name from 'previewers' table)
-- set to 'false' to disable
2021-07-14 21:25:37 +00:00
prompt = 'Files❯ ',
2021-12-12 08:43:38 +00:00
multiprocess = true, -- run command in a separate process
2021-07-27 16:18:12 +00:00
git_icons = true, -- show git icons?
file_icons = true, -- show file icons?
color_icons = true, -- colorize file|git icons
2021-11-19 02:36:32 +00:00
-- executed command priority is 'cmd' (if exists)
2021-12-07 14:56:37 +00:00
-- otherwise auto-detect prioritizes `fd` :`rg`:`find`
-- default options are controlled by 'fd|rg|find|_opts'
2021-11-13 18:36:05 +00:00
-- NOTE: 'find -printf' requires GNU find
2021-11-19 02:36:32 +00:00
-- cmd = "find . -type f -printf '%P\n'",
2021-11-13 18:36:05 +00:00
find_opts = [[-type f -not -path '*/\.git/*' -printf '%P\n']],
2021-12-07 14:56:37 +00:00
rg_opts = "--color=never --files --hidden --follow -g '!.git'",
fd_opts = "--color=never --type f --hidden --follow --exclude .git",
2021-07-14 21:25:37 +00:00
actions = {
2022-02-01 04:00:20 +00:00
-- inherits from 'actions.files', here we can override
-- or set bind to 'false' to disable a default action
["default"] = actions.file_edit,
2021-09-09 18:56:19 +00:00
-- custom actions are available too
2021-10-05 15:43:28 +00:00
["ctrl-y"] = function(selected) print(selected[1]) end,
2021-07-14 21:25:37 +00:00
}
},
2021-07-20 06:21:20 +00:00
git = {
2021-08-06 02:34:49 +00:00
files = {
prompt = 'GitFiles❯ ',
cmd = 'git ls-files --exclude-standard',
2022-01-19 03:49:21 +00:00
multiprocess = true, -- run command in a separate process
2021-08-06 02:34:49 +00:00
git_icons = true, -- show git icons?
file_icons = true, -- show file icons?
color_icons = true, -- colorize file|git icons
2022-01-15 05:45:57 +00:00
-- force display the cwd header line regardles of your current working
-- directory can also be used to hide the header when not wanted
2022-01-11 14:18:56 +00:00
-- show_cwd_header = true
2021-08-06 02:34:49 +00:00
},
2021-08-07 21:01:01 +00:00
status = {
2021-12-19 09:32:36 +00:00
prompt = 'GitStatus❯ ',
cmd = "git status -s",
previewer = "git_diff",
file_icons = true,
git_icons = true,
color_icons = true,
actions = {
2022-02-01 04:00:20 +00:00
-- actions inherit from 'actions.files' and merge
["right"] = { actions.git_unstage, actions.resume },
["left"] = { actions.git_stage, actions.resume },
2021-12-19 09:32:36 +00:00
},
2021-08-07 21:01:01 +00:00
},
2021-08-06 02:34:49 +00:00
commits = {
prompt = 'Commits❯ ',
2021-10-05 17:48:52 +00:00
cmd = "git log --pretty=oneline --abbrev-commit --color",
2021-08-06 02:34:49 +00:00
preview = "git show --pretty='%Cred%H%n%Cblue%an%n%Cgreen%s' --color {1}",
actions = {
2021-08-30 16:53:21 +00:00
["default"] = actions.git_checkout,
2021-08-06 02:34:49 +00:00
},
},
bcommits = {
prompt = 'BCommits❯ ',
2021-10-05 17:48:52 +00:00
cmd = "git log --pretty=oneline --abbrev-commit --color",
2021-08-06 02:34:49 +00:00
preview = "git show --pretty='%Cred%H%n%Cblue%an%n%Cgreen%s' --color {1}",
actions = {
2021-08-30 16:53:21 +00:00
["default"] = actions.git_buf_edit,
["ctrl-s"] = actions.git_buf_split,
["ctrl-v"] = actions.git_buf_vsplit,
["ctrl-t"] = actions.git_buf_tabedit,
2021-08-06 02:34:49 +00:00
},
},
branches = {
prompt = 'Branches❯ ',
2021-09-06 22:46:46 +00:00
cmd = "git branch --all --color",
2021-09-08 21:54:27 +00:00
preview = "git log --graph --pretty=oneline --abbrev-commit --color {1}",
2021-08-06 02:34:49 +00:00
actions = {
["default"] = actions.git_switch,
},
},
2021-07-20 06:21:20 +00:00
icons = {
2021-07-27 16:18:12 +00:00
["M"] = { icon = "M", color = "yellow" },
["D"] = { icon = "D", color = "red" },
["A"] = { icon = "A", color = "green" },
2022-01-15 05:45:57 +00:00
["R"] = { icon = "R", color = "yellow" },
["C"] = { icon = "C", color = "yellow" },
2021-07-27 16:18:12 +00:00
["?"] = { icon = "?", color = "magenta" },
2021-12-17 06:26:44 +00:00
-- override git icons?
2021-12-28 00:25:18 +00:00
-- ["M"] = { icon = "★", color = "red" },
-- ["D"] = { icon = "✗", color = "red" },
-- ["A"] = { icon = "+", color = "green" },
2021-07-20 06:21:20 +00:00
},
},
2021-07-14 21:25:37 +00:00
grep = {
prompt = 'Rg❯ ',
input_prompt = 'Grep For❯ ',
2021-12-12 08:43:38 +00:00
multiprocess = true, -- run command in a separate process
2021-07-27 16:18:12 +00:00
git_icons = true, -- show git icons?
file_icons = true, -- show file icons?
color_icons = true, -- colorize file|git icons
2021-11-19 02:36:32 +00:00
-- executed command priority is 'cmd' (if exists)
-- otherwise auto-detect prioritizes `rg` over `grep`
-- default options are controlled by 'rg|grep_opts'
-- cmd = "rg --vimgrep",
rg_opts = "--column --line-number --no-heading --color=always --smart-case --max-columns=512",
grep_opts = "--binary-files=without-match --line-number --recursive --color=auto --perl-regexp",
2021-12-17 06:26:44 +00:00
-- 'live_grep_glob' options:
2022-03-09 06:29:42 +00:00
glob_flag = "--iglob", -- for case sensitive globs use '--glob'
glob_separator = "%s%-%-" -- query separator pattern (lua): ' --'
actions = {
-- actions inherit from 'actions.files' and merge
-- this action toggles between 'grep' and 'live_grep'
2022-03-10 08:01:13 +00:00
["ctrl-g"] = { actions.grep_lgrep }
2022-03-09 06:29:42 +00:00
},
no_header = false, -- hide grep|cwd header?
no_header_i = false, -- hide interactive header?
2021-07-14 21:25:37 +00:00
},
2021-10-05 15:43:28 +00:00
args = {
prompt = 'Args❯ ',
2021-10-05 15:55:46 +00:00
files_only = true,
2022-02-01 04:00:20 +00:00
-- actions inherit from 'actions.files' and merge
2022-02-12 19:54:19 +00:00
actions = { ["ctrl-x"] = { actions.arg_del, actions.resume } }
2021-10-05 15:43:28 +00:00
},
2021-07-14 21:25:37 +00:00
oldfiles = {
prompt = 'History❯ ',
cwd_only = false,
2022-02-12 16:51:39 +00:00
stat_file = true, -- verify files exist on disk
2022-02-12 08:00:57 +00:00
include_current_session = false, -- include bufs from current session
2021-07-14 21:25:37 +00:00
},
buffers = {
prompt = 'Buffers❯ ',
file_icons = true, -- show file icons?
color_icons = true, -- colorize file|git icons
sort_lastused = true, -- sort buffers() by last used
actions = {
2022-02-01 04:00:20 +00:00
-- actions inherit from 'actions.buffers' and merge
2021-12-19 04:12:43 +00:00
-- by supplying a table of functions we're telling
-- fzf-lua to not close the fzf window, this way we
-- can resume the buffers picker on the same window
-- eliminating an otherwise unaesthetic win "flash"
["ctrl-x"] = { actions.buf_del, actions.resume },
2021-07-14 21:25:37 +00:00
}
},
2022-02-02 19:54:17 +00:00
tabs = {
prompt = 'Tabs❯ ',
tab_title = "Tab",
tab_marker = "< < ",
file_icons = true, -- show file icons?
color_icons = true, -- colorize file|git icons
actions = {
-- actions inherit from 'actions.buffers' and merge
["default"] = actions.buf_switch,
["ctrl-x"] = { actions.buf_del, actions.resume },
},
2022-02-12 08:47:30 +00:00
fzf_opts = {
-- hide tabnr
['--delimiter'] = "'[\\):]'",
["--with-nth"] = '2..',
},
2022-02-02 19:54:17 +00:00
},
2021-12-02 17:19:20 +00:00
lines = {
previewer = "builtin", -- set to 'false' to disable
prompt = 'Lines❯ ',
show_unlisted = false, -- exclude 'help' buffers
no_term_buffers = true, -- exclude 'term' buffers
fzf_opts = {
-- do not include bufnr in fuzzy matching
-- tiebreak by line no.
2022-02-12 08:47:30 +00:00
['--delimiter'] = "'[\\]:]'",
2021-12-02 17:19:20 +00:00
["--nth"] = '2..',
["--tiebreak"] = 'index',
},
2022-02-01 04:00:20 +00:00
-- actions inherit from 'actions.buffers'
2021-12-02 17:19:20 +00:00
},
2021-08-31 22:02:35 +00:00
blines = {
previewer = "builtin", -- set to 'false' to disable
prompt = 'BLines❯ ',
2021-12-01 20:42:09 +00:00
show_unlisted = true, -- include 'help' buffers
no_term_buffers = false, -- include 'term' buffers
2021-12-02 17:19:20 +00:00
fzf_opts = {
-- hide filename, tiebreak by line no.
2022-02-12 08:47:30 +00:00
['--delimiter'] = "'[\\]:]'",
2021-12-02 17:19:20 +00:00
["--with-nth"] = '2..',
["--tiebreak"] = 'index',
},
2022-02-01 04:00:20 +00:00
-- actions inherit from 'actions.buffers'
2021-08-31 22:02:35 +00:00
},
2022-03-04 03:16:12 +00:00
tags = {
prompt = 'Tags❯ ',
ctags_file = "tags",
multiprocess = true,
file_icons = true,
git_icons = true,
color_icons = true,
2022-03-06 06:07:36 +00:00
-- 'tags_live_grep' options, `rg` prioritizes over `grep`
rg_opts = "--no-heading --color=always --smart-case",
grep_opts = "--color=auto --perl-regexp",
2022-03-09 06:29:42 +00:00
actions = {
-- actions inherit from 'actions.files' and merge
-- this action toggles between 'grep' and 'live_grep'
2022-03-10 08:01:13 +00:00
["ctrl-g"] = { actions.grep_lgrep }
2022-03-09 06:29:42 +00:00
},
no_header = false, -- hide grep|cwd header?
no_header_i = false, -- hide interactive header?
2022-03-04 03:16:12 +00:00
},
btags = {
prompt = 'BTags❯ ',
ctags_file = "tags",
multiprocess = true,
file_icons = true,
git_icons = true,
color_icons = true,
fzf_opts = {
['--delimiter'] = "'[\\]:]'",
["--with-nth"] = '2..',
["--tiebreak"] = 'index',
},
-- actions inherit from 'actions.files'
},
2021-07-14 21:25:37 +00:00
colorschemes = {
prompt = 'Colorschemes❯ ',
2021-07-27 16:18:12 +00:00
live_preview = true, -- apply the colorscheme on preview?
2021-12-28 00:25:18 +00:00
actions = { ["default"] = actions.colorscheme, },
winopts = { height = 0.55, width = 0.30, },
2021-07-27 16:18:12 +00:00
post_reset_cb = function()
-- reset statusline highlights after
-- a live_preview of the colorscheme
-- require('feline').reset_highlights()
2021-07-14 21:25:37 +00:00
end,
},
quickfix = {
2021-07-20 06:21:20 +00:00
file_icons = true,
git_icons = true,
},
lsp = {
2022-01-16 18:07:50 +00:00
prompt_postfix = '❯ ', -- will be appended to the LSP label
-- to override use 'prompt' instead
2021-08-11 22:26:19 +00:00
cwd_only = false, -- LSP/diagnostics for cwd only?
2021-12-05 17:31:06 +00:00
async_or_timeout = 5000, -- timeout(ms) or 'true' for async calls
2021-07-14 21:25:37 +00:00
file_icons = true,
2021-07-20 06:21:20 +00:00
git_icons = false,
lsp_icons = true,
2022-03-01 23:51:43 +00:00
ui_select = true, -- use 'vim.ui.select' for code actions
2022-03-02 17:55:04 +00:00
severity = "hint",
2021-07-20 06:21:20 +00:00
icons = {
["Error"] = { icon = "", color = "red" }, -- error
["Warning"] = { icon = "", color = "yellow" }, -- warning
["Information"] = { icon = "", color = "blue" }, -- info
["Hint"] = { icon = "", color = "magenta" }, -- hint
},
2021-07-14 21:25:37 +00:00
},
2021-09-09 07:08:35 +00:00
-- uncomment to disable the previewer
2021-12-28 00:25:18 +00:00
-- nvim = { marks = { previewer = { _ctor = false } } },
2021-09-09 22:27:38 +00:00
-- helptags = { previewer = { _ctor = false } },
-- manpages = { previewer = { _ctor = false } },
2021-09-09 17:28:19 +00:00
-- uncomment to set dummy win location (help|man bar)
-- "topleft" : up
-- "botright" : down
-- helptags = { previewer = { split = "topleft" } },
2021-09-09 22:27:38 +00:00
-- uncomment to use `man` command as native fzf previewer
-- manpages = { previewer = { _ctor = require'fzf-lua.previewer'.fzf.man_pages } },
2021-07-27 16:18:12 +00:00
-- optional override of file extension icon colors
-- available colors (terminal):
-- clear, bold, black, red, green, yellow
-- blue, magenta, cyan, grey, dark_grey, white
2021-09-05 19:00:57 +00:00
-- padding can help kitty term users with
-- double-width icon rendering
file_icon_padding = '',
2021-07-27 16:18:12 +00:00
file_icon_colors = {
2021-07-14 21:25:37 +00:00
["lua"] = "blue",
},
2022-02-16 19:57:01 +00:00
-- uncomment if your terminal/font does not support unicode character
-- 'EN SPACE' (U+2002), the below sets it to 'NBSP' (U+00A0) instead
-- nbsp = '\xc2\xa0',
2021-07-14 21:25:37 +00:00
}
```
2021-09-20 02:04:55 +00:00
This can also be run from a `.vim` file using:
2021-07-14 21:25:37 +00:00
```lua
lua < < EOF
require('fzf-lua').setup{
-- ...
}
EOF
```
2021-09-20 02:04:55 +00:00
## Credits
2021-07-15 19:51:03 +00:00
Big thank you to all those I borrowed code/ideas from, I read so many configs
and plugin codes that I probably forgot where I found some samples from so if
I missed your name feel free to contact me and I'll add it below:
2021-07-15 20:11:48 +00:00
- [@vijaymarupudi ](https://github.com/vijaymarupudi/ ) for his wonderful
[nvim-fzf ](https://github.com/vijaymarupudi/nvim-fzf ) plugin which is in the
core of this plugin
- [@tjdevries ](https://github.com/tjdevries/ ) for too many great things to
list here and for borrowing some of his
[nvim-telescope ](https://github.com/nvim-telescope/telescope.nvim ) provider
code
- [@lukas-reineke ](https://github.com/lukas-reineke ) for inspiring the
solution after browsing his
[dotfiles ](https://github.com/lukas-reineke/dotfiles ) and coming across his
[fuzzy.lua ](https://github.com/lukas-reineke/dotfiles/blob/master/vim/lua/fuzzy.lua )
, and while we're, also here for his great lua plugin
[indent-blankline ](https://github.com/lukas-reineke/indent-blankline.nvim )
- [@sindrets ](https://github.com/sindrets ) for borrowing utilities from his
fantastic lua plugin [diffview.nvim ](https://github.com/sindrets/diffview.nvim )
2021-09-20 02:04:55 +00:00
- [@kevinhwang91 ](https://github.com/kevinhwang91 ) for using his previewer
code as baseline for the builtin previewer and his must have plugin
[nvim-bqf ](https://github.com/kevinhwang91/nvim-bqf )