iquzart/toggleword.nvim

github github
utility
stars 2
issues 1
subscribers 0
forks 0
CREATED

UPDATED


Features

  • Toggle common values like truefalse, onoff, etc.
  • Minimal, fast, and Lua-native.
  • Configurable keybinding.
  • Custom toggle pairs supported.

Installation

Lazy.nvim:

{
  "iquzart/toggleword.nvim",
   opts = {
     key = "<leader>tt" -- optional, defaults to <leader>tt,
   }
}

packer.nvim:

use {
  "yourname/toggleword.nvim",
  config = function()
    require("toggleword").setup()
  end,
}

Supported words

- true ⇄ false
- on ⇄ off
- enabled ⇄ disabled
- yes ⇄ no
- up ⇄ down
- start ⇄ stop
- open ⇄ close
- allow ⇄ deny
- accept ⇄ reject
- read ⇄ write
- push ⇄ pull
- inbound ⇄ outbound
- public ⇄ private
- online ⇄ offline
- local ⇄ remote
- master ⇄ slave
- primary ⇄ replica
- active ⇄ passive
- manual ⇄ automatic

- prod ⇄ uat ⇄ dev ⇄ preprod (cyclical)

Custom Toggle Pairs

You can override the default list:

require("toggleword").setup {
  key = "<leader>tw",
  toggle_groups = {
    {"start", "stop"},
    {"open",  "close"},
    {"active", "inactive"},
  }
}

Usage

Place your cursor on a supported word and press <leader>tt.
If the word matches a toggle pair, it will be replaced with the opposite.