How to change picker layout on window resize? #1475
-
Hi everyone, I am trying to set my picker layout on resize. I don't want to use the presets so I was hoping to pass a function to layout similar to preset? local layout_sm = {
box = "vertical",
backdrop = false,
width = 0.9,
height = 0.9,
border = "none",
{
win = "preview",
title = "{preview:Preview}",
-- width = 0.9,
border = "rounded",
title_pos = "center",
},
{
box = "vertical",
{ win = "list", title = " Results ", title_pos = "center", border = "rounded" },
{ win = "input", height = 1, border = "rounded", title = "{title} {live} {flags}", title_pos = "center" },
},
}
local layout_bg = {
backdrop = false,
width = 0.5,
min_width = 80,
height = 0.8,
min_height = 30,
box = "vertical",
border = "rounded",
title = "{title} {live} {flags}",
title_pos = "center",
{ win = "input", height = 1, border = "bottom" },
{ win = "list", border = "none" },
{ win = "preview", title = "{preview}", height = 0.4, border = "top" },
}
M.picker = {
layout = {
cycle = true,
reverse = true,
--- Use the default layout or vertical if the window is too narrow
--- This didn't work
layout = function()
return vim.o.columns >= 120 and layout_bg or layout_sm
end,
-- This didn't work too
-- layout = vim.o.columns >= 120 and layout_bg or layout_sm,
--- Use the default layout or vertical if the window is too narrow
-- This works but it is not what I want
-- preset = function()
-- return vim.o.columns >= 120 and "default" or "vertical"
-- end,
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
drowning-cat
Mar 1, 2025
Replies: 1 comment 4 replies
-
I believe your layouts should be defined under |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#1448 (reply in thread)