Skip to content

Commit

Permalink
Add scroll keymapping
Browse files Browse the repository at this point in the history
  • Loading branch information
hrsh7th committed Jan 25, 2021
1 parent 7d5cd27 commit 55b4951
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
18 changes: 18 additions & 0 deletions autoload/lsp/internal/ui/floatwin.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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
let l:Window = vital#vital#import('VS.Vim.Window')
for l:winid in s:Window.find({ winid -> l:Window.is_floating(winid) })
let l:info = s:Window.info(l:winid)
call l:Window.scroll(l:winid, l:info.topline + a:delta)
endfor
endfunction
call timer_start(0, { -> l:ctx.callback() })
return "\<Ignore>"
endfunction

4 changes: 4 additions & 0 deletions doc/vim-lsp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
9 changes: 9 additions & 0 deletions plugin/lsp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

0 comments on commit 55b4951

Please sign in to comment.