From: Yegappan Lakshmanan Date: Fri, 24 Mar 2023 14:36:27 +0000 (-0700) Subject: Display the diag message when using the LspDiagHere command X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=3559588604f1887c6518ef9bbd8a768f8bf06c4f;p=vim-lsp.git Display the diag message when using the LspDiagHere command --- diff --git a/autoload/lsp/diag.vim b/autoload/lsp/diag.vim index 7c251ca..853f3de 100644 --- a/autoload/lsp/diag.vim +++ b/autoload/lsp/diag.vim @@ -258,6 +258,17 @@ def ShowDiagInPopup(diag: dict) popup_create(diag.message->split("\n"), ppopts) enddef +# Display the 'diag' message in a popup or in the status message area +def DisplayDiag(diag: dict) + if opt.lspOptions.showDiagInPopup + # Display the diagnostic message in a popup window. + ShowDiagInPopup(diag) + else + # Display the diagnostic message in the status message area + echo diag.message + endif +enddef + # Show the diagnostic message for the current line export def ShowCurrentDiag(lspserver: dict) var bnr: number = bufnr() @@ -267,13 +278,7 @@ export def ShowCurrentDiag(lspserver: dict) if diag->empty() util.WarnMsg('No diagnostic messages found for current line') else - if opt.lspOptions.showDiagInPopup - # Display the diagnostic message in a popup window. - ShowDiagInPopup(diag) - else - # Display the diagnostic message in the status message area - echo diag.message - endif + DisplayDiag(diag) endif enddef @@ -350,13 +355,18 @@ export def LspDiagsJump(lspserver: dict, which: string): void # Find the entry just before the current line (binary search) var curlnum: number = line('.') var curcol: number = charcol('.') - for diag in (which == 'next' || which == 'here') ? diags : diags->copy()->reverse() + for diag in (which == 'next' || which == 'here') ? + diags : diags->copy()->reverse() var lnum = diag.range.start.line + 1 var col = diag.range.start.character + 1 if (which == 'next' && (lnum > curlnum || lnum == curlnum && col > curcol)) - || (which == 'prev' && (lnum < curlnum || lnum == curlnum && col < curcol)) - || (which == 'here' && (lnum == curlnum && col > curcol)) + || (which == 'prev' && (lnum < curlnum || lnum == curlnum + && col < curcol)) + || (which == 'here' && (lnum == curlnum && col >= curcol)) setcursorcharpos(lnum, col) + if (which == 'here') + DisplayDiag(diag) + endif return endif endfor