ggandor / flit.nvim

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

Make the default key bindings optional #8

Open jotacosta-fb opened 1 year ago

jotacosta-fb commented 1 year ago

I like using f/F for flit and t/T for Leap. Can we make flit have optional keybindings very much like Leap does?

Right now my config is:

    use {
        'ggandor/flit.nvim',
        requires = { 'ggandor/leap.nvim' },
        config = function()
            require('flit').setup {
                keys = { f = 'f', F = 'F', t = 'ggt', T = 'ggT' },
            }

        end,
    }

I would like to just define:

  require('flit').setup {
                keys = { f = 'f', F = 'F'},
            }

Or just have the ability to call (flit-forward-to) like I do with Leap!

ggandor commented 1 year ago

I would like to just define:

require('flit').setup { keys = { f = 'f', F = 'F'}, }

This already works, you're free to leave out those keys you don't want to remap.

Or just have the ability to call (flit-forward-to) like I do with Leap!

Long story short: the "clever-f" functionality prevents that - for that, the flit() call should know what key has been mapped to it, but we cannot pass arguments to a <Plug> key, by design. (Lightspeed solved this in a hacky way, by scanning through all the user-defined mappings itself, so that it could still use <Plug> keys, but I considered that overengineering here.) That said, the flit function could be exposed indeed.

jotacosta-fb commented 1 year ago

Are you sure that leaving keys out works? I tried it (before and after opening the ticket) and it results in:

table index is nil

Looking at your code, you do hardcode the [key.t] .... So I'm assuming you cannot leave them out of the setup. Can you confirm? Maybe I'm doing something wrong?

ggandor commented 1 year ago

you do hardcode the [key.t] ...

Oh, indeed. I forgot about setup itself :)