autozimu / LanguageClient-neovim

Language Server Protocol (LSP) support for vim and neovim.
MIT License
3.55k stars 273 forks source link

"Go to next error" action feature request #1148

Closed googleson78 closed 3 years ago

googleson78 commented 3 years ago

I'm not sure if something like this exists already, and I just haven't found it - I would like to be able to have an action that goes to the "next" diagnostic (perhaps configurable, e.g. go to next warning, go to next error).

This is extremely useful in a typed-language setting, where very often changing a core type means just going around files/your codebase and doing mostly trivial changes to the code.

Optionally, it would be pretty cool if this feature could work across files, so it would jump you to another file, although I have doubts wrt how possible this is.

I'm also willing to put some work into this, if it's not some conceptually hard change, although I have never written any rust (haskell dev).

martskins commented 3 years ago

To cycle diagnostics in a buffer you can use :call LanguageClient#diagnosticsNext() and :call LanguageClient#diagnosticsPrevious(). There's a plug mapping for these so you can map them with something like this:

    nmap <silent><c-]>        <Plug>(lcn-diagnostics-next)
    nmap <silent><c-[>        <Plug>(lcn-diagnostics-prev)

To cycle diagnostics in the whole project you can use :cnext and :cprevious or :lnext or :lprevious depending on whether you have configured quickfix or location list for diagnostics. Optionally you can also open the list with :copen or :lopen depending on the same as the previous point.

googleson78 commented 3 years ago

Omg sorry! And thanks! I'll try these out