Simple indentation configuration and guessing plugin for Neovim
require("indent-wizard").setup {}
{
"chardoncs/indent-wizard.nvim",
opts = {},
}
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
},
}
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,
},
},
},
}
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)
- Output:
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)
- Output: