diff --git a/autoload/lsp/internal/ui/floatwin.vim b/autoload/lsp/internal/ui/floatwin.vim new file mode 100644 index 000000000..d3516a717 --- /dev/null +++ b/autoload/lsp/internal/ui/floatwin.vim @@ -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 "\" +endfunction + diff --git a/doc/vim-lsp.txt b/doc/vim-lsp.txt index c75bb05a6..e6bc3065b 100644 --- a/doc/vim-lsp.txt +++ b/doc/vim-lsp.txt @@ -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. +(lsp-floatwin-scroll-up) *(lsp-floatwin-scroll-up)* +(lsp-floatwin-scroll-down) *(lsp-floatwin-scroll-down)* + +Scroll all displayed floating windows. ============================================================================== Autocomplete *vim-lsp-autocomplete* diff --git a/plugin/lsp.vim b/plugin/lsp.vim index 0b05f4d33..fb968482f 100644 --- a/plugin/lsp.vim +++ b/plugin/lsp.vim @@ -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 (lsp-status) :echo lsp#get_server_status() nnoremap (lsp-next-reference) :call lsp#internal#document_highlight#jump(+1) nnoremap (lsp-previous-reference) :call lsp#internal#document_highlight#jump(-1) nnoremap (lsp-signature-help) :call lsp#ui#vim#signature_help#get_signature_help_under_cursor() + +nnoremap (lsp-floatwin-scroll-up) lsp#internal#ui#floatwin#scroll(-g:lsp_floatwin_scroll_delta) +nnoremap (lsp-floatwin-scroll-down) lsp#internal#ui#floatwin#scroll(g:lsp_floatwin_scroll_delta) +inoremap (lsp-floatwin-scroll-up) lsp#internal#ui#floatwin#scroll(-g:lsp_floatwin_scroll_delta) +inoremap (lsp-floatwin-scroll-down) lsp#internal#ui#floatwin#scroll(g:lsp_floatwin_scroll_delta) +xnoremap (lsp-floatwin-scroll-up) lsp#internal#ui#floatwin#scroll(-g:lsp_floatwin_scroll_delta) +xnoremap (lsp-floatwin-scroll-down) lsp#internal#ui#floatwin#scroll(g:lsp_floatwin_scroll_delta) +