Skip to content

Commit 1f6d847

Browse files
committed
feat: set statusline in splits
1 parent a8f7d50 commit 1f6d847

3 files changed

Lines changed: 56 additions & 1 deletion

File tree

lua/fzf-lua/fzf.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ function M.raw_fzf(contents, fzf_cli_args, opts)
199199
if not opts.is_fzf_tmux then
200200
vim.bo.filetype = "fzf"
201201

202+
local fzfwin = utils.fzf_winobj()
203+
if fzfwin then fzfwin:update_statusline() end
204+
202205
-- See note in "ModeChanged" above
203206
if vim.api.nvim_get_mode().mode == "t" then
204207
-- Called from another fzf-win most likely

lua/fzf-lua/init.lua

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,36 @@ function M.setup_highlights(override)
141141
vim.api.nvim_set_hl(0, hl_name, hl_def)
142142
end
143143

144+
-- courtesy of fzf.vim
145+
do
146+
local termguicolors = vim.o.termguicolors
147+
vim.api.nvim_set_hl(0, "fzf1",
148+
{
149+
default = true,
150+
ctermfg = termguicolors and 1 or 161,
151+
ctermbg = termguicolors and 8 or 238,
152+
fg = "#E12672",
153+
bg = "#565656"
154+
})
155+
vim.api.nvim_set_hl(0, "fzf2",
156+
{
157+
default = true,
158+
ctermfg = termguicolors and 2 or 151,
159+
ctermbg = termguicolors and 8 or 238,
160+
fg = "#BCDDBD",
161+
bg =
162+
"#565656"
163+
})
164+
vim.api.nvim_set_hl(0, "fzf3",
165+
{
166+
default = true,
167+
ctermfg = termguicolors and 7 or 252,
168+
ctermbg = termguicolors and 8 or 238,
169+
fg = "#D9D9D9",
170+
bg = "#565656"
171+
})
172+
end
173+
144174
-- Init the colormap singleton
145175
utils.COLORMAP()
146176
end

lua/fzf-lua/win.lua

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,7 @@ function FzfWin:close(fzf_bufnr, hide, hidden)
13001300
self.closing = nil
13011301
self._reuse = nil
13021302
_self = nil
1303-
utils.set_info({}) -- clear info
1303+
utils.set_info({}) -- clear info
13041304
end
13051305

13061306
function FzfWin.win_leave()
@@ -1522,6 +1522,28 @@ function FzfWin:update_preview_scrollbar()
15221522
end
15231523
end
15241524

1525+
function FzfWin:update_statusline()
1526+
if not self.winopts.split then return end
1527+
local parts = self.winopts.title or string.format(" %s ", FzfLua.get_info().cmd)
1528+
local statusline = { "%#fzf1# > %#fzf2#fzf-lua%#fzf3#" }
1529+
for _, t in ipairs(type(parts) == "table" and parts
1530+
or type(parts) == "string" and { parts }
1531+
or {}
1532+
) do
1533+
local hl, str = (function()
1534+
if type(t) == "table" and t[2] then
1535+
return t[2], t[1]
1536+
elseif type(t) == "table" then
1537+
return "FzfLuaTitle", tostring(t[1])
1538+
else
1539+
return "FzfLuaTitle", tostring(t)
1540+
end
1541+
end)()
1542+
table.insert(statusline, string.format("%%#%s#%s%%#fzf3#", hl, str))
1543+
end
1544+
vim.wo[self.fzf_winid].statusline = table.concat(statusline, " ")
1545+
end
1546+
15251547
---@param winid integer
15261548
---@param winopts table
15271549
---@param o table

0 commit comments

Comments
 (0)