add new preview window id api (#1323)

* add new preview window id api
resolves #1281

* add alias for getpreviewwinid()

* add documentation
This commit is contained in:
fungus
2022-06-18 05:32:24 +00:00
committed by GitHub
parent bf2d083ace
commit 74e458bc9c
3 changed files with 20 additions and 3 deletions

View File

@@ -1216,6 +1216,10 @@ function! lsp#get_progress() abort
return lsp#internal#work_done_progress#get_progress()
endfunction
function! lsp#document_hover_preview_winid() abort
return lsp#internal#document_hover#under_cursor#getpreviewwinid()
endfunction
"
" Scroll vim-lsp related windows.
"

View File

@@ -74,6 +74,13 @@ function! lsp#internal#document_hover#under_cursor#do(options) abort
\ )
endfunction
function! lsp#internal#document_hover#under_cursor#getpreviewwinid() abort
if exists('s:doc_win')
return s:doc_win.get_winid()
endif
return v:null
endfunction
function! s:show_hover(ui, server_name, request, response) abort
if !has_key(a:response, 'result') || empty(a:response['result']) ||
\ empty(a:response['result']['contents'])

View File

@@ -92,6 +92,7 @@ CONTENTS *vim-lsp-contents*
lsp#get_buffer_diagnostics_counts() |lsp#get_buffer_diagnostics_counts()|
lsp#get_buffer_first_error_line() |lsp#get_buffer_first_error_line()|
lsp#get_progress() |lsp#get_progress()|
lsp#document_hover_preview_winid() |lsp#document_hover_preview_winid()|
Commands |vim-lsp-commands|
LspAddTreeCallHierarchyIncoming |:LspAddTreeCallHierarchyIncoming|
LspCallHierarchyIncoming |:LspCallHierarchyIncoming|
@@ -324,7 +325,7 @@ g:lsp_preview_float *g:lsp_preview_float*
<
After opening an autocmd User event lsp_float_opened is issued, as well as
and lsp_float_closed upon closing. This can be used to alter the preview
window (using lsp#ui#vim#output#getpreviewwinid() to get the window id),
window (using |lsp#document_hover_preview_winid()| to get the window id),
setup custom bindings while a preview is open, or change the highlighting
of the window.
@@ -342,12 +343,12 @@ g:lsp_preview_float *g:lsp_preview_float*
autocmd!
if !has('nvim')
autocmd User lsp_float_opened
\ call setwinvar(lsp#ui#vim#output#getpreviewwinid(),
\ call setwinvar(lsp#document_hover_preview_winid(),
\ '&wincolor', 'PopupWindow')
else
autocmd User lsp_float_opened
\ call nvim_win_set_option(
\ lsp#ui#vim#output#getpreviewwinid(),
\ lsp#document_hover_preview_winid(),
\ 'winhighlight', 'Normal:PopupWindow')
endif
augroup end
@@ -1451,6 +1452,11 @@ lsp#get_progress() *lsp#get_progress()*
Type: |Number|
0 - 100 or not exist
lsp#document_hover_preview_winid() *lsp#document_hover_preview_winid()*
Returns |windowid| of the current hover preview window or |v:null| if it does not
exist.
lsp#scroll(count) *lsp#scroll()*
Scroll current displayed floating/popup window with specified count.