]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Add : possibility to get hover result in preview window
authorIndelog <maxime@indelog.fr>
Mon, 8 Nov 2021 13:14:08 +0000 (14:14 +0100)
committerIndelog <maxime@indelog.fr>
Thu, 11 Nov 2021 14:25:42 +0000 (15:25 +0100)
autoload/handlers.vim
doc/lsp.txt
plugin/lsp.vim

index 6db5dbd48e28ed73cd23e10ad54e58167853b2d5..665eb69884f77fb02b360709275ae1dca2674d6a 100644 (file)
@@ -302,7 +302,21 @@ def s:processHoverReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>):
     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
index 674bf2bfc2cbf439f60f4349e4772a3fbd7c2de0..dd9da9f9402e4ca8420377e021834085431bb8f0 100644 (file)
@@ -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.
index 572e201cb922d2f7f5c26e22ab6de2d092fff530..5bfa08476d801b9647fcec5ed35a01a155ab6e0b 100644 (file)
@@ -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 *