mirror of
https://github.com/pnx/dotfiles
synced 2026-06-16 03:14:55 +02:00
nvim: hacking with and height of telescope windows.
This commit is contained in:
parent
35438bea75
commit
a7538c250d
2 changed files with 54 additions and 5 deletions
|
|
@ -37,14 +37,13 @@ return {
|
||||||
cycle_layout_list = { "horizontal", "vertical" },
|
cycle_layout_list = { "horizontal", "vertical" },
|
||||||
layout_config = {
|
layout_config = {
|
||||||
vertical = {
|
vertical = {
|
||||||
width = 0.5,
|
width = utils.width(0.5, { min = 80, max = 100, padding = 10}),
|
||||||
height = 0.6,
|
height = utils.height(0.6, { min = 15, max = 50, padding = 2}),
|
||||||
},
|
},
|
||||||
horizontal = {
|
horizontal = {
|
||||||
width = 0.95,
|
width = utils.width(0.95, { min = 80, max = 180, padding = 10 }),
|
||||||
height = 0.95,
|
height = utils.height(0.95, { min = 15, max = 34, padding = 2 }),
|
||||||
preview_width = 0.5,
|
preview_width = 0.5,
|
||||||
preview_cutoff = 200,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -154,4 +154,54 @@ function M.buffer_view(opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param value integer
|
||||||
|
---@param screen integer
|
||||||
|
---@param min integer
|
||||||
|
---@param max integer
|
||||||
|
---@param padding integer
|
||||||
|
---@return integer
|
||||||
|
local function calculate_size(value, screen, min, max, padding)
|
||||||
|
if (min > 0) then
|
||||||
|
if (screen < (min + padding)) then
|
||||||
|
return math.max(screen - padding, 0)
|
||||||
|
end
|
||||||
|
value = math.max(value, min)
|
||||||
|
end
|
||||||
|
if (max > 0) then value = math.min(value, max) end
|
||||||
|
return value
|
||||||
|
end
|
||||||
|
|
||||||
|
---@class size_opts
|
||||||
|
---@field max integer?
|
||||||
|
---@field min integer?
|
||||||
|
---@field padding integer?
|
||||||
|
|
||||||
|
---@param percentage number
|
||||||
|
---@param opts size_opts
|
||||||
|
---@return function
|
||||||
|
function M.width(percentage, opts)
|
||||||
|
return function(_, screen_width)
|
||||||
|
local padding = opts.padding or 0
|
||||||
|
local max = opts.max or -1
|
||||||
|
local min = opts.min or -1
|
||||||
|
local width = math.floor(percentage * screen_width)
|
||||||
|
|
||||||
|
return calculate_size(width, screen_width, min, max, padding)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param percentage number
|
||||||
|
---@param opts size_opts
|
||||||
|
---@return function
|
||||||
|
function M.height(percentage, opts)
|
||||||
|
return function(_, _, screen_height)
|
||||||
|
local padding = opts.padding or 0
|
||||||
|
local max = opts.max or -1
|
||||||
|
local min = opts.min or -1
|
||||||
|
local height = math.floor(percentage * screen_height)
|
||||||
|
|
||||||
|
return calculate_size(height, screen_height, min, max, padding)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue