From 452d7924abba12af9eb9b41491c6cb6684052dbe Mon Sep 17 00:00:00 2001 From: Andreas Louv Date: Mon, 3 Apr 2023 02:00:21 +0200 Subject: [PATCH] Make it possible to provide a "[count]" for ":LspDiagPrev" This works somewhat like the count for `:h :cbefore` --- autoload/lsp/diag.vim | 6 ++++++ plugin/lsp.vim | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/autoload/lsp/diag.vim b/autoload/lsp/diag.vim index bdf36a4..8e27723 100644 --- a/autoload/lsp/diag.vim +++ b/autoload/lsp/diag.vim @@ -517,6 +517,12 @@ export def LspDiagsJump(lspserver: dict, which: string, a_count: number = 0 return endif + # If [count] exceeded the previous diags + if which == 'prev' && a_count > 1 && a_count != count + JumpDiag(diags[0]) + return + endif + if which == 'here' util.WarnMsg('Error: No more diagnostics found on this line') else diff --git a/plugin/lsp.vim b/plugin/lsp.vim index 8d2ea9d..12271dd 100644 --- a/plugin/lsp.vim +++ b/plugin/lsp.vim @@ -83,7 +83,7 @@ command! -nargs=0 -bar LspDiagFirst lsp.JumpToDiag('first') command! -nargs=0 -bar LspDiagHighlightDisable lsp.DiagHighlightDisable() command! -nargs=0 -bar LspDiagHighlightEnable lsp.DiagHighlightEnable() command! -nargs=0 -bar -count=1 LspDiagNext lsp.JumpToDiag('next', ) -command! -nargs=0 -bar LspDiagPrev lsp.JumpToDiag('prev') +command! -nargs=0 -bar -count=1 LspDiagPrev lsp.JumpToDiag('prev', ) command! -nargs=0 -bar LspDiagShow lsp.ShowDiagnostics() command! -nargs=0 -bar LspDiagHere lsp.JumpToDiag('here') command! -nargs=0 -bar LspFold lsp.FoldDocument() -- 2.48.1