folke / flash.nvim

Navigate your code with search labels, enhanced character motions and Treesitter integration
Apache License 2.0
2.51k stars 32 forks source link

feature: 'do not update labels' setting #70

Closed rasulomaroff closed 1 year ago

rasulomaroff commented 1 year ago

Did you check the docs?

Is your feature request related to a problem? Please describe.

Yep. When I specify search.max_length property (2, for example), labels are shown after the first character I type and then they are changed after the second one. It's inconvenient, isn't it? 🤔

Describe the solution you'd like

So, I would suggest to add a property static_labels or something like that. It would mean that labels shouldn't be changed when results are narrowing.

By the way, there's a property highlight.reuse and instead of adding a new one (static_labels), maybe it's better to add a possible none value for the reuse enum?

Describe alternatives you've considered

The alternative I've considered is to set highlight.label.min_pattern_length equal to 2. It kinda solves the problem and even has benefits (labels are shown right after 2 characters and don't cover the next character I wanna type), but I see the labels after typing the full length (2).

Additional context

No response

rasulomaroff commented 1 year ago

Here are the pictures showing changes in the label (top left corner)

WezTerm 2023-06-27 at 01-45 WezTerm 2023-06-27 at 01-46

rasulomaroff commented 1 year ago

Another thing I would like to suggest (just noticed it) is to have a fixed label position:

For now we have the highlight.label.after option that could be a number[] or boolean. I think adding a fixed property there is not a bad idea? For example: after = { 0, 3, fixed = true } But it should only work if search.max_length specified, in other cases it doesn't make sense. And I do believe that these constraints should only work in "jump" mode, not in search by pressing "/" or "?", so maybe the max_length option should also be added to jump settings to avoid the confusion (and in this case the offset can be applied automatically and it equals to max_length without the need to change anything else)?

What do you think?

folke commented 1 year ago

Did you properly read the docs?

  -- flash tries to re-use labels that were already assigned to a position,
      -- when typing more characters. By default only lower-case labels are re-used.
      reuse = "lowercase", ---@type "lowercase" | "all"

So just set that to "all" to get it to work like you want.

For your other comment, set after=false, before={0,2}

You can add the max_length to any mode. Again, read the config docs. It's all in there

rasulomaroff commented 1 year ago

@folke didn't know I can pass those props to any mode, although it should be obvious, totally makes sense. (Oh, I found the mention of it) Thanks for that trick with before={0,2}

BTW, yes, I've read that line Flash tries to re-use labels that were already assigned to a position, but I didn't think of it that way you mean 🤔.

Anyway, thank you for your quick response and help, I was able to set everything as I want and it works. Just amazed how customizable this plugin is. I don't see me using neovim without it anymore.

folke commented 1 year ago

Glad it's working now!