mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-05 03:08:13 +00:00
feat(picker): preview window horizontal scrolling (#686)
## Description This is an initial commit for trying to add horizontal scrolling for the picker preview window. Known issue: when scrolling horizontally with scope indent, the indent chars persist in the preview window and don't disappear as they should... Edit: I just realized this happens only when we are previewing a buffer that is already open. Only in that case the indents are being rendered... if we are previewing a file that is not currently open the indents don't get rendered and therefore there is no issue. Maybe this is a bug? Should we prevent rendering of the indent guides in the preview window? ## Related Issue(s) - Fixes #676 ## Screenshots  --------- Co-authored-by: Val Gorokhovsky <valery.gorokhovsky@riverbed.com>
This commit is contained in:
parent
79a6eabd31
commit
bc47e0b1dd
3 changed files with 19 additions and 0 deletions
|
@ -311,6 +311,14 @@ function M.preview_scroll_up(picker)
|
|||
picker.preview.win:scroll(true)
|
||||
end
|
||||
|
||||
function M.preview_scroll_left(picker)
|
||||
picker.preview.win:hscroll(true)
|
||||
end
|
||||
|
||||
function M.preview_scroll_right(picker)
|
||||
picker.preview.win:hscroll()
|
||||
end
|
||||
|
||||
function M.inspect(picker, item)
|
||||
Snacks.debug.inspect(item)
|
||||
end
|
||||
|
|
|
@ -190,6 +190,8 @@ local defaults = {
|
|||
["<c-k>"] = { "list_up", mode = { "i", "n" } },
|
||||
["<c-n>"] = { "list_down", mode = { "i", "n" } },
|
||||
["<c-p>"] = { "list_up", mode = { "i", "n" } },
|
||||
["<c-l>"] = { "preview_scroll_left", mode = { "i", "n" } },
|
||||
["<c-h>"] = { "preview_scroll_right", mode = { "i", "n" } },
|
||||
["<c-b>"] = { "preview_scroll_up", mode = { "i", "n" } },
|
||||
["<c-d>"] = { "list_scroll_down", mode = { "i", "n" } },
|
||||
["<c-f>"] = { "preview_scroll_down", mode = { "i", "n" } },
|
||||
|
@ -234,6 +236,8 @@ local defaults = {
|
|||
["<c-a>"] = "select_all",
|
||||
["<c-f>"] = "preview_scroll_down",
|
||||
["<c-b>"] = "preview_scroll_up",
|
||||
["<c-l>"] = "preview_scroll_right",
|
||||
["<c-h>"] = "preview_scroll_left",
|
||||
["<c-v>"] = "edit_vsplit",
|
||||
["<c-s>"] = "edit_split",
|
||||
["<c-j>"] = "list_down",
|
||||
|
|
|
@ -479,6 +479,13 @@ function M:redraw()
|
|||
end
|
||||
end
|
||||
|
||||
---@param left? boolean
|
||||
function M:hscroll(left)
|
||||
vim.api.nvim_win_call(self.win, function()
|
||||
vim.cmd(("normal! %s"):format(left and "zh" or "zl"))
|
||||
end)
|
||||
end
|
||||
|
||||
---@param up? boolean
|
||||
function M:scroll(up)
|
||||
vim.api.nvim_win_call(self.win, function()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue