autoload/handlers.vim | 16 +++++++++++++++- doc/lsp.txt | 4 +++- plugin/lsp.vim | 4 ++++ diff --git a/autoload/handlers.vim b/autoload/handlers.vim index 6db5dbd48e28ed73cd23e10ad54e58167853b2d5..665eb69884f77fb02b360709275ae1dca2674d6a 100644 --- a/autoload/handlers.vim +++ b/autoload/handlers.vim @@ -302,7 +302,21 @@ else 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 674bf2bfc2cbf439f60f4349e4772a3fbd7c2de0..dd9da9f9402e4ca8420377e021834085431bb8f0 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -333,7 +333,9 @@ wide symbol search. *: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 572e201cb922d2f7f5c26e22ab6de2d092fff530..5bfa08476d801b9647fcec5ed35a01a155ab6e0b 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 *