autoload/lsp/diag.vim | 16 ++++++++++++++-- autoload/lsp/lsp.vim | 18 ------------------ diff --git a/autoload/lsp/diag.vim b/autoload/lsp/diag.vim index 7eba712dfbedd87710a4531476074c198dd5d8c1..880e08c8f4a49fa33a29e1e308a6b6f667fbc2c2 100644 --- a/autoload/lsp/diag.vim +++ b/autoload/lsp/diag.vim @@ -125,6 +125,16 @@ if opt.lspOptions.showDiagInBalloon :set ballooneval balloonevalterm setbufvar(bnr, '&balloonexpr', 'g:LspDiagExpr()') endif + + var acmds: list> = [] + # Show diagnostics on the status line + if opt.lspOptions.showDiagOnStatusLine + acmds->add({bufnr: bnr, + event: 'CursorMoved', + group: 'LSPBufferAutocmds', + cmd: 'ShowCurrentDiagInStatusLine()'}) + endif + autocmd_add(acmds) enddef # Function to sort the diagnostics in ascending order based on the line and @@ -641,7 +651,7 @@ endif enddef # Show the diagnostic message for the current line without linebreak -export def ShowCurrentDiagInStatusLine() +def ShowCurrentDiagInStatusLine() var bnr: number = bufnr() var lnum: number = line('.') var col: number = charcol('.') @@ -653,9 +663,11 @@ var code = '' if diag->has_key('code') code = $'[{diag.code}] ' endif - var msgNoLineBreak = code .. substitute(substitute(diag.message, "\n", ' ', ''), "\\n", ' ', '') + var msgNoLineBreak = code .. + diag.message->substitute("\n", ' ', '')->substitute("\\n", ' ', '') :echo msgNoLineBreak[ : max_width] else + # clear the previous message :echo '' endif enddef diff --git a/autoload/lsp/lsp.vim b/autoload/lsp/lsp.vim index 7cf25ac2b5d2172d21fed769c24a6374afae8ed8..77544ff1fabd588a7a9c0cccd0665a5142947104 100644 --- a/autoload/lsp/lsp.vim +++ b/autoload/lsp/lsp.vim @@ -387,14 +387,6 @@ group: 'LSPBufferAutocmds', cmd: $'call LspDocHighlightClear({bnr}) | call LspDocHighlight({bnr}, "silent")'}) endif - # Show diagnostics on the status line - if opt.lspOptions.showDiagOnStatusLine - acmds->add({bufnr: bnr, - event: 'CursorMoved', - group: 'LSPBufferAutocmds', - cmd: 'LspShowCurrentDiagInStatusLine()'}) - endif - autocmd_add(acmds) enddef @@ -756,16 +748,6 @@ # Show the diagnostic message for the current line export def LspShowCurrentDiag(atPos: bool) diag.ShowCurrentDiag(atPos) -enddef - -# Display the diagnostics for the current line in the status line. -export def LspShowCurrentDiagInStatusLine() - var fname: string = @% - if fname->empty() - return - endif - - diag.ShowCurrentDiagInStatusLine() enddef # get the count of diagnostics in the current buffer