summaryrefslogtreecommitdiff
path: root/lua/telescope/pickers
diff options
context:
space:
mode:
authormax397574 <81827001+max397574@users.noreply.github.com>2021-11-28 18:32:50 +0100
committerGitHub <noreply@github.com>2021-11-28 17:32:50 +0000
commit7cfddbfd93a1fbd4bc7158ec66cbc5d43cd93567 (patch)
tree93215cb293d52f128684eab2892a4369f9e36b2c /lua/telescope/pickers
parented4adba6d0083a14cabf5837f2511b2617a45593 (diff)
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
Diffstat (limited to 'lua/telescope/pickers')
-rw-r--r--lua/telescope/pickers/layout_strategies.lua18
1 files changed, 13 insertions, 5 deletions
diff --git a/lua/telescope/pickers/layout_strategies.lua b/lua/telescope/pickers/layout_strategies.lua
index 271fc72..706c3e7 100644
--- a/lua/telescope/pickers/layout_strategies.lua
+++ b/lua/telescope/pickers/layout_strategies.lua
@@ -778,6 +778,7 @@ end)
layout_strategies.bottom_pane = make_documented_layout(
"bottom_pane",
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'" },
}),
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)
preview.height = results.height - bs
+ local width
+
-- Width
prompt.width = max_columns - 2 * bs
- -- TODO(l-kershaw): add a preview_cutoff option
- if self.previewer then
- -- TODO(l-kershaw): make configurable
- results.width = math.floor(max_columns / 2) - 2 * bs
- preview.width = max_columns - results.width - 4 * bs
+ local w_space
+ if self.previewer and max_columns >= layout_config.preview_cutoff then
+ -- Cap over/undersized width (with preview)
+ width, w_space = calc_size_and_spacing(max_columns, max_columns, bs, 2, 4, 0)
+
+ 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
results.width = prompt.width
preview.width = 0