Code Monkey home page Code Monkey logo

nvim-insx's Introduction

nvim-insx

nvim-insx is a flexible key mapping manager.

2023-06-01.3.07.56.mov

Limitations and Warnings

  • Dot-repeat is supported by only basic recipes.
    • Note that dot-repeat may not work with the complicated recipes.
  • This plugin usually works as expected.
    • It may fire the accidental action, because the regular expression does not capture the structure of whole text.
    • We do not intend to integrate with tree-sitter as control over the regular expression is more convenient and sufficient.
  • It is more convenient when used with vim-matchup.
    • A demonstration of vim-match usage can be referred to above.
  • This plugin provides basic cmdline-mode pairwise features.
    • The advanced recipes do not support cmdline-mode.
  • We can not accept the proposal for preset if it incorporates breaking changes.
    • Please write your own mapping definitions in your vimrc. ๐Ÿ˜ข

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.