VidocqH / auto-indent.nvim

Auto indent like VSCode when cursor at the first column and press <TAB> key

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AutoIndent.nvim

A simple util providing auto indent like VSCode when cursor at the first column and press <TAB> key

2023-10-23.1.21.40.mov

Installation

Lazy

requir("lazy").setup({
  {
    'vidocqh/auto-indent.nvim',
    opts = {},
  },
})

Configuration

Default Config

require("auto-indent").setup({
  lightmode = true,        -- Lightmode assumes tabstop and indentexpr not change within buffer's lifetime
  indentexpr = nil,        -- Use vim.bo.indentexpr by default, see 'Custom Indent Evaluate Method'
  ignore_filetype = {},    -- Disable plugin for specific filetypes, e.g. ignore_filetype = { 'javascript' }
})

Custom Indent Evaluate Method

indentexpr should be a function returns quantity of indents

example using treesitter.indent module

{
  ---@param lnum: number
  ---@return number
  indentexpr = function(lnum)
    return require("nvim-treesitter.indent").get_indent(lnum)
  end
}

About

Auto indent like VSCode when cursor at the first column and press <TAB> key

License:MIT License


Languages

Language:Lua 100.0%