Replies: 2 comments 9 replies
-
Haven't tested but this would be my approach:
|
Beta Was this translation helpful? Give feedback.
4 replies
-
Thanks @ibhagwan and @nenahp . Here is the full config with autofocus and automatic width / height: return {
"https://github.com/ibhagwan/fzf-lua",
version = "*",
config = function()
local win_opts = function()
local bufs_fn_len = {}
local max_len = 0
for _, buf_nr in ipairs(vim.api.nvim_list_bufs()) do
if vim.api.nvim_buf_is_valid(buf_nr) then
local buf_listed = vim.api.nvim_get_option_value('buflisted', { buf = buf_nr })
local buf_nm = vim.api.nvim_buf_get_name(buf_nr)
buf_nm = vim.fn.expand(buf_nm)
buf_nm = vim.fn.fnamemodify(buf_nm, ":.")
if buf_listed then
if buf_nm ~= '' then
buf_len = string.len(buf_nm)
table.insert(bufs_fn_len, buf_len)
end
end
end
end
for _, len in ipairs(bufs_fn_len) do
max_len = math.max(max_len, len)
end
return {
height = #bufs_fn_len + 6,
width = max_len + 6,
}
end
require('fzf-lua').setup({
tabs = {
keymap = function() -- autofocus current tab
local curtab = vim.fn.tabpagenr()
local pos = 1
for i, t in ipairs(vim.api.nvim_list_tabpages()) do
if i < curtab then pos = pos + 1 + #vim.api.nvim_tabpage_list_wins(t) end
end
return { fzf = { load = string.format("transform:echo 'pos(%d)'", pos) } }
end,
actions = {
result = {
fn = function(s)
local fzf_match_cnt = tonumber(unpack(s))
local w = require('fzf-lua.utils').fzf_winobj()
local opts = win_opts()
w._o.winopts.width = opts.width + 20
w._o.winopts.height = fzf_match_cnt + 3
w:redraw()
end,
exec_silent = true,
field_index = '$FZF_MATCH_COUNT',
},
}
},
})
end
} Resulting window, correctly padded: |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Some pickers work best full-screen (e.g. "show me all project files") while others are unlikely to occupy much space (e.g. open buffers).
It is possible to create a pop-up window that fits its content?
Somewhat related to #1934
Beta Was this translation helpful? Give feedback.
All reactions