better-escape.nvim icon indicating copy to clipboard operation
better-escape.nvim copied to clipboard

Disable within certain filetypes?

Open Machine-Maker opened this issue 2 years ago • 1 comments

It'd be nice if there was a setting for a condition function to be called to see if the mapping should be "applied". My usecase specifically is disabling it within TelescopePrompts

Machine-Maker avatar May 07 '23 23:05 Machine-Maker

I think you can do it using a function like this:

mappings = {
    i = {
        j = {
            k = function()
                -- Escape insert mode when jk is pressed
                if vim.bo.filetype == 'Yourfiletype' then
                    -- Type 'jk' normally when inside filetype 'Yourfiletype'
                    -- <c-v> is used to avoid mappings
                    return "<c-v>j<c-v>k"
                end
                return "<esc>"
            end
        }
    }
}

Sam-programs avatar Jul 05 '24 12:07 Sam-programs