summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/config.lua1
-rw-r--r--lua/telescope/pickers/layout_strategies.lua18
2 files changed, 14 insertions, 5 deletions
diff --git a/lua/telescope/config.lua b/lua/telescope/config.lua
index a57ec7f..ccce136 100644
--- a/lua/telescope/config.lua
+++ b/lua/telescope/config.lua
@@ -108,6 +108,7 @@ local layout_config_defaults = {
bottom_pane = {
height = 25,
prompt_position = "top",
+ preview_cutoff = 120,
},
}
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