Home

Awesome

nvim-insx

nvim-insx is a flexible key mapping manager.

https://github.com/hrsh7th/nvim-insx/assets/629908/ad878d95-c541-4d6c-b135-139d511602b8

Limitations and Warnings

Usage

This plugin provides no default mappings. You need to define your custom mappings as follows.

Preset

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

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\%#]])
  })
)

Custom 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 advanced features.

Status

The API is stable except for the helper-related APIs.

Bug report & feature request are welcome.