folke / flash.nvim

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

feature: casing options for each mode #181

Open Reisen opened 1 year ago

Reisen commented 1 year ago

Did you check the docs?

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

In standard vim, ignorecase/smartcase does not apply to f behaviour, I.E: nvim -u NONE:

Searching with / for qui with ignorecase+smartcase hits the first result:

image

Searching with f for q with ignorecase+smartcase hits the second result:

image

It's intuitive that flash respects these settings for /, but for f this was a surprise compared to vanilla behaviour and breaks the utility of plugins like quickscope which now highlight the wrong symbols, so in my example here while my eyes are trained on q, pressing q actually takes me to Q.

image

So I repeatedly find myself often accidentally jumping earlier than I expected.

Describe the solution you'd like

To be able to disable case settings on a mode by mode basis:

config = {
    modes = {
        char = {
            case = 'sensitive'
         }
     }
}

Where a default of inherit might imply the current behaviour, I don't have a good idea in mind for how this option might exactly look though this is just a quick scrappy explanation of what I would like to be able to do.

Alternatively, to change f to not rely on ignorecase/smartcase so it matches vanilla nvim behaviour:

  'smartcase' 'scs'       boolean (default off)                                                                                                                                                                                                                                                  
                          global                                                                                                                                                                                                                                                                 
          Override the 'ignorecase' option if the search pattern contains upper                                                                                                                                                                                                                  
          case characters.  Only used when the search pattern is typed and                                                                                                                                                                                                                       
          'ignorecase' option is on.  Used for the commands "/", "?", "n", "N",                                                                                                                                                                                                                  
          ":g" and ":s".  Not used for "*", "#", "gd", tag search, etc.  After                                                                                                                                                                                                                   
          "*" and "#" you can make 'smartcase' used by doing a "/" command,                                                                                                                                                                                                                      
          recalling the search pattern from history and hitting <Enter>. 

Describe alternatives you've considered

  1. Disable flash for f and stick to only s and / benefits of flash.
  2. Disable uppercase searches for quickscope as most of the time I'm searching lowercase, but this isn't ideal as quickscope requires listing every possible matchable char if you try and override the allowable characters so you have to maintain a whitelist. This would reduce the amount of matchable positions as well which is unfortunate.

Additional context

While It's not related to the feature I'm requesting here, I was wondering what your thoughts might be on adding quickscopes functionality to flash? Quickscope is a pretty old plugin at this point as far as I can tell, and flash's f behaviour is very nice. Having the ability to show the first non-conflicting f jump in each word, but being able to do it over multiple lines would be incredibly useful.

nullromo commented 10 months ago

Based on this comment, an alternative approach would be to override the jump behavior as follows:

function()
    local ignorecase = vim.go.ignorecase
    vim.go.ignorecase = false
    require('flash').something({    I'm not sure what to put here    })
    vim.go.ignorecase = ignorecase
end

However, I don't know where this would go in the flash config, as I do not see an option for supplying a custom function for the f/F/t/T feature.

Any tips on how to use this approach would be much appreciated since I am a bit confused about how to set this up.

@Reisen did you ever find another workaround?

github-actions[bot] commented 2 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

nullromo commented 2 months ago

This has not been addressed, so the stale label should be removed.

github-actions[bot] commented 1 month ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

nullromo commented 1 month ago

Still not stale.

github-actions[bot] commented 1 day ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

nullromo commented 1 day ago

Nope