feat: add preview width option for bottom_pane layout (#1505)
* feat(layout_strategies): started adding preview width for bottom pane * fix(bottom_pane preview_width): fixed some values and added defualt * fix(config): better default for preview cutoff * fix(layout): removed unnecessary variable value
This commit is contained in:
@@ -108,6 +108,7 @@ local layout_config_defaults = {
|
|||||||
bottom_pane = {
|
bottom_pane = {
|
||||||
height = 25,
|
height = 25,
|
||||||
prompt_position = "top",
|
prompt_position = "top",
|
||||||
|
preview_cutoff = 120,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -778,6 +778,7 @@ end)
|
|||||||
layout_strategies.bottom_pane = make_documented_layout(
|
layout_strategies.bottom_pane = make_documented_layout(
|
||||||
"bottom_pane",
|
"bottom_pane",
|
||||||
vim.tbl_extend("error", shared_options, {
|
vim.tbl_extend("error", shared_options, {
|
||||||
|
preview_width = { "Change the width of Telescope's preview window", "See |resolver.resolve_width()|" },
|
||||||
prompt_position = { "Where to place prompt window.", "Available Values: 'bottom', 'top'" },
|
prompt_position = { "Where to place prompt window.", "Available Values: 'bottom', 'top'" },
|
||||||
}),
|
}),
|
||||||
function(self, max_columns, max_lines, layout_config)
|
function(self, max_columns, max_lines, layout_config)
|
||||||
@@ -806,13 +807,20 @@ layout_strategies.bottom_pane = make_documented_layout(
|
|||||||
results.height = height - prompt.height - (2 * bs)
|
results.height = height - prompt.height - (2 * bs)
|
||||||
preview.height = results.height - bs
|
preview.height = results.height - bs
|
||||||
|
|
||||||
|
local width
|
||||||
|
|
||||||
-- Width
|
-- Width
|
||||||
prompt.width = max_columns - 2 * bs
|
prompt.width = max_columns - 2 * bs
|
||||||
-- TODO(l-kershaw): add a preview_cutoff option
|
local w_space
|
||||||
if self.previewer then
|
if self.previewer and max_columns >= layout_config.preview_cutoff then
|
||||||
-- TODO(l-kershaw): make configurable
|
-- Cap over/undersized width (with preview)
|
||||||
results.width = math.floor(max_columns / 2) - 2 * bs
|
width, w_space = calc_size_and_spacing(max_columns, max_columns, bs, 2, 4, 0)
|
||||||
preview.width = max_columns - results.width - 4 * bs
|
|
||||||
|
preview.width = resolve.resolve_width(if_nil(layout_config.preview_width, function(_, _)
|
||||||
|
-- By default, previewer takes 1/2 of the layout
|
||||||
|
return math.floor(width / 2)
|
||||||
|
end))(self, width, max_lines)
|
||||||
|
results.width = width - preview.width - w_space
|
||||||
else
|
else
|
||||||
results.width = prompt.width
|
results.width = prompt.width
|
||||||
preview.width = 0
|
preview.width = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user