blink.indent

repository·main·Indexed 42 days ago

https://github.com/saghen/blink.indent

A high-performance indent guide plugin for Neovim providing scope-aware indentation visuals with minimal latency. Features include configurable static and active scope guides, custom textobjects for scope navigation, and support for dedent-scoped filetypes.

Tokens
1.8K
Snippets
3
Records
3
Agent score
4%

What's inside blink.indent

  1. Install blink.indent

    main

    You can install blink.indent using lazy.nvim or vim.pack. Note that calling setup() is optional; the plugin will initialize with default settings automatically.

    -- lazy.nvim
    {
      'saghen/blink.indent',
      --- @module 'blink.indent'
      --- @type blink.indent.Config
      -- opts = {},
    }
    
    -- vim.pack
    vim.pack.add({ 'https://github.com/saghen/blink.indent' 
    -- require('blink.indent').setup({})
  2. Configure blink.indent options

    main

    Use require('blink.indent').setup({...}) to customize the plugin. Key configuration areas include:

    • dedent_scoped_filetypes: A table containing include_defaults. Set to true to treat all filetypes as having scopes closed by dedenting (useful for Python/YAML).
    • blocked: Defines buftypes and filetypes where the plugin is disabled. Defaults include terminal, quickfix, lspinfo, help, etc.
    • mappings: Configures textobjects and motions:
      • border: 'top', 'bottom', 'both', or 'none' for scope lines.
      • object_scope: Textobject identifier (e.g., 'ii').
      • object_scope_with_border: Textobject identifier including borders (e.g., 'ai').
      • goto_top: Motion for jumping to scope top (default '[i').
      • goto_bottom: Motion for jumping to scope bottom (default ']i').
    • static: Configuration for static indent guides:
      • char: The character used for the guide.
      • highlights: A list of highlight groups for rainbow-style guides.
    • scope: Configuration for the active scope:
      • enabled: Whether to highlight the highest level of indentation on the current line.
      • indent_at_cursor: If true, clamps the guide to the cursor's indent level.
      • underline: A table with enabled and highlights to show underlines on the line above the current scope.
    require('blink.indent').setup({
      -- filetypes where scopes are closed by dedenting, such as python and yaml
      -- set to true to treat all filetypes this way
      dedent_scoped_filetypes = { include_defaults = true },
      blocked = {
        -- default: 'terminal', 'quickfix', 'nofile', 'prompt'
        buftypes = { include_defaults = true },
        -- default: 'lspinfo', 'packer', 'checkhealth', 'help', 'man', 'gitcommit', 'dashboard', ''
        filetypes = { include_defaults = true },
      },
      mappings = {
        -- which lines around the scope are included for 'ai': 'top', 'bottom', 'both', or 'none'
        border = 'both',
        -- set to '' to disable
        -- textobjects (e.g. `y2ii` to yank current and outer scope)
        object_scope = 'ii',
        object_scope_with_border = 'ai',
        -- motions
        goto_top = '[i',
        goto_bottom = ']i',
      },
      static = {
        enabled = true,
        char = '▎',
        -- inherits space/tab characters from 'listchars' when 'list' is enabled (see `:h 'listchars'`)
        whitespace_char = nil,
        priority = 1,
        -- specify multiple highlights here for rainbow-style indent guides
        -- highlights = { 'BlinkIndentRed', 'BlinkIndentOrange', 'BlinkIndentYellow', 'BlinkIndentGreen', 'BlinkIndentViolet', 'BlinkIndentCyan' },
        highlights = { 'BlinkIndent' },
      },
      scope = {
        enabled = true, -- highlight highest level of indentation on the current line
        indent_at_cursor = false, -- clamp to indent level of cursor
        char = '▎',
        priority = 1000,
        -- set this to a single highlight, such as 'BlinkIndent' to disable rainbow-style indent guides
        -- highlights = { 'BlinkIndentScope' },
        -- optionally add: 'BlinkIndentRed', 'BlinkIndentCyan', 'BlinkIndentYellow', 'BlinkIndentGreen'
        highlights = { 'BlinkIndentOrange', 'BlinkIndentViolet', 'BlinkIndentBlue' },
        -- enable to show underlines on the line above the current scope
        underline = {
          enabled = false,
          -- optionally add: 'BlinkIndentRedUnderline', 'BlinkIndentCyanUnderline', 'BlinkIndentYellowUnderline', 'BlinkIndentGreenUnderline'
          highlights = { 'BlinkIndentOrangeUnderline', 'BlinkIndentVioletUnderline', 'BlinkIndentBlueUnderline' },
        },
      },
    })
  3. Toggle indent guides visibility

    main

    You can disable indent guides globally using vim.g.indent_guide = false or per-buffer using vim.b[bufnr].indent_guide = false.

    To create a keymap that toggles visibility for the current buffer, use the blink.indent API:

    -- Toggle for current buffer
    local indent = require('blink.indent')
    vim.keymap.set('n', 'some-key', function() 
      indent.enable(not indent.is_enabled({ bufnr = 0 }), { bufnr = 0 }) 
    end, { desc = 'Toggle indent guides' })