autozimu / LanguageClient-neovim

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

Add function and plug mappings to cycle diagnostics #1075

Closed martskins closed 4 years ago

martskins commented 4 years ago

This PR creates two new function LanguageClient_diagnosticsNext and LanguageClient_diagnosticsPrevious which enable the user to jump to the next or previous diagnostic in the current buffer, relative to the cursor's current position.

Peek 2020-07-13 17-56

martskins commented 4 years ago

@autozimu I'm not 100% sure if I missed something and there's already something in place for this or if this is in fact a missing feature, so I'll this for you to comment on and then I'll merge it if there aren't any functions that provide this functionality.

autozimu commented 4 years ago

I personally use quickfix to display diagnostics (the default) with :cp, :cn to jump between locations. While using location list, I believe :prev, :lnext serve similar purpose. Is this actually sufficient?

martskins commented 4 years ago

Not quite. The only bit that I find difficult with that workflow is that the items in the location/quickfix list are (logically) not re-sorted every time you move the cursor, so the "next" item in the location list is not really the next diagnostic based on the position of the cursor, which makes navigation a little difficult if you have many diagnostics. It can also be a little surprising, if you have the location list closed and do :lnext then you don't really know which diagnostic that is gonna take you too.

Another thing is that diagnostics do not seem to be ordered by line number in the location/quickfix list, maybe that can be solved though, but it still doesn't solve the previous issue.

autozimu commented 4 years ago

Ahh, makes sense. Can you add this gist to the function doc? Then let's merge it in.

On Wed, Jul 15, 2020 at 00:15 martskins notifications@github.com wrote:

Not quite. The only bit that I find difficult with that workflow is that the items in the location/quickfix list are (logically) not re-sorted every time you move the cursor, so the "next" item in the location list is not really the next diagnostic based on the position of the cursor, which makes navigation a little difficult if you have many diagnostics.

Another thing is that diagnostics do not seem to be ordered by line number in the location/quickfix list, maybe that can be solved though, but it still doesn't solve the previous issue.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/autozimu/LanguageClient-neovim/pull/1075#issuecomment-658590968, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALC337EAK6MRZ4KUQLS6ILR3VJQLANCNFSM4OYVQM4A .

martskins commented 4 years ago

I adjusted the doc to make it a little clearer, but not sure if that's what you meant.