return []
enddef
+# Utility function to do the actual jump
+def JumpDiag(diag: dict<any>)
+ setcursorcharpos(diag.range.start.line + 1, diag.range.start.character + 1)
+ if !opt.lspOptions.showDiagWithVirtualText
+ :redraw
+ DisplayDiag(diag)
+ endif
+enddef
+
# jump to the next/previous/first diagnostic message in the current buffer
-export def LspDiagsJump(lspserver: dict<any>, which: string): void
+export def LspDiagsJump(lspserver: dict<any>, which: string, a_count: number = 0): void
var fname: string = expand('%:p')
if fname == ''
return
var diags = lspserver.diagsMap[bnr].sortedDiagnostics
if which == 'first'
- setcursorcharpos(diags[0].range.start.line + 1, diags[0].range.start.character + 1)
- if !opt.lspOptions.showDiagWithVirtualText
- :redraw
- DisplayDiag(diags[0])
- endif
+ JumpDiag(diags[0])
return
endif
# Find the entry just before the current line (binary search)
+ var count = a_count > 1 ? a_count : 1
var curlnum: number = line('.')
var curcol: number = charcol('.')
for diag in (which == 'next' || which == 'here') ?
|| (which == 'prev' && (lnum < curlnum || lnum == curlnum
&& col < curcol))
|| (which == 'here' && (lnum == curlnum && col >= curcol))
- setcursorcharpos(lnum, col)
- if !opt.lspOptions.showDiagWithVirtualText
- :redraw
- DisplayDiag(diag)
+
+ # Skip over as many diags as "count" dictates
+ count = count - 1
+ if count > 0
+ continue
endif
+
+ JumpDiag(diag)
return
endif
endfor
+ # If [count] exceeded the remaining diags
+ if which == 'next' && a_count > 1 && a_count != count
+ JumpDiag(diags[-1])
+ return
+ endif
+
if which == 'here'
util.WarnMsg('Error: No more diagnostics found on this line')
else
enddef
# jump to the next/previous/first diagnostic message in the current buffer
-export def JumpToDiag(which: string): void
+export def JumpToDiag(which: string, count: number = 0): void
var lspserver: dict<any> = buf.CurbufGetServerChecked()
if lspserver->empty()
return
endif
- diag.LspDiagsJump(lspserver, which)
+ diag.LspDiagsJump(lspserver, which, count)
enddef
# Display the hover message from the LSP server for the current cursor
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 LspDiagNext lsp.JumpToDiag('next')
+command! -nargs=0 -bar -count=1 LspDiagNext lsp.JumpToDiag('next', <count>)
command! -nargs=0 -bar LspDiagPrev lsp.JumpToDiag('prev')
command! -nargs=0 -bar LspDiagShow lsp.ShowDiagnostics()
command! -nargs=0 -bar LspDiagHere lsp.JumpToDiag('here')