From fa329100171c9ef3a1e0db0d321c8b246a401f53 Mon Sep 17 00:00:00 2001 From: Indelog Date: Tue, 16 Nov 2021 11:19:27 +0100 Subject: [PATCH] Set option for hover in preview with new lspOptions --- autoload/handlers.vim | 6 +++--- autoload/lspoptions.vim | 4 +++- doc/lsp.txt | 3 ++- plugin/lsp.vim | 15 --------------- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/autoload/handlers.vim b/autoload/handlers.vim index 7a40de4..7a9126a 100644 --- a/autoload/handlers.vim +++ b/autoload/handlers.vim @@ -330,7 +330,7 @@ def s:processHoverReply(lspserver: dict, req: dict, reply: dict): ErrMsg('Error: Unsupported hover contents (' .. reply.result.contents .. ')') return endif - if g:LSP_Hover_In_Preview + if lspOptions.hoverInPreview silent! pedit HoverReply wincmd P setlocal buftype=nofile @@ -338,9 +338,9 @@ def s:processHoverReply(lspserver: dict, req: dict, reply: dict): if !reply.result.contents.kind->empty() exe 'setlocal ft=' .. reply.result.contents.kind endif - exe 'normal ggdG' + deletebufline(bufnr(), 1, getbufinfo(bufnr())[0].linecount) append(0, hoverText) - exe 'normal gg' + cursor(1, 1) wincmd p else hoverText->popup_atcursor({moved: 'word'}) diff --git a/autoload/lspoptions.vim b/autoload/lspoptions.vim index ab7daa0..6edd8b1 100644 --- a/autoload/lspoptions.vim +++ b/autoload/lspoptions.vim @@ -14,5 +14,7 @@ export var lspOptions: dict = { # instead of showing it in a popup echoSignature: false, # Automatically highlight diagnostics messages from LSP server - autoHighlightDiags: true + autoHighlightDiags: true, + # Show the symbol documentation in the preview window instead of in a popup + hoverInPreview: false, } diff --git a/doc/lsp.txt b/doc/lsp.txt index 9f80f65..1422d4e 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -371,7 +371,8 @@ diagnostic messages, you can add the following line to your .vimrc file: in a popup window. If you want to show the symbol documentation in the preview window instead of in a popup set > - let g:LSP_Hover_In_preview variable = v:true + + call lsp#setOptions({'hoverInPreview': v:true}) < Default is false diff --git a/plugin/lsp.vim b/plugin/lsp.vim index 0f324c4..8683e63 100644 --- a/plugin/lsp.vim +++ b/plugin/lsp.vim @@ -5,21 +5,6 @@ if v:version < 802 || !has('patch-8.2.2342') finish endif - -" Perform completion in insert mode automatically. Otherwise use -" omni-complete. -if !exists('g:LSP_24x7_Complete') - let g:LSP_24x7_Complete = v:true -endif - -if !exists('g:LSP_Show_Signature') - let g:LSP_Show_Signature = v:true -endif - -if !exists('g:LSP_Hover_In_Preview') - let g:LSP_Hover_In_Preview = v:false -endif - augroup LSPAutoCmds au! autocmd BufNewFile,BufReadPost * -- 2.48.1