max397574/better-escape.nvim

Can we keep mapping overrides ?

tommarien opened this issue ยท 5 comments

After the rewrite i have the following issue

in visual mode i press j to select line down, if i overpress i press of course k, this causes an escape to picked up, i want to disable select mode escape keybinds

I can do it now but it triggers the warning!!!

I don't really understand what your issue is
also I don't know which warning gets triggered. There should only be warning if you use the old way of configuration
to disable mappings see https://github.com/max397574/better-escape.nvim?tab=readme-ov-file#%EF%B8%8Fcustomization (set them to false)

@max397574 Thanks for pointing out was missing that part

    {
        'max397574/better-escape.nvim',
        event = 'InsertEnter',
        opts = {
            k = function()
                vim.api.nvim_input("<esc>")
                local current_line = vim.api.nvim_get_current_line()
                if current_line:match('^%s+j$') then
                    vim.schedule(function()
                        vim.api.nvim_set_current_line('')
                    end)
                end
            end,
            mappings = {
                v = {
                    j = {
                        k = false
                    }
                }
            }
        },
    },

that config looks really wrong to me
there is no k field in the config. So this will just be ignored
the bottom part looks correct though

@max397574 coming from the docs, to clear empty lines see https://github.com/max397574/better-escape.nvim?tab=readme-ov-file#rewrite

so this needs to be duplicated than over all mappings you don't control anymore ?

you'd need to

i = {
  j = {
    k = function() ... end
  }
}

if you want that for many different mappings just create a local function for it