RRethy / vim-illuminate

illuminate.vim - (Neo)Vim plugin for automatically highlighting other uses of the word under the cursor using either LSP, Tree-sitter, or regex matching.
2.14k stars 47 forks source link

Needs to call next_reference again in the same word when `reverse=true` #69

Closed baldore closed 3 years ago

baldore commented 3 years ago

Hello, first at all, what an amazing plugin. Thanks for the great work.

Second, when I use lua require"illuminate".next_reference{reverse=true,wrap=true} and I'm in the word, but not at the beginning of the word, it goes to the beginning of the word first, instead of going to the previous match. Adding a gif to be more clear.

double_back_reference

Just to know if this is expected or easily fixable. Thanks in advance.

RRethy commented 3 years ago

This was expected since it matches the behaviour of N when doing / searches. I can add an option to override this.

RRethy commented 3 years ago

I remember now why I made this decision originally. Matches can be nested, for example:

  return true
//         ^cursor is here

A language server could return the matches return true and true so moving to previous without using an ordering based on the start of the match would be weird and skip matches.

RRethy commented 3 years ago

You can use lua require"illuminate".next_reference{reverse=true,wrap=true,range_ordering='disjoint'} now.

baldore commented 3 years ago

Sounds good to me! Thanks for taking a look at this.