add netrw preview scrolling
This commit is contained in:
parent
44385e1b3d
commit
c48c9451fc
4 changed files with 33 additions and 0 deletions
|
|
@ -626,6 +626,18 @@ local function schedule_leave_cleanup(state)
|
|||
end))
|
||||
end
|
||||
|
||||
local function scroll_preview(direction, count)
|
||||
local preview = find_preview_window(vim.api.nvim_get_current_tabpage())
|
||||
if not preview then
|
||||
return
|
||||
end
|
||||
|
||||
local key = vim.keycode(direction > 0 and '<C-e>' or '<C-y>')
|
||||
vim.api.nvim_win_call(preview, function()
|
||||
vim.cmd.normal({ args = { tostring(count) .. key }, bang = true })
|
||||
end)
|
||||
end
|
||||
|
||||
function M.setup(buf)
|
||||
if vim.fn.has('nvim-0.12') == 0 or not is_valid_buffer(buf) then
|
||||
return false
|
||||
|
|
@ -653,6 +665,24 @@ function M.setup(buf)
|
|||
silent = true,
|
||||
})
|
||||
|
||||
vim.keymap.set('n', '<M-j>', function()
|
||||
scroll_preview(1, vim.v.count1)
|
||||
end, {
|
||||
buffer = buf,
|
||||
desc = 'Netrw: Scroll preview down',
|
||||
nowait = true,
|
||||
silent = true,
|
||||
})
|
||||
|
||||
vim.keymap.set('n', '<M-k>', function()
|
||||
scroll_preview(-1, vim.v.count1)
|
||||
end, {
|
||||
buffer = buf,
|
||||
desc = 'Netrw: Scroll preview up',
|
||||
nowait = true,
|
||||
silent = true,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('CursorMoved', {
|
||||
group = preview_group,
|
||||
buffer = buf,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue