mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-22 00:49:03 +02:00
feat(fzf): better layout for code actions
This commit is contained in:
parent
8346fa7ddc
commit
e948435f17
1 changed files with 18 additions and 8 deletions
|
@ -87,18 +87,28 @@ return {
|
||||||
},
|
},
|
||||||
-- Custom LazyVim option to configure vim.ui.select
|
-- Custom LazyVim option to configure vim.ui.select
|
||||||
ui_select = function(fzf_opts, items)
|
ui_select = function(fzf_opts, items)
|
||||||
local title = vim.trim((fzf_opts.prompt or "Select"):gsub("%s*:%s*$", ""))
|
|
||||||
local width, height ---@type number?, number?
|
|
||||||
if fzf_opts.kind ~= "codeaction" then
|
|
||||||
width, height = 0.5, math.floor(math.min(vim.o.lines * 0.8, #items + 2) + 0.5)
|
|
||||||
end
|
|
||||||
return vim.tbl_deep_extend("force", fzf_opts, {
|
return vim.tbl_deep_extend("force", fzf_opts, {
|
||||||
prompt = " ",
|
prompt = " ",
|
||||||
winopts = {
|
winopts = {
|
||||||
title = " " .. title .. " ",
|
title = " " .. vim.trim((fzf_opts.prompt or "Select"):gsub("%s*:%s*$", "")) .. " ",
|
||||||
title_pos = "center",
|
title_pos = "center",
|
||||||
width = width,
|
},
|
||||||
height = height,
|
}, fzf_opts.kind == "codeaction" and {
|
||||||
|
winopts = {
|
||||||
|
layout = "vertical",
|
||||||
|
-- height is number of items minus 15 lines for the preview, with a max of 80% screen height
|
||||||
|
height = math.floor(math.min(vim.o.lines * 0.8 - 16, #items + 2) + 0.5) + 16,
|
||||||
|
width = 0.5,
|
||||||
|
preview = {
|
||||||
|
layout = "vertical",
|
||||||
|
vertical = "down:15,border-top",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} or {
|
||||||
|
winopts = {
|
||||||
|
width = 0.5,
|
||||||
|
-- height is number of items, with a max of 80% screen height
|
||||||
|
height = math.floor(math.min(vim.o.lines * 0.8, #items + 2) + 0.5),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue