[mini.pick] side-by-side preview #2293
Replies: 3 comments
-
|
Thanks for sharing! The code itself doesn't look that big or complex as is, which is inspiring. And it can be made even more concise (as far as I can see from the first glance). The only thing that caught my when looking at code was that I'd suggest to use |
Beta Was this translation helpful? Give feedback.
-
Thanks for the feedback! This part is from a general config, where it's used for mappings like <M-*>, <C-*>, and these need nvim_feedkeys() to work, but for this snippet nvim_input() is probably enough. |
Beta Was this translation helpful? Give feedback.
-
|
This is really awesome! Here is a tweak to local function compute_layout(window_config, preview_config)
local preview_ratio = 0.618
local padding = 2 -- I removed compute_border_size as I just use the default mini.pick provides ("rounded")
if window_config.width > 75 then -- horizontal preview when window is 75 columns or less
local preview_width = math.floor(preview_ratio * win_config.width)
local picker_width = win_config.width - preview_width - padding
win_config.width = picker_width
preview_config.width = preview_width
preview_config.col = win_config.col + picker_width + padding
else
local preview_height = math.floor(preview_ratio * win_config.height)
local picker_height = win_config.height - preview_height
preview_config.height = preview_height
win_config.height = picker_height
preview_config.row = win_config.row - picker_height - padding
end
end |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Since using
mini.pickI've missed having the preview pane visible next to the picker - it shows more context and helps me to narrow down the search faster (or maybe I'm just too used to it 😅). This is an attempt at implementing this feature.Features:
horizontal,vertical(defaulting tovertical)<S-Up>/<S-Down>)<Tab>)Preview content is wrapped by default, eliminating the need to scroll preview left or right.
Code
Vertical layout:
Horizontal layout:
setup
Beta Was this translation helpful? Give feedback.
All reactions