ggandor / flit.nvim

Enhanced f/t motions for Leap
The Unlicense
365 stars 15 forks source link

Override to avoid using smartcase #14

Open AlexSWall opened 1 year ago

AlexSWall commented 1 year ago

I like using smartcase for standard searching but am not keen on it for my f (etc.) behaviour, so would like to avoid this. I have ignorecase = false for leap, but I'm still getting the behaviour of ff moving me to the next F.

Is there a way to override this or change this behaviour?

If not, I'm not against submitting a PR to add this functionality if you can point me to where it's occurring in the code and if it's not too complex; I couldn't see it.

ggandor commented 1 year ago

I have ignorecase = false for leap

Flit uses Leap's search function (get-match-positions), but feeds it with its own pattern, so Leap's setting is irrelevant here. (The option name is case_sensitive btw.)

Replace '\\V' with '\\V\\C' here, to force case sensitivity: https://github.com/ggandor/flit.nvim/blob/be110f9814a45788d10537fd59b3c76d956bb7ad/lua/flit.lua#L52

If not, I'm not against submitting a PR to add this functionality

The problem is not the implementation, but we'd need to decide on the API then. (Just an ignorecase flag? One for forcing smartcase too? An additional one to follow vim.o.ignorecase|smartcase? There are many possible combinations.)

AlexSWall commented 1 year ago

Makes sense. Thanks for pointing me to the right place.

There could be two flags, one for ignorecase and one for smartcase, with true and false values setting the value as an override and nil defaulting to vim.opt values?

AlexSWall commented 1 year ago

@ggandor If you give the thumbs up on this API, I'm happy to look into throwing in a PR. I just want to avoid putting in the effort if you wouldn't be happy with the solution.