Closed ilya-bc closed 2 years ago
Ty for the kind words @ilya-bc!
I only recently added the full blown git_status
with <left>|<right>
to stage/unstage, in the process I forgot to take into account icon customizations :-)
https://github.com/ibhagwan/fzf-lua/commit/3eb5baa6e9beff2fdc51c6152707206a0ab80a26 - this takes care of it, update to the latest commit and you'll have both preview and stage/unstage working properly with icon customiztaion.
I would like to try the customization because of your hard work, thanks for the update!
First of all, thank you for this plugin 👍 . I've been using
fzf.vim
for a while now, but when I switched to NeoVim I started to migrate all Vimscript plugins to their alternatives written in Lua. Althoughtelescope
is very nice etc, but there is something that still feels a bit off 🤷 .Now to the main point. Overriding git icons using examples from the README, breaks preview for
FzfLua git_status
Version of
fzf-lua
: https://github.com/ibhagwan/fzf-lua/tree/e40d65cI've tried different values for the
icon
and for different git modesExample of full config. Click to expand :point_down:
```lua local actions = require "fzf-lua.actions" require'fzf-lua'.setup { -- fzf_bin = 'sk', -- use skim instead of fzf? -- https://github.com/lotabout/skim global_resume = true, -- enable global `resume`? -- can also be sent individually: -- `.({ gl ... })`
global_resume_query = true, -- include typed query in `resume`?
winopts = {
-- split = "belowright new",-- open in a split instead?
-- "belowright new" : split below
-- "aboveleft new" : split above
-- "belowright vnew" : split right
-- "aboveleft vnew : split left
-- Only valid when using a float window
-- (i.e. when 'split' is not defined, default)
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 = { '╭', '─', '╮', '│', '╯', '─', '╰', '│' },
fullscreen = false, -- start fullscreen?
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
search = 'Search', -- search matches (ctags)
-- 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 ({ , }
-- applies only when scrollbar = 'border'
delay = 100, -- delay(ms) displaying the preview
-- prevents lag on fast scrolling
winopts = { -- builtin previewer window options
number = true,
relativenumber = false,
cursorline = true,
cursorlineopt = 'both',
cursorcolumn = false,
signcolumn = 'no',
list = false,
foldenable = false,
foldmethod = 'manual',
},
},
on_create = function()
-- 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", "", "",
-- { silent = true, noremap = true })
end,
},
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
[""] = "toggle-fullscreen",
-- Only valid with the 'builtin' previewer
[""] = "toggle-preview-wrap",
[""] = "toggle-preview",
-- Rotate preview clockwise/counter-clockwise
[""] = "toggle-preview-ccw",
[""] = "toggle-preview-cw",
[""] = "preview-page-down",
[""] = "preview-page-up",
[""] = "preview-page-reset",
},
fzf = {
-- fzf '--bind=' options
["ctrl-z"] = "abort",
["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",
},
},
fzf_opts = {
-- options are sent as `=`
-- set to `false` to remove a flag
-- set to '' for a non-value flag
-- for raw args use `fzf_args` instead
['--ansi'] = '',
['--prompt'] = '> ',
['--info'] = 'inline',
['--height'] = '100%',
['--layout'] = 'reverse',
},
-- fzf '--color=' options (optional)
--[[ fzf_colors = {
["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" },
}, ]]
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,
},
git_diff = {
cmd_deleted = "git diff --color HEAD --",
cmd_modified = "git diff --color HEAD",
cmd_untracked = "git diff --color --no-index /dev/null",
-- pager = "delta", -- if you have `delta` installed
},
man = {
cmd = "man -c %s | col -bx",
},
builtin = {
syntax = true, -- preview syntax highlight?
syntax_limit_l = 0, -- syntax limit (lines), 0=nolimit
syntax_limit_b = 1024*1024, -- syntax limit (bytes), 0=nolimit
},
},
-- provider setup
files = {
-- previewer = "bat", -- uncomment to override previewer
-- (name from 'previewers' table)
-- set to 'false' to disable
prompt = 'Files❯ ',
multiprocess = true, -- run command in a separate process
git_icons = true, -- show git icons?
file_icons = true, -- show file icons?
color_icons = true, -- colorize file|git icons
-- executed command priority is 'cmd' (if exists)
-- otherwise auto-detect prioritizes `fd`:`rg`:`find`
-- default options are controlled by 'fd|rg|find|_opts'
-- NOTE: 'find -printf' requires GNU find
-- cmd = "find . -type f -printf '%P\n'",
find_opts = [[-type f -not -path '*/\.git/*' -printf '%P\n']],
rg_opts = "--color=never --files --hidden --follow -g '!.git'",
fd_opts = "--color=never --type f --hidden --follow --exclude .git",
actions = {
-- set bind to 'false' to disable an action
-- 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,
-- custom actions are available too
["ctrl-y"] = function(selected) print(selected[1]) end,
}
},
git = {
files = {
prompt = 'GitFiles❯ ',
cmd = 'git ls-files --exclude-standard',
multiprocess = false, -- run command in a separate process
git_icons = true, -- show git icons?
file_icons = true, -- show file icons?
color_icons = true, -- colorize file|git icons
},
status = {
prompt = 'GitStatus❯ ',
cmd = "git status -s",
previewer = "git_diff",
file_icons = true,
git_icons = true,
color_icons = true,
actions = {
["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,
["right"] = { actions.git_unstage, actions.resume },
["left"] = { actions.git_stage, actions.resume },
},
},
commits = {
prompt = 'Commits❯ ',
cmd = "git log --pretty=oneline --abbrev-commit --color",
preview = "git show --pretty='%Cred%H%n%Cblue%an%n%Cgreen%s' --color {1}",
actions = {
["default"] = actions.git_checkout,
},
},
bcommits = {
prompt = 'BCommits❯ ',
cmd = "git log --pretty=oneline --abbrev-commit --color",
preview = "git show --pretty='%Cred%H%n%Cblue%an%n%Cgreen%s' --color {1}",
actions = {
["default"] = actions.git_buf_edit,
["ctrl-s"] = actions.git_buf_split,
["ctrl-v"] = actions.git_buf_vsplit,
["ctrl-t"] = actions.git_buf_tabedit,
},
},
branches = {
prompt = 'Branches❯ ',
cmd = "git branch --all --color",
preview = "git log --graph --pretty=oneline --abbrev-commit --color {1}",
actions = {
["default"] = actions.git_switch,
},
},
icons = {
["M"] = { icon = "★", color = "blue" },
["D"] = { icon = "✗", color = "red" },
["A"] = { icon = "+", color = "green" },
["?"] = { icon = "?", color = "red" },
},
},
grep = {
prompt = 'Rg❯ ',
input_prompt = 'Grep For❯ ',
multiprocess = true, -- run command in a separate process
git_icons = true, -- show git icons?
file_icons = true, -- show file icons?
color_icons = true, -- colorize file|git icons
-- 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",
-- 'live_grep_glob' options:
glob_flag = "--iglob", -- for case sensitive globs use '--glob'
glob_separator = "%s%-%-" -- query separator pattern (lua): ' --'
},
args = {
prompt = 'Args❯ ',
files_only = true,
-- added on top of regular file actions
actions = { ["ctrl-x"] = actions.arg_del }
},
oldfiles = {
prompt = 'History❯ ',
cwd_only = false,
},
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 = {
["default"] = actions.buf_edit,
["ctrl-s"] = actions.buf_split,
["ctrl-v"] = actions.buf_vsplit,
["ctrl-t"] = actions.buf_tabedit,
-- 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 },
}
},
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.
['--delimiter'] = vim.fn.shellescape(']'),
["--nth"] = '2..',
["--tiebreak"] = 'index',
},
actions = {
["default"] = actions.buf_edit,
["ctrl-s"] = actions.buf_split,
["ctrl-v"] = actions.buf_vsplit,
["ctrl-t"] = actions.buf_tabedit,
}
},
blines = {
previewer = "builtin", -- set to 'false' to disable
prompt = 'BLines❯ ',
show_unlisted = true, -- include 'help' buffers
no_term_buffers = false, -- include 'term' buffers
fzf_opts = {
-- hide filename, tiebreak by line no.
['--delimiter'] = vim.fn.shellescape('[:]'),
["--with-nth"] = '2..',
["--tiebreak"] = 'index',
},
actions = {
["default"] = actions.buf_edit,
["ctrl-s"] = actions.buf_split,
["ctrl-v"] = actions.buf_vsplit,
["ctrl-t"] = actions.buf_tabedit,
}
},
colorschemes = {
prompt = 'Colorschemes❯ ',
live_preview = true, -- apply the colorscheme on preview?
actions = { ["default"] = actions.colorscheme, },
winopts = { height = 0.55, width = 0.30, },
post_reset_cb = function()
-- reset statusline highlights after
-- a live_preview of the colorscheme
-- require('feline').reset_highlights()
end,
},
quickfix = {
file_icons = true,
git_icons = true,
},
lsp = {
prompt = '❯ ',
cwd_only = false, -- LSP/diagnostics for cwd only?
async_or_timeout = 5000, -- timeout(ms) or 'true' for async calls
file_icons = true,
git_icons = false,
lsp_icons = true,
severity = "hint",
icons = {
["Error"] = { icon = "", color = "red" }, -- error
["Warning"] = { icon = "", color = "yellow" }, -- warning
["Information"] = { icon = "", color = "blue" }, -- info
["Hint"] = { icon = "", color = "magenta" }, -- hint
},
},
-- uncomment to disable the previewer
-- nvim = { marks = { previewer = { _ctor = false } } },
-- helptags = { previewer = { _ctor = false } },
-- manpages = { previewer = { _ctor = false } },
-- uncomment to set dummy win location (help|man bar)
-- "topleft" : up
-- "botright" : down
-- helptags = { previewer = { split = "topleft" } },
-- uncomment to use `man` command as native fzf previewer
-- manpages = { previewer = { _ctor = require'fzf-lua.previewer'.fzf.man_pages } },
-- optional override of file extension icon colors
-- available colors (terminal):
-- clear, bold, black, red, green, yellow
-- blue, magenta, cyan, grey, dark_grey, white
-- padding can help kitty term users with
-- double-width icon rendering
file_icon_padding = '',
file_icon_colors = {
["lua"] = "blue",
},
}
```