mirror of
https://github.com/prabirshrestha/vim-lsp.git
synced 2025-12-14 20:35:59 +01:00
Add scroll keymapping (#1058)
* Add lsp#scroll function * Update README.md * Add example setting to docs
This commit is contained in:
@@ -36,9 +36,11 @@ function! s:on_lsp_buffer_enabled() abort
|
||||
nmap <buffer> gi <plug>(lsp-implementation)
|
||||
nmap <buffer> gt <plug>(lsp-type-definition)
|
||||
nmap <buffer> <leader>rn <plug>(lsp-rename)
|
||||
nmap <buffer> [g <Plug>(lsp-previous-diagnostic)
|
||||
nmap <buffer> ]g <Plug>(lsp-next-diagnostic)
|
||||
nmap <buffer> [g <plug>(lsp-previous-diagnostic)
|
||||
nmap <buffer> ]g <plug>(lsp-next-diagnostic)
|
||||
nmap <buffer> K <plug>(lsp-hover)
|
||||
inoremap <buffer> <expr><c-f> lsp#scroll(+4)
|
||||
inoremap <buffer> <expr><c-d> lsp#scroll(-4)
|
||||
|
||||
let g:lsp_format_sync_timeout = 1000
|
||||
autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync')
|
||||
|
||||
@@ -1148,6 +1148,23 @@ function! lsp#get_progress() abort
|
||||
return lsp#internal#work_done_progress#get_progress()
|
||||
endfunction
|
||||
|
||||
"
|
||||
" Scroll vim-lsp related windows.
|
||||
"
|
||||
" NOTE: This method can be used to <expr> mapping.
|
||||
"
|
||||
function! lsp#scroll(count) abort
|
||||
let l:ctx = {}
|
||||
function! l:ctx.callback(count) abort
|
||||
let l:Window = vital#lsp#import('VS.Vim.Window')
|
||||
for l:winid in l:Window.find({ winid -> l:Window.is_floating(winid) })
|
||||
call l:Window.scroll(l:winid, l:Window.info(l:winid).topline + a:count)
|
||||
endfor
|
||||
endfunction
|
||||
call timer_start(0, { -> l:ctx.callback(a:count) })
|
||||
return "\<Ignore>"
|
||||
endfunction
|
||||
|
||||
function! s:merge_dict(dict_old, dict_new) abort
|
||||
for l:key in keys(a:dict_new)
|
||||
if has_key(a:dict_old, l:key) && type(a:dict_old[l:key]) == v:t_dict && type(a:dict_new[l:key]) == v:t_dict
|
||||
|
||||
@@ -1309,6 +1309,14 @@ lsp#get_progress() *lsp#get_progress()*
|
||||
Type: |Number|
|
||||
0 - 100 or not exist
|
||||
|
||||
lsp#scroll(count) *lsp#scroll()*
|
||||
|
||||
Scroll current displayed floating/popup window with specified count.
|
||||
|
||||
Example: >
|
||||
inoremap <buffer> <expr><c-f> lsp#scroll(+4)
|
||||
inoremap <buffer> <expr><c-d> lsp#scroll(-4)
|
||||
|
||||
==============================================================================
|
||||
Commands *vim-lsp-commands*
|
||||
|
||||
|
||||
Reference in New Issue
Block a user