Merge pull request #143 from nvim-lua/dropdown-fixes
fix: Results height configurable. Properly collapse on border = false
This commit is contained in:
@@ -41,6 +41,9 @@ function config.set_defaults(defaults)
|
|||||||
set("prompt_position", "bottom")
|
set("prompt_position", "bottom")
|
||||||
set("preview_cutoff", 120)
|
set("preview_cutoff", 120)
|
||||||
|
|
||||||
|
set("results_height", 1)
|
||||||
|
set("results_width", 0.8)
|
||||||
|
|
||||||
set("border", {})
|
set("border", {})
|
||||||
set("borderchars", { '─', '│', '─', '│', '╭', '╮', '╯', '╰'})
|
set("borderchars", { '─', '│', '─', '│', '╭', '╮', '╯', '╰'})
|
||||||
|
|
||||||
|
|||||||
@@ -87,10 +87,13 @@ function Picker:new(opts)
|
|||||||
-- TODO: If it's a list, of length 2, then it's a range of min to max?
|
-- TODO: If it's a list, of length 2, then it's a range of min to max?
|
||||||
height = get_default(opts.height, 0.8),
|
height = get_default(opts.height, 0.8),
|
||||||
width = get_default(opts.width, config.values.width),
|
width = get_default(opts.width, config.values.width),
|
||||||
get_preview_width = get_default(opts.preview_width, config.values.get_preview_width),
|
|
||||||
results_width = get_default(opts.results_width, 0.8),
|
|
||||||
winblend = get_default(opts.winblend, config.values.winblend),
|
|
||||||
|
|
||||||
|
get_preview_width = get_default(opts.preview_width, config.values.get_preview_width),
|
||||||
|
|
||||||
|
results_width = get_default(opts.results_width, 0.8),
|
||||||
|
results_height = get_default(opts.results_height, 1),
|
||||||
|
|
||||||
|
winblend = get_default(opts.winblend, config.values.winblend),
|
||||||
prompt_position = get_default(opts.prompt_position, config.values.prompt_position),
|
prompt_position = get_default(opts.prompt_position, config.values.prompt_position),
|
||||||
|
|
||||||
-- Border config
|
-- Border config
|
||||||
|
|||||||
@@ -123,7 +123,6 @@ end
|
|||||||
+--------------+
|
+--------------+
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
-- Check if there are any borders. Right now it's a little raw as
|
-- Check if there are any borders. Right now it's a little raw as
|
||||||
@@ -138,9 +137,11 @@ layout_strategies.center = function(self, columns, lines, prompt_title)
|
|||||||
local results = initial_options.results
|
local results = initial_options.results
|
||||||
local prompt = initial_options.prompt
|
local prompt = initial_options.prompt
|
||||||
|
|
||||||
local max_results = 15
|
-- This sets the height/width for the whole layout
|
||||||
local width = resolve.resolve_width(self.window.width)(self, columns)
|
local height = resolve.resolve_height(self.window.results_height)(self, lines)
|
||||||
|
local width = resolve.resolve_width(self.window.results_width)(self, columns)
|
||||||
|
|
||||||
|
local max_results = (height > lines and lines or height)
|
||||||
local max_width = (width > columns and columns or width)
|
local max_width = (width > columns and columns or width)
|
||||||
|
|
||||||
prompt.height = 1
|
prompt.height = 1
|
||||||
@@ -157,7 +158,7 @@ layout_strategies.center = function(self, columns, lines, prompt_title)
|
|||||||
end
|
end
|
||||||
|
|
||||||
prompt.line = (lines / 2) - ((max_results + (bs * 2)) / 2)
|
prompt.line = (lines / 2) - ((max_results + (bs * 2)) / 2)
|
||||||
results.line = prompt.line + 2
|
results.line = prompt.line + 1 + (bs)
|
||||||
|
|
||||||
preview.line = 1
|
preview.line = 1
|
||||||
preview.height = math.floor(prompt.line - (2 + bs))
|
preview.height = math.floor(prompt.line - (2 + bs))
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ function themes.get_dropdown(opts)
|
|||||||
layout_strategy = "center",
|
layout_strategy = "center",
|
||||||
results_title = false,
|
results_title = false,
|
||||||
preview_title = "Preview",
|
preview_title = "Preview",
|
||||||
width = 70,
|
results_width = 70,
|
||||||
|
results_height = 15,
|
||||||
borderchars = {
|
borderchars = {
|
||||||
{ '─', '│', '─', '│', '╭', '╮', '╯', '╰'},
|
{ '─', '│', '─', '│', '╭', '╮', '╯', '╰'},
|
||||||
prompt = {"─", "│", " ", "│", "╭", "╮", "│", "│"},
|
prompt = {"─", "│", " ", "│", "╭", "╮", "│", "│"},
|
||||||
|
|||||||
Reference in New Issue
Block a user