diff options
| author | Luke Kershaw <35707277+l-kershaw@users.noreply.github.com> | 2021-12-10 10:48:14 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-10 11:48:14 +0100 |
| commit | 80cdb00b221f69348afc4fb4b701f51eb8dd3120 (patch) | |
| tree | 8b722042e2785f23c42ec6fd36abbd3f7ad8c619 /lua/telescope/pickers/layout_strategies.lua | |
| parent | 991d0127f0abc6db9d8efd3a49e53a6867de5559 (diff) | |
feat: `center` layout `mirror` option (#1577)
Diffstat (limited to 'lua/telescope/pickers/layout_strategies.lua')
| -rw-r--r-- | lua/telescope/pickers/layout_strategies.lua | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/lua/telescope/pickers/layout_strategies.lua b/lua/telescope/pickers/layout_strategies.lua index 12090b7..9b1b2cd 100644 --- a/lua/telescope/pickers/layout_strategies.lua +++ b/lua/telescope/pickers/layout_strategies.lua @@ -186,6 +186,7 @@ local shared_options = { height = { "How tall to make Telescope's entire layout", "See |resolver.resolve_height()|" }, mirror = "Flip the location of the results/prompt and preview windows", scroll_speed = "The number of lines to scroll through the previewer", + prompt_position = { "Where to place prompt window.", "Available Values: 'bottom', 'top'" }, } -- Used for generating vim help documentation. @@ -287,7 +288,6 @@ layout_strategies.horizontal = make_documented_layout( vim.tbl_extend("error", shared_options, { preview_width = { "Change the width of Telescope's preview window", "See |resolver.resolve_width()|" }, preview_cutoff = "When columns are less than this value, the preview will be disabled", - prompt_position = { "Where to place prompt window.", "Available Values: 'bottom', 'top'" }, }), function(self, max_columns, max_lines, layout_config) local initial_options = p_window.get_initial_window_options(self) @@ -412,7 +412,6 @@ layout_strategies.center = make_documented_layout( "center", vim.tbl_extend("error", shared_options, { preview_cutoff = "When lines are less than this value, the preview will be disabled", - prompt_position = { "Where to place prompt window.", "Available Values: 'bottom', 'top'" }, }), function(self, max_columns, max_lines, layout_config) local initial_options = p_window.get_initial_window_options(self) @@ -448,7 +447,7 @@ layout_strategies.center = make_documented_layout( prompt.height = 1 results.height = height - prompt.height - h_space - local topline = (max_lines / 2) - ((results.height + (2 * bs)) / 2) + 1 + local topline = math.floor((max_lines / 2) - ((results.height + (2 * bs)) / 2) + 1) -- Align the prompt and results so halfway up the screen is -- in the middle of this combined block if layout_config.prompt_position == "top" then @@ -464,11 +463,15 @@ layout_strategies.center = make_documented_layout( error(string.format("Unknown prompt_position: %s\n%s", self.window.prompt_position, vim.inspect(layout_config))) end - preview.line = 2 - - if self.previewer and max_lines >= layout_config.preview_cutoff then - preview.height = math.floor(topline - (3 + bs)) + if not layout_config.mirror then + preview.line = 1 + bs + preview.height = topline - (2 * bs + 2) else + preview.line = topline + (results.height + (2 * bs + 2)) + preview.height = max_lines - preview.line + (1 - bs) + end + + if not (self.previewer and max_lines >= layout_config.preview_cutoff) then preview.height = 0 end @@ -617,7 +620,6 @@ layout_strategies.vertical = make_documented_layout( vim.tbl_extend("error", shared_options, { preview_cutoff = "When lines are less than this value, the preview will be disabled", preview_height = { "Change the height of Telescope's preview window", "See |resolver.resolve_height()|" }, - prompt_position = { "Where to place prompt window.", "Available Values: 'bottom', 'top'" }, }), function(self, max_columns, max_lines, layout_config) local initial_options = p_window.get_initial_window_options(self) @@ -792,7 +794,6 @@ layout_strategies.bottom_pane = make_documented_layout( vim.tbl_extend("error", shared_options, { preview_width = { "Change the width of Telescope's preview window", "See |resolver.resolve_width()|" }, preview_cutoff = "When columns are less than this value, the preview will be disabled", - prompt_position = { "Where to place prompt window.", "Available Values: 'bottom', 'top'" }, }), function(self, max_columns, max_lines, layout_config) local initial_options = p_window.get_initial_window_options(self) |
