Does a plugin to jump to next reference exist?

I just wanted to know if there is any plugin that implements a functionality to jump to next reference?
Currently there is go to references, which opens quick fix with all references, but sometimes I just want to jump to the next one.
Is this possible? I don’t mind if there is a simple mapping that I can copy paste (ideally, in lua).
Thanks in advance.

You’d need to call references with a custom callback (using vim.lsp.buf_request). Assuming you mean the next reference in the same file, your callback would need to:

  1. filter the results to only look at references in the current file
  2. sort the remaining references by position
  3. find where your cursor is in that list
  4. jump to the next one using vim.lsp.util.jump_to_location

If you don’t mean the next reference in the same file, you can skip step 1, and sort by file name and position in step 2.

Is this you want?nvim-treesitter-refactor#navigation

looks exactly like what I want. Thanks

I appreciate the time you put into describing the required steps. I will see if the proposed existing solutions work for me, if not I may give a try to implement it myself.

This is also very nice to use it with hop.nvim:

Treesitter will only allow you to find references in the current file; unlike a language server, it isn’t aware of the other files in the project.

That is generally OK in the context of editing the file. I just want granular control to move exactly I want