Add scroll keymapping

This commit is contained in:
hrsh7th
2021-01-25 21:00:12 +09:00
parent 7d5cd2763c
commit bc821a5bcd
3 changed files with 30 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
let s:Window = vital#lsp#import('VS.Vim.Window')
"
" lsp#internal#ui#floatwin#scroll
"
function! lsp#internal#ui#floatwin#scroll(delta) abort
let l:ctx = {}
function! l:ctx.callback() abort closure
for l:winid in s:Window.find({ winid -> s:Window.is_floating(winid) })
let l:info = s:Window.info(l:winid)
call s:Window.scroll(l:winid, l:info.topline + a:delta)
endfor
endfunction
call timer_start(0, { -> l:ctx.callback() })
return "\<Ignore>"
endfunction

View File

@@ -1676,6 +1676,10 @@ Closes an opened preview window
Transfers focus to an opened preview window or back to the previous window if
focus is already on the preview window.
<plug>(lsp-floatwin-scroll-up) *<plug>(lsp-floatwin-scroll-up)*
<plug>(lsp-floatwin-scroll-down) *<plug>(lsp-floatwin-scroll-down)*
Scroll all displayed floating windows.
==============================================================================
Autocomplete *vim-lsp-autocomplete*

View File

@@ -10,6 +10,7 @@ let g:lsp_log_file = get(g:, 'lsp_log_file', '')
let g:lsp_log_verbose = get(g:, 'lsp_log_verbose', 1)
let g:lsp_debug_servers = get(g:, 'lsp_debug_servers', [])
let g:lsp_format_sync_timeout = get(g:, 'lsp_format_sync_timeout', -1)
let g:lsp_floatwin_scroll_delta = get(g:, 'lsp_floatwin_scroll_delta', 4)
let g:lsp_completion_documentation_enabled = get(g:, 'lsp_completion_documentation_enabled', 1)
let g:lsp_completion_documentation_delay = get(g:, 'lsp_completion_documention_delay', 80)
@@ -172,3 +173,11 @@ nnoremap <plug>(lsp-status) :<c-u>echo lsp#get_server_status()<cr>
nnoremap <plug>(lsp-next-reference) :<c-u>call lsp#internal#document_highlight#jump(+1)<cr>
nnoremap <plug>(lsp-previous-reference) :<c-u>call lsp#internal#document_highlight#jump(-1)<cr>
nnoremap <plug>(lsp-signature-help) :<c-u>call lsp#ui#vim#signature_help#get_signature_help_under_cursor()<cr>
nnoremap <expr> <plug>(lsp-floatwin-scroll-up) lsp#internal#ui#floatwin#scroll(-g:lsp_floatwin_scroll_delta)
nnoremap <expr> <plug>(lsp-floatwin-scroll-down) lsp#internal#ui#floatwin#scroll(g:lsp_floatwin_scroll_delta)
inoremap <expr> <plug>(lsp-floatwin-scroll-up) lsp#internal#ui#floatwin#scroll(-g:lsp_floatwin_scroll_delta)
inoremap <expr> <plug>(lsp-floatwin-scroll-down) lsp#internal#ui#floatwin#scroll(g:lsp_floatwin_scroll_delta)
xnoremap <expr> <plug>(lsp-floatwin-scroll-up) lsp#internal#ui#floatwin#scroll(-g:lsp_floatwin_scroll_delta)
xnoremap <expr> <plug>(lsp-floatwin-scroll-down) lsp#internal#ui#floatwin#scroll(g:lsp_floatwin_scroll_delta)