Skip to content

MrKyomoto/mini-reverse.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

mini-reverse

A lightweight Neovim plugin, aiming to auto reverse the paired content(i.e. left<->right,true<->false,==<->!=)

Feature

  • Normal mode(content in cursor) && Visual mode(content selected) are both SUPPORTED
  • Customizable reversed pairs
  • Support ignore case sensitivity(i.e. Left<->Right)

Setup

Using Lazy.nvim

{
  'MrKyomoto/mini-reverse.nvim',
  config = function()
    require('mini.reverse').setup({
      -- Custom key mapping (default is 'tr')
      mappings = { toggle = 'tr' },  -- 'tr' stands for "toggle reverse"

      -- Extend reverse pairs (defaults include left/right, <, >, etc.)
      reverse_pairs = {
        -- NOTE:Add new pairs while preserving defaults
        ['north'] = 'south',
        ['south'] = 'north',
        ['enable'] = 'disable',
        ['disable'] = 'enable',
        -- NOTE:Override default == ↔ != with == ↔ <> (useful for specific languages)
        ['=='] = '<>',
        ['<>'] = '==',
      },

      -- Enable case insensitivity (default: false)
      ignore_case = true,  -- Now works with Left → Right, LEFT → RIGHT

      -- Enable silent mode (no notifications, default: false)
      silent = true
    })
  end
}

default settings

  • These default pairs are empirical
-- Default configuration
MiniReverse.config = {
	mappings = { toggle = "tr" },
	reverse_pairs = {
    -- NOTE: most common pair: True && False
		["true"] = "false",
		["false"] = "true",

    -- NOTE: for some naming habit reason, these are added into default
		["left"] = "right",
		["right"] = "left",
		["up"] = "down",
		["down"] = "up",

    -- NOTE: addop, mulop && relop pair
		["+"] = "-",
		["-"] = "+",
		["^"] = "_",
		["_"] = "^",
		["/"] = "\\",
		["\\"] = "/",
		["<"] = ">",
		[">"] = "<",
		["<="] = ">=",
		[">="] = "<=",
		["=="] = "!=",
		["!="] = "==",
		["==="] = "!==",
		["!=="] = "===",

		["on"] = "off",
		["off"] = "on",

    ["yes"] = "no";
    ["no"] = "yes";

    -- NOTE: these pairs can be replaced by Code Action actually
    ["."] = "->";
    ["&"] = "*";
	},
	ignore_case = false,
	silent = false,
}

About

A lightweight Neovim plugin to auto revere some content (i.e. `true` <-> `false`, `==`<->`!=`

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages