summaryrefslogtreecommitdiff
path: root/lua/telescope/pickers.lua
diff options
context:
space:
mode:
authorTJ DeVries <devries.timothyj@gmail.com>2020-08-27 22:55:44 -0400
committerTJ DeVries <devries.timothyj@gmail.com>2020-08-27 22:55:44 -0400
commit4100795d0ca64b2afd073e90435374a16f3ae962 (patch)
tree1965e78b562b113f3df4e561171cc130433cf7d4 /lua/telescope/pickers.lua
parentbb446421c5e97310fc0823c157d94cef624688bb (diff)
slightly better small screen UX
Diffstat (limited to 'lua/telescope/pickers.lua')
-rw-r--r--lua/telescope/pickers.lua18
1 files changed, 15 insertions, 3 deletions
diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua
index 9973c8e..8adde83 100644
--- a/lua/telescope/pickers.lua
+++ b/lua/telescope/pickers.lua
@@ -51,9 +51,12 @@ function Picker._get_window_options(max_columns, max_lines, prompt_title)
enter = true
}
+ -- TODO: Test with 120 width terminal
+
local width_padding = 10
if max_columns < 150 then
- preview.width = 60
+ width_padding = 5
+ preview.width = math.floor(max_columns * 0.4)
elseif max_columns < 200 then
preview.width = 80
else
@@ -64,7 +67,13 @@ function Picker._get_window_options(max_columns, max_lines, prompt_title)
results.width = other_width
prompt.width = other_width
- results.height = 25
+ local base_height
+ if max_lines < 40 then
+ base_height = math.floor(max_lines * 0.5)
+ else
+ base_height = math.floor(max_lines * 0.8)
+ end
+ results.height = base_height
results.minheight = results.height
prompt.height = 1
prompt.minheight = prompt.height
@@ -76,7 +85,8 @@ function Picker._get_window_options(max_columns, max_lines, prompt_title)
prompt.col = width_padding
preview.col = results.col + results.width + 2
- local height_padding = math.floor(0.95 * max_lines)
+ -- TODO: Center this in the page a bit better.
+ local height_padding = math.max(math.floor(0.95 * max_lines), 2)
results.line = max_lines - height_padding
prompt.line = results.line + results.height + 2
preview.line = results.line
@@ -97,6 +107,8 @@ function Picker:find(opts)
local sorter = opts.sorter
local prompt_string = opts.prompt
+ self.original_win_id = a.nvim_get_current_win()
+
-- Create three windows:
-- 1. Prompt window
-- 2. Options window