Jump to the errors in the quickfix or location list for the current line in Vim (with Syntastic)
You're right, there's no built-in way to find out which error is at or after the current cursor position, though that would often be useful. I've written the QuickFixCurrentNumber plugin for that.
With the g<C-q>
mapping, you can go to the item in the quickfix / location list for the current cursor position (or the next item after the cursor). It also offers [q
/ ]q
mappings to jump to previous / next errors while limiting the navigation to errors in the current buffer.
I think that it's not possible, at least with default Vim commands or Syntastic.
But Syntastic actually echoes the error message associated with the current line in your command-line. This feature is enabled by default.
I just created this for my :Man viewer. It tracks the current item in the 'locationlist' window when navigating:
function! s:visibleLoc()
return len(filter(getwininfo(), {i,v -> v.loclist}))
endfunc
function! s:followLine()
let curLine = line(".")
if (exists("b:lastLine") && b:lastLine == curLine) || 0 == s:visibleLoc()
return
endif
let b:lastLine = line(".")
let ent = len(filter(getloclist("."), {i,v -> v.lnum <= curLine}))
if ent < 1 || (exists("b:lastEntry") && b:lastEntry == ent)
return
endif
let b:lastEntry = ent
let pos = [ 0, curLine, col("."), 0 ]
exe "ll ".ent
call setpos(".", pos)
endfunc
au CursorMoved <buffer> call <SID>followLine()