-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scrolling in vim8 popup window #975
Comments
Scrolling in popups generated by |
Unfortunately vim8 doesn't support focusable popup so we cannot scroll by focusing on popup. We need to instead intercept keys and send commands to it. It will be good if we can implement Might be ping here for focusable popup support too while you send a PR for vim-lsp. |
I just sent a PR in vim to allow focusing inside popup. Let us also see how that goes. If that gets accepted we can implement double tap feature for vim8 and you can use all the features of window inside popup same as how you work on any buffer. |
@prabirshrestha Great! Ok, I will have a go at it. Is there any current scenario (in vim8) with multiple popups that I could test against? As far as I can tell, opening a new popup window (with |
You don't need to intercept keys. That's what popup-filters are for. Vim does this automatically for you. Here's a minimal example: function s:popup_filter(winid, key) abort
if a:key ==# "\<c-j>"
call win_execute(a:winid, "normal! \<c-e>")
elseif a:key ==# "\<c-k>"
call win_execute(a:winid, "normal! \<c-y>")
elseif a:key ==# "\<c-g>"
call win_execute(a:winid, "normal! G")
elseif a:key ==# "\<c-t>"
call win_execute(a:winid, "normal! gg")
elseif a:key ==# 'q'
call popup_close(a:winid)
else
return v:false
endif
return v:true
endfunction
call range(100)
\ ->map('string(v:val)')
\ ->popup_create({
\ 'border': [],
\ 'moved': 'any',
\ 'minwidth': 60,
\ 'maxwidth': 60,
\ 'minheight': 10,
\ 'maxheight': 10,
\ 'filter': funcref('s:popup_filter'),
\ 'filtermode': 'n',
\ 'mapping': v:false
\ }) With the above You could make the keys for scrolling customizable, for example: function s:popup_filter(winid, key) abort
if a:key ==# get(g:, 'lsp_popup_scroll_down', "\<c-j>")
call win_execute(a:winid, "normal! \<c-e>")
elseif a:key ==# get(g:, 'lsp_popup_scroll_up', "\<c-k>")
call win_execute(a:winid, "normal! \<c-y>")
else
return v:false
endif
return v:true
endfunction |
Scrolling is now supported by #1058. |
Hello, firstly thank you for your work on this plugin and related ones.
I installed vim-lsp on vim8 a few days ago, and found that scrolling in popup windows was not possible. I understand that a big part of the issue is that vim8's popup window interface is not very complete, which has also been mentioned in #395 and #403. (Please correct me if I am wrong about either of these!)
So I wrote a tiny function which helps to carry out the scrolling https://github.com/yongrenjie/dotfiles/blob/master/.vimrc#L57-L80., which is partly adapted from https://fortime.ws/blog/2020/03/14/20200312-01/ although I added some touches. It seems like it would be easier to integrate this into vim-lsp since you keep track of the popup window ID already. Would you be interested in a PR (might take a couple of days though as I'm not very good at vimscript)? Although I hardcoded it to 3 lines here, the user could conceivably choose how fast to scroll using a setting like
g:vim_lsp_scroll_speed
.hover_example.mov
The text was updated successfully, but these errors were encountered: