diff --git a/lua/lazyvim/plugins/extras/editor/fzf.lua b/lua/lazyvim/plugins/extras/editor/fzf.lua index c37e6788..dd935282 100644 --- a/lua/lazyvim/plugins/extras/editor/fzf.lua +++ b/lua/lazyvim/plugins/extras/editor/fzf.lua @@ -82,7 +82,8 @@ return { ["--no-scrollbar"] = true, }, defaults = { - formatter = "path.filename_first", + -- formatter = "path.filename_first", + formatter = "path.hl", }, -- Custom LazyVim option to configure vim.ui.select ui_select = function(fzf_opts, items) @@ -101,6 +102,38 @@ return { }, }) end, + formatters = { + path = { + hl = { + _to = function() + local utils = require("fzf-lua.utils") + local _, hl_file = utils.ansi_from_hl("FzfLuaFilePart", "foo") + local _, hl_dir = utils.ansi_from_hl("FzfLuaDirPart", "foo") + return ([[ + return function(s, _, m) + local _path, _utils = m.path, m.utils + local _hl_dir = "%s" + local _hl_file = "%s" + local parent = _path.parent(s) + local tail = _path.tail(s) + if #_hl_file > 0 then + tail = _hl_file .. tail .. _utils.ansi_escseq.clear + end + if parent then + parent = _path.remove_trailing(parent) .. "/" + if #_hl_dir > 0 then + parent = _hl_dir .. parent .. _utils.ansi_escseq.clear + end + else + parent = "" + end + return parent .. tail + end + ]]):format(hl_dir, hl_file) + end, + }, + }, + }, winopts = { width = 0.8, height = 0.8,