Intelligent auto-pairs with rainbow highlighting for Neovim
  • Rust 62.2%
  • Lua 32.4%
  • Tree-sitter Query 3.8%
  • Nix 1.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-09-12 17:43:03 -04:00
.cargo feat: use fearless_simd crate, switch to stable toolchain, drop fenix (#101) 2026-05-26 12:13:44 -04:00
.github ci: fix artifact names 2026-06-11 18:27:43 -04:00
benches feat: pair class independent depth 2026-09-12 17:43:03 -04:00
lua feat: pair class independent depth 2026-09-12 17:43:03 -04:00
matcher chore: format code 2026-09-11 17:31:19 -04:00
plugin fix: use global namespace for highlight definitions (#122) 2026-07-12 16:39:14 -04:00
queries feat: add support for angle bracket highlighting/mappings (#136) 2026-09-08 16:47:44 -04:00
src feat: pair class independent depth 2026-09-12 17:43:03 -04:00
.gitattributes feat: exclude test languages from github language stats 2025-03-26 11:39:40 -04:00
.gitignore fix: add /lib to gitignore 2026-05-28 15:14:54 -07:00
.stylua.toml Initial commit 2025-03-14 14:56:01 -04:00
build.rs fix: remove outdated remove_file in build.rs 2026-06-12 19:51:07 -07:00
Cargo.lock feat: merge indents/tokenize/parse, remove simd, simplify lookahead (#104) 2026-05-29 20:17:47 -04:00
Cargo.toml feat: merge indents/tokenize/parse, remove simd, simplify lookahead (#104) 2026-05-29 20:17:47 -04:00
CHANGELOG.md chore: bump version to 0.7.1 2026-09-10 11:22:48 -04:00
cliff.toml chore: bump version to v0.5.0, adopt git-cliff 2026-03-24 14:26:44 -04:00
Cross.toml docs: misc cross.toml 2026-05-31 19:02:01 -04:00
flake.lock refactor: support blink.lib.config api changes (#134) 2026-09-04 16:19:12 -04:00
flake.nix chore: bump version to 0.7.1 2026-09-10 11:22:48 -04:00
LICENSE Initial commit 2025-03-14 14:56:01 -04:00
README.md feat: pair class independent depth 2026-09-12 17:43:03 -04:00
repro.lua fix: fixed repro.lua (#115) 2026-06-19 10:47:46 -04:00

Blink Pairs (blink.pairs)

Intelligent auto-pairs with rainbow highlighting for Neovim

blink.pairs combines auto-pairs with rainbow highlighting, via a custom internal parser. The parser takes ~1ms to parse a 400k character file, and ~0.005ms for incremental updates. It uses indent-aware matching of delimiters and highlights mismatched pairs. See the roadmap for the current status, contributions welcome!

  • Works out of the box with no additional configuration
  • Rainbow highlighting of pairs
  • Indent-aware matching of delimiters to highlight mismatched pairs
  • Wrapping via motions (dot-repeatable) or treesitter
  • Updates on every keystroke (<0.2ms)
Screenshot

code from frizbee, font iosevka, theme one-dark with catppuccin bg

Behavior

The behavior was inspired by lexima.vim and nvim-autopairs

Before Input After
| ( (|)
|) ( (|)
| " "|"
""| " """|"""
"foo| " "foo"|
|foo" " "|foo"
''| ' '''|'''
\| [ \[|
\| " \"|
\| ' \'|
A ' A'
(|) ) ()|
((|) ) (()|)
'|' ' ''|
'''|''' ' ''''''|
(|) <BS> |
'|' <BS> |
( | ) <BS> (|)
(|) <Space> ( | )
Vec| < Vec<|>
a | < a <|
foo(|)'bar' <C-b>a' foo('bar'|)

Installation

{
  'saghen/blink.pairs',
  dependencies = 'saghen/blink.lib',

  version = '*',
  -- download prebuilt binaries from github releases, must be on a versioned release
  build = function() require('blink.pairs').download():pwait(60000) end,
  -- OR build from source
  -- build = function() require('blink.pairs').build():pwait(60000) end,

  --- @module 'blink.pairs'
  --- @type blink.pairs.Config
  opts = {
    mappings = {
      -- you can call require("blink.pairs.mappings").enable()
      -- and require("blink.pairs.mappings").disable()
      -- to enable/disable mappings at runtime
      enabled = true,
      cmdline = true,
      -- or disable with `vim.g.pairs = false` (global) and `vim.b.pairs = false` (per-buffer)
      -- and/or with `vim.g.blink_pairs = false` and `vim.b.blink_pairs = false`
      disabled_filetypes = {},
      wrap = {
        -- move closing pair via motion
        ['<C-b>'] = 'motion',
        -- move opening pair via motion
        ['<C-S-b>'] = 'motion_reverse',
        -- set to 'treesitter' or 'treesitter_reverse' to use treesitter instead of motions
        -- set to nil, '' or false to disable the mapping
        -- for normal mode mappings, only supports 'motion' and 'motion_reverse'
        -- normal_mode = {}
      },
      -- see the defaults:
      -- https://github.com/Saghen/blink.pairs/blob/main/lua/blink/pairs/config/mappings.lua#L52
      pairs = {},
    },
    highlights = {
      enabled = true,
      -- requires require('vim._core.ui2').enable({}), otherwise has no effect
      cmdline = true,
      -- set to { 'BlinkPairs' } to disable rainbow highlighting
      groups = { 'BlinkPairsOrange', 'BlinkPairsPurple', 'BlinkPairsBlue' },
      -- pairs whose nesting is counted separately from the rest, or `true` for every pair
      separate = { '<' },
      unmatched_group = 'BlinkPairsUnmatched',

      -- highlights matching pairs under the cursor
      matchparen = {
        -- optionally only for the given token types, e.g. 'delimiter'
        enabled = true,
        -- known issue where typing won't update matchparen highlight, disabled by default
        cmdline = false,
        -- also include pairs not on top of the cursor, but surrounding the cursor
        -- optionally only for the given token types, which must be a subset of `enabled`,
        -- if defined
        include_surrounding = false,
        group = 'BlinkPairsMatchParen',
        priority = 250,
      },
    },
    debug = false,
  }
}

vim.pack

vim.pack.add({
  'https://github.com/saghen/blink.lib',
  { src = 'https://github.com/saghen/blink.pairs', version = vim.version.range('*') },
})

-- download prebuilt binaries from github releases, must be on a versioned release
require('blink.pairs').download():pwait(60000)
-- OR build from source
-- require('blink.pairs').build():pwait(60000)

-- see above for the config
require('blink.pairs').setup()