Skip to content

alex-k03/nvim-toggle-indentation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

indent-toggle.nvim

Quick indentation toggling for Neovim.

Installation

lazy.nvim

{
  "alex-k03/nvim-toggle-indentation",
  config = function()
    require("indent-toggle").setup({
      small_indent = 2,      -- default: 2
      large_indent = 4,      -- default: 4
      update_prettier = false, -- default: false, set to true to sync with ~/.prettierrc
    })
  end,
}

With prettier integration and keybindings

{
  "alex-k03/nvim-toggle-indentation",
  config = function()
    require("indent-toggle").setup({
      update_prettier = true,
      keys = {
        { "<leader><tab>t", action = "toggle", desc = "Toggle indentation" },
        { "<leader><tab>2", action = "set", value = 2, desc = "Set indentation to 2" },
        { "<leader><tab>4", action = "set", value = 4, desc = "Set indentation to 4" },
      },
    })
  end,
}

Usage

Commands

  • :ToggleIndentation - Toggle between small and large indentation
  • :SetIndentation 4 - Set specific indentation level

Keybindings

Configure keybindings in the keys option during setup:

keys = {
  { "<leader><tab>t", action = "toggle", desc = "Toggle indentation" },
  { "<leader><tab>2", action = "set", value = 2, desc = "Set indentation to 2" },
  { "<leader><tab>4", action = "set", value = 4, desc = "Set indentation to 4" },
}

Each key table supports:

  • [1] - The key mapping (required)
  • action - Either "toggle" or "set" (required)
  • value - The indentation value (required for "set" action)
  • desc - Description for which-key (optional)
  • mode - Vim mode, defaults to "n" (optional)
  • silent - Whether to suppress output, defaults to true (optional)

Configuration

All options with their defaults:

{
  small_indent = 2,        -- The smaller indentation size
  large_indent = 4,        -- The larger indentation size
  update_prettier = false, -- Whether to update ~/.prettierrc tabWidth
}

About

slop - don't use this

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages