Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable within certain filetypes? #48

Open
Machine-Maker opened this issue May 7, 2023 · 1 comment
Open

Disable within certain filetypes? #48

Machine-Maker opened this issue May 7, 2023 · 1 comment

Comments

@Machine-Maker
Copy link

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

@Sam-programs
Copy link
Contributor

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
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants