From 764297e6b469e9930091cbd3d7e338f2d1cd6f45 Mon Sep 17 00:00:00 2001 From: Indelog Date: Mon, 8 Nov 2021 14:14:08 +0100 Subject: [PATCH] Add : possibility to get hover result in preview window --- autoload/handlers.vim | 16 +++++++++++++++- doc/lsp.txt | 4 +++- plugin/lsp.vim | 4 ++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/autoload/handlers.vim b/autoload/handlers.vim index 6db5dbd..665eb69 100644 --- a/autoload/handlers.vim +++ b/autoload/handlers.vim @@ -302,7 +302,21 @@ def s:processHoverReply(lspserver: dict, req: dict, reply: dict): ErrMsg('Error: Unsupported hover contents (' .. reply.result.contents .. ')') return endif - hoverText->popup_atcursor({moved: 'word'}) + if g:LSP_Hover_Reply_In_Preview + silent! pedit HoverReply + wincmd P + setlocal buftype=nofile + setlocal bufhidden=delete + if !reply.result.contents.kind->empty() + exe 'setlocal ft=' .. reply.result.contents.kind + endif + exe 'normal ggdG' + append(0, hoverText) + exe 'normal gg' + wincmd p + else + hoverText->popup_atcursor({moved: 'word'}) + endif enddef # process the 'textDocument/references' reply from the LSP server diff --git a/doc/lsp.txt b/doc/lsp.txt index 674bf2b..dd9da9f 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -333,7 +333,9 @@ accepts a list of LSP servers with the above information. *:LspHover* :LspHover Show the documentation for the symbol under the cursor - in a popup window. + in a popup window. If you prefer show documentation in + a preview window rather a popup set + g:LSP_Hover_Reply_In_Preview = v:true . *:LspSelectionRange* :LspSelectionRange Visually select the current symbol range. diff --git a/plugin/lsp.vim b/plugin/lsp.vim index 572e201..5bfa084 100644 --- a/plugin/lsp.vim +++ b/plugin/lsp.vim @@ -15,6 +15,10 @@ if !exists('g:LSP_Show_Signature') let g:LSP_Show_Signature = v:true endif +if !exists('g:LSP_Hover_Reply_In_Preview') + let g:LSP_Hover_Reply_In_Preview = v:false +endif + augroup LSPAutoCmds au! autocmd BufNewFile,BufReadPost * -- 2.48.1