folke / flash.nvim

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

feature: allow max_length in `modes -> search -> search` #166

Closed Reisen closed 1 year ago

Reisen commented 1 year ago

Did you check the docs?

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

When setting max_length under config -> search the s/S style mappings work as expected, but when using / this is also applied. While It's possible to toggle this on/off it's not very fluid.

Describe the solution you'd like

I would like to be able to set this using the provided search suboptions:

config = {
    search = { max_length = 2 },
    modes = {
        search = {
            search = { max_length = nil }
        }
    }
}

So that I retain unlimited character typing only when using /, but currently this does not seem to work, not sure if unintentional or not.

Describe alternatives you've considered

Just not setting max_length at all but I prefer the 2-char cancelling behaviour when using s.

Additional context

No response

Reisen commented 1 year ago

On second thoughts this might be a bug. For now I'm working around it by leaving max_length nil and setting it explicitly in my keymap:

keys = {
    { 's', mode = { 'n', 'x', 'o' }, function() require 'flash'.jump({ search = { max_length = 2 } }) end, desc = 'Jump' }
}
folke commented 1 year ago

In lua, doing {search = {max_length = nil}} is the same as {search = {}}, so there's no way to differentiate between the two.

You could set max_length = false instead, but it's better to just set it specifically for the jump keymap as you did.