mawkler / refjump.nvim

Jump to next/previous LSP reference for item under cursor with ]r/[r
MIT License
27 stars 1 forks source link

fix: sort references from lsp by line #2

Closed Vinzent03 closed 2 weeks ago

Vinzent03 commented 2 weeks ago

When using the Dart lsp and querying the references, the declaration line is the last item in the references list and thus using the [r motion always goes to the declaration line. By ensuring the list is actually sorted by line, the issue is fixed.

mawkler commented 2 weeks ago

@Vinzent03 Thank you for your contribution! I just pushed a commit that changes from textDocument/references to textDocument/documentHighlight: https://github.com/mawkler/refjump.nvim/commit/b3f2cd76def28a58aa8b4fea5a66d506434f8951

I'm curious if textDocument/documentHighlight has the same issue for the Dart language server. Could you please give my plugin a try with the new commit and see if you see the same issue? I'm guessing that you will, and if that's the case I'll gladly merge your PR 🙂

Vinzent03 commented 2 weeks ago

Ah good catch with the correct lsp method. It actually seems to be solved!

Just a small note on your implementation. I don't think that endpoint supports/needs any context like the current includeDeclaration = true context. https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_documentHighlight So I think that can be removed.

mawkler commented 2 weeks ago

You're absolutely right, thank you! I've removed includeDeclaration = true in 3b52f5f2b4dc8ee03d7c79d28ce545c9cf91fd9d