mini.bracketed
Generated from the main branch of ‘mini.nvim’
Go forward/backward with square brackets
See more details in Features and Documentation.
This was previously hosted at a personal echasnovski GitHub account. It was transferred to a dedicated organization to improve long term project stability. See more details here.
⦿ This is a part of mini.nvim library. Please use this link if you want to mention this module.
⦿ All contributions (issues, pull requests, discussions, etc.) are done inside of ‘mini.nvim’.
⦿ See whole library documentation to learn about general design principles, disable/configuration recipes, and more.
⦿ See MiniMax for a full config example that uses this module.
If you want to help this project grow but don’t know where to start, check out contributing guides of ‘mini.nvim’ or leave a Github star for ‘mini.nvim’ project and/or any its standalone Git repositories.
Demo
Features
Configurable Lua functions to go forward/backward to a certain target. Each function can be customized with:
- Direction. One of “forward”, “backward”, “first” (forward starting from first one), “last” (backward starting from last one).
- Number of times to go.
- Whether to wrap on edges (going forward on last one goes to first).
- Some other target specific options.
Mappings using square brackets. They are created using configurable target suffix and can be selectively disabled.
Each mapping supports |[count]|. Mappings are created in Normal mode; for targets which move cursor in current buffer also Visual and Operator-pending (with dot-repeat) modes are supported.
Using
lower-suffixandupper-suffix(lower and upper case suffix) for a single target the following mappings are created:[+upper-suffix: go first.[+lower-suffix: go backward.]+lower-suffix: go forward.]+upper-suffix: go last.
Supported targets (for more information see help for corresponding Lua function):
Target Mappings Lua function Buffer [B[b]b]BMiniBracketed.buffer()Comment block [C[c]c]CMiniBracketed.comment()Conflict marker [X[x]x]XMiniBracketed.conflict()Diagnostic [D[d]d]DMiniBracketed.diagnostic()File on disk [F[f]f]FMiniBracketed.file()Indent change [I[i]i]IMiniBracketed.indent()Jump from jumplist inside current buffer [J[j]j]JMiniBracketed.jump()Location from location list [L[l]l]LMiniBracketed.location()Old files [O[o]o]OMiniBracketed.oldfile()Quickfix entry from quickfix list [Q[q]q]QMiniBracketed.quickfix()Tree-sitter node and parents [T[t]t]TMiniBracketed.treesitter()Undo states from specially tracked linear history [U[u]u]UMiniBracketed.undo()Window in current tab [W[w]w]WMiniBracketed.window()Yank selection replacing latest put region [Y[y]y]YMiniBracketed.yank()
Notes:
- The
undotarget remapsuand<C-R>keys to register undo state after undo and redo respectively. If this conflicts with your setup, either disableundotarget or make your remaps after callingMiniBracketed.setup(). To useundotarget, remap your undo/redo keys to callMiniBracketed.register_undo_state()after the action.
Installation
This plugin can be installed as part of ‘mini.nvim’ library (recommended) or as a standalone Git repository.
There are two branches to install from:
main(default, recommended) will have latest development version of plugin. All changes since last stable release should be perceived as being in beta testing phase (meaning they already passed alpha-testing and are moderately settled).stablewill be updated only upon releases with code tested during public beta-testing phase inmainbranch.
Here are code snippets for some common installation methods (use only one):
With mini.deps
‘mini.nvim’ library:
Branch Code snippet Main Follow recommended ‘mini.deps’ installation Stable Follow recommended ‘mini.deps’ installation Standalone plugin:
Branch Code snippet Main add(‘nvim-mini/mini.bracketed’)Stable add({ source = ‘nvim-mini/mini.bracketed’, checkout = ‘stable’ })
With folke/lazy.nvim
‘mini.nvim’ library:
Branch Code snippet Main { 'nvim-mini/mini.nvim', version = false },Stable { 'nvim-mini/mini.nvim', version = '*' },Standalone plugin:
Branch Code snippet Main { 'nvim-mini/mini.bracketed', version = false },Stable { 'nvim-mini/mini.bracketed', version = '*' },
With junegunn/vim-plug
‘mini.nvim’ library:
Branch Code snippet Main Plug 'nvim-mini/mini.nvim'Stable Plug 'nvim-mini/mini.nvim', { 'branch': 'stable' }Standalone plugin:
Branch Code snippet Main Plug 'nvim-mini/mini.bracketed'Stable Plug 'nvim-mini/mini.bracketed', { 'branch': 'stable' }
Important: don’t forget to call require('mini.bracketed').setup() to enable its functionality.
Note: if you are on Windows, there might be problems with too long file paths (like error: unable to create file <some file name>: Filename too long). Try doing one of the following:
- Enable corresponding git global config value:
git config --system core.longpaths true. Then try to reinstall. - Install plugin in other place with shorter path.
Default config
-- No need to copy this inside `setup()`. Will be used automatically.
{
-- First-level elements are tables describing behavior of a target:
--
-- - <suffix> - single character suffix. Used after `[` / `]` in mappings.
-- For example, with `b` creates `[B`, `[b`, `]b`, `]B` mappings.
-- Supply empty string `''` to not create mappings.
--
-- - <options> - table overriding target options.
--
-- See [`:h MiniBracketed.config`](../doc/mini-bracketed.qmd#minibracketed.config) for more info.
buffer = { suffix = 'b', options = {} },
comment = { suffix = 'c', options = {} },
conflict = { suffix = 'x', options = {} },
diagnostic = { suffix = 'd', options = {} },
file = { suffix = 'f', options = {} },
indent = { suffix = 'i', options = {} },
jump = { suffix = 'j', options = {} },
location = { suffix = 'l', options = {} },
oldfile = { suffix = 'o', options = {} },
quickfix = { suffix = 'q', options = {} },
treesitter = { suffix = 't', options = {} },
undo = { suffix = 'u', options = {} },
window = { suffix = 'w', options = {} },
yank = { suffix = 'y', options = {} },
}