Krafi2 / jeskape.nvim

A neovim plugin for mapping key sequences in insert mode without disrupting typing.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jeskape

Have you ever wanted to map keys in insert mode, but found that it causes the mapped keys to lag? This happens because neovim waits until it is sure that you aren't typing a mapped combination before inserting characters. Jeskape works around the issue by implementing its own mapping system for insert mode.

Installation

Install using your favourite package manager.

-- with packer.nvim
use {
    "Krafi2/jeskape.nvim",
    config = function()
        require("jeskape").setup()
    end,
}

Configuration

You can configure the plugin using the setup function.

require("jeskape").setup {
    -- Mappings are specified in this table. Jeskape uses neovim's keymap
    -- system under the hood, so anything allowed in a normal `map`'s righ hand
    -- side will work here too. Check out ':h  map.txt' to see what's possible.
    mappings = {
        -- Typing `hi` quickly will cause the string `hello!` to be inserted.
        hi = "hello!",
        -- They can also be specified in a tree-like format.
        j = {
            -- Here `jk` will escape insert mode.
            k = "<esc>",
            -- You can have as many layers as you want!
            h = {
                g = "I pressed jhg!",
            },
            -- If the mapping leads to a function, it will be evaluated every
            -- time the mapping is reached and its return value will be fed to
            -- neovim.
            f = function()
                print("Oh look, a function!")
                -- Insert the name of the current file.
                return vim.fn.expand "%:t"
            end,
        },
        -- You can use lua's arbitrary key notation to map special characters
        [";;"] = "<esc>A;<cr>",
        -- Use `<cmd>` to map commands. Be carful to terminate the command with `<cr>`.
        ff = "<cmd>echo 'commands work too'<cr>",
    },
    -- The maximum length of time between keystrokes where they are still
    -- considered a part of the same mapping.
    timeout = vim.o.timeoutlen,
}

Alternatives

You can also try one of these plugins if all you need is escaping insert mode.

About

A neovim plugin for mapping key sequences in insert mode without disrupting typing.

License:MIT License


Languages

Language:Lua 100.0%