tani / nvim-insx

Flexible key mapping manager.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nvim-insx

Flexible key mapping manager.

2023-06-01.3.07.56.mov

Warning

  • The basic recipes supports dot-repeat
    • However, advanced recipes don't support dot-repeat.
  • This plugin is usually works as expected.
    • Does not aim to support to always work as expected because this plugin uses RegExp 😅
    • Not based on tree-sitter is intentional. I think regular expressions are great for control during editing.
  • It is more convenient when used with vim-matchup.
    • The demo image uses with vim-matchup. 👍
  • This plugin provides basic cmdline-mode pairwise features.
    • The advanced recipes aren't support cmdline-mode.
  • The preset change is not treat as breakin change
    • if you hope to fix preset behavior, please write your own mapping definitions in your vimrc. 😢

Usage

This plugin does not provide any default mappings. You should define mapping by yourself like this.

Use preset

require('insx.preset.standard').setup()

Use recipe

local insx = require('insx')

insx.add(
  "'",
  insx.with(require('insx.recipe.auto_pair')({
    open = "'",
    close = "'"
  }), {
    insx.with.in_string(false),
    insx.with.in_comment(false),
    insx.with.nomatch([[\\\%#]]),
    insx.with.nomatch([[\a\%#]])
  })
)

Create your own recipe

-- Simple pair deletion recipe.
local function your_recipe(option)
  return {
    action = function(ctx)
      if option.allow_space then
        ctx.remove([[\s*\%#\s*]])
      end
      ctx.send('<BS><Right><BS>')
    end,
    enabled = function(ctx)
      if option.allow_space then
        return ctx.match([[(\s*\%#\s*)]])
      end
      return ctx.match([[(\%#)]])
    end
  }
end

The standard preset enables some of the advanced features.

Status

The API is stable except helper related APIs.

bug report & feature request are welcome.

About

Flexible key mapping manager.


Languages

Language:Lua 100.0%Language:Vim Script 0.0%