/toggle-bool.nvim

A simple plugin to toggle bools in nvim

Primary LanguageLuaMIT LicenseMIT

toggle-bool.nvim

This is a minimal Neovim plugin that can be used to toggle various boolean-like values.

toggle-bool

The toggles included by default are:

  • False ←→ True
  • false ←→ true

The toggle works for the first match on the current line starting at the cursor position.

Additional toggles can be setup by the user.

This plugin is a Lua port of the Vim version gerazov/vim-toggle-bool.

Setup

The plugin can be installed via a plugin manager.

For packer.nvim it's:

use 'gerazov/toggle-bool.nvim'

To setup the plugin run:

require("toggle-bool").setup {
    mapping = "<leader>tt",
	additional_toggles = {
        Yes = 'No',
        On = 'Off',
        ["0"] = "1",
        Enable = 'Disable',
        Enabled = 'Disabled',
        First = 'Last',
        Before = 'After',
        Persistent = 'Ephemeral',
        Internal = 'External',
        Ingress = 'Egress',
        Allow = 'Deny',
        All = 'None',
    },
}

Usage

The plugin exposes a single function toggle_bool that is mapped to the specified mapping.

Alternatively, it can be called via:

:lua require("toggle-bool").toggle_bool()

Similar plugins