Skip to content

Simple indentation configuration and guessing plugin for Neovim

License

Notifications You must be signed in to change notification settings

chardoncs/indent-wizard.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

indent-wizard.nvim 🧙

Simple indentation configuration and guessing plugin for Neovim

Install

Manual

require("indent-wizard").setup {}
{
  "chardoncs/indent-wizard.nvim",
  opts = {},
}

Usage

Configuration

Default configuration

This snippet is about default config. You don't need to copypasta it.

require("indent-wizard").setup {
  -- Auto guess and set buffer-wise indentation for each buffer
  auto_guess = true,
  scan = {
    -- How many lines of sample in a file should be used for indentation guessing.
    --
    -- NOTE: 0-indented lines are ignored.
    line_count = 60,
    -- How many lines should be skipped.
    --
    -- If the number is between 0~1, indent-wizard will regard it
    -- as percentage of total lines.
    offset = 0,
  },
  -- Default settings
  defaults = {
    -- Nothing by default
  },
}

Fallback indentations

Here is how fallback settings (defaults) looks like:

require("indent-wizard").setup {
  defaults = {
    -- Global settings, will be applied to `vim.opt`
    {
      -- All options are optional
      options = {
        tabstop = 8,
        softtabstop = 4,
        shiftwidth = 4,
        expandtab = true,
        smartindent = true,
      },
    },
    -- Filetype-wise settings, will be applied to `vim.bo`
    {
      ft = "go",
      options = {
        shiftwidth = 4,
        expandtab = false,
      },
    },
    {
      -- Or multiple filetypes
      ft = {"c", "cpp", "rust", "zig"},
      options = {
        shiftwidth = 4,
        expandtab = false,
      },
    },
  },
}

Commands

  • IndentInfo: Guess the indentation and print the summary
    • Output: Apparently: shiftwidth=<sw>, expandtab=<et>
      • <sw>: Number for shiftwidth, or ? for inconclusive
      • <et>: If expands tab, yes, no, or ? (inconclusive)
  • GuessIndent: Guess the indentation and update the configuration
    • Output: Apparently: shiftwidth=<sw>, expandtab=<et>
      • <sw>: Number for shiftwidth, or ? for inconclusive
      • <et>: If expands tab, yes, no, or ? (inconclusive)

About

Simple indentation configuration and guessing plugin for Neovim

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages