this repo has no description
at main 812 lines 39 kB view raw
1-- ┌────────────────────┐ 2-- │ MINI configuration │ 3-- └────────────────────┘ 4-- 5-- This file contains configuration of the MINI parts of the config. 6-- It contains only configs for the 'mini.nvim' plugin (installed in 'init.lua'). 7-- 8-- 'mini.nvim' is a library of modules. Each is enabled independently via 9-- `require('mini.xxx').setup()` convention. It creates all intended side effects: 10-- mappings, autocommands, highlight groups, etc. It also creates a global 11-- `MiniXxx` table that can be later used to access module's features. 12-- 13-- Every module's `setup()` function accepts an optional `config` table to 14-- adjust its behavior. See the structure of this table at `:h MiniXxx.config`. 15-- 16-- See `:h mini.nvim-general-principles` for more general principles. 17-- 18-- Here each module's `setup()` has a brief explanation of what the module is for, 19-- its usage examples (uses Leader mappings from 'plugin/20_keymaps.lua'), and 20-- possible directions for more info. 21-- For more info about a module see its help page (`:h mini.xxx` for 'mini.xxx'). 22 23-- To minimize the time until first screen draw, modules are enabled in two steps: 24-- - Step one enables everything that is needed for first draw with `now()`. 25-- Sometimes is needed only if Neovim is started as `nvim -- path/to/file`. 26-- - Everything else is delayed until the first draw with `later()`. 27local now, later = MiniDeps.now, MiniDeps.later 28local now_if_args = Config.now_if_args 29 30-- Step one =================================================================== 31-- Enable 'miniwinter' color scheme. It comes with 'mini.nvim' and uses 'mini.hues'. 32-- 33-- See also: 34-- - `:h mini.nvim-color-schemes` - list of other color schemes 35-- - `:h MiniHues-examples` - how to define highlighting with 'mini.hues' 36-- - 'plugin/40_plugins.lua' honorable mentions - other good color schemes 37-- now(function() vim.cmd('colorscheme miniwinter') end) 38now(function() vim.cmd('colorscheme github_dark_default') end) 39 40-- You can try these other 'mini.hues'-based color schemes (uncomment with `gcc`): 41-- now(function() vim.cmd('colorscheme minispring') end) 42-- now(function() vim.cmd('colorscheme minisummer') end) 43-- now(function() vim.cmd('colorscheme miniautumn') end) 44-- now(function() vim.cmd('colorscheme randomhue') end) 45 46-- Common configuration presets. Example usage: 47-- - `<C-s>` in Insert mode - save and go to Normal mode 48-- - `go` / `gO` - insert empty line before/after in Normal mode 49-- - `gy` / `gp` - copy / paste from system clipboard 50-- - `\` + key - toggle common options. Like `\h` toggles highlighting search. 51-- - `<C-hjkl>` (four combos) - navigate between windows. 52-- - `<M-hjkl>` in Insert/Command mode - navigate in that mode. 53-- 54-- See also: 55-- - `:h MiniBasics.config.options` - list of adjusted options 56-- - `:h MiniBasics.config.mappings` - list of created mappings 57-- - `:h MiniBasics.config.autocommands` - list of created autocommands 58now(function() 59 require('mini.basics').setup({ 60 -- Manage options in 'plugin/10_options.lua' for didactic purposes 61 options = { basic = false }, 62 mappings = { 63 -- Create `<C-hjkl>` mappings for window navigation 64 windows = true, 65 -- Create `<M-hjkl>` mappings for navigation in Insert and Command modes 66 move_with_alt = true, 67 }, 68 }) 69end) 70 71-- Icon provider. Usually no need to use manually. It is used by plugins like 72-- 'mini.pick', 'mini.files', 'mini.statusline', and others. 73now(function() 74 -- Set up to not prefer extension-based icon for some extensions 75 local ext3_blocklist = { scm = true, txt = true, yml = true } 76 local ext4_blocklist = { json = true, yaml = true } 77 require('mini.icons').setup({ 78 use_file_extension = function(ext, _) 79 return not (ext3_blocklist[ext:sub(-3)] or ext4_blocklist[ext:sub(-4)]) 80 end, 81 }) 82 83 -- Mock 'nvim-tree/nvim-web-devicons' for plugins without 'mini.icons' support. 84 -- Not needed for 'mini.nvim' or MiniMax, but might be useful for others. 85 later(MiniIcons.mock_nvim_web_devicons) 86 87 -- Add LSP kind icons. Useful for 'mini.completion'. 88 later(MiniIcons.tweak_lsp_kind) 89end) 90 91 92-- Notifications provider. Shows all kinds of notifications in the upper right 93-- corner (by default). Example usage: 94-- - `:h vim.notify()` - show notification (hides automatically) 95-- - `<Leader>en` - show notification history 96-- 97-- See also: 98-- - `:h MiniNotify.config` for some of common configuration examples. 99now(function() require('mini.notify').setup() end) 100 101-- Session management. A thin wrapper around `:h mksession` that consistently 102-- manages session files. Example usage: 103-- - `<Leader>sn` - start new session 104-- - `<Leader>sr` - read previously started session 105-- - `<Leader>sd` - delete previously started session 106now(function() require('mini.sessions').setup() end) 107 108-- Start screen. This is what is shown when you open Neovim like `nvim`. 109-- Example usage: 110-- - Type prefix keys to limit available candidates 111-- - Navigate down/up with `<C-n>` and `<C-p>` 112-- - Press `<CR>` to select an entry 113-- 114-- See also: 115-- - `:h MiniStarter-example-config` - non-default config examples 116-- - `:h MiniStarter-lifecycle` - how to work with Starter buffer 117now(function() require('mini.starter').setup() end) 118 119-- Statusline. Sets `:h 'statusline'` to show more info in a line below window. 120-- Example usage: 121-- - Left most section indicates current mode (text + highlighting). 122-- - Second from left section shows "developer info": Git, diff, diagnostics, LSP. 123-- - Center section shows the name of displayed buffer. 124-- - Second to right section shows more buffer info. 125-- - Right most section shows current cursor coordinates and search results. 126-- 127-- See also: 128-- - `:h MiniStatusline-example-content` - example of default content. Use it to 129-- configure a custom statusline by setting `config.content.active` function. 130now(function() require('mini.statusline').setup() end) 131 132-- Tabline. Sets `:h 'tabline'` to show all listed buffers in a line at the top. 133-- Buffers are ordered as they were created. Navigate with `[b` and `]b`. 134now(function() require('mini.tabline').setup() end) 135 136 137-- Step one or two ============================================================ 138-- Load now if Neovim is started like `nvim -- path/to/file`, otherwise - later. 139-- This ensures a correct behavior for files opened during startup. 140 141-- Completion and signature help. Implements async "two stage" autocompletion: 142-- - Based on attached LSP servers that support completion. 143-- - Fallback (based on built-in keyword completion) if there is no LSP candidates. 144-- 145-- Example usage in Insert mode with attached LSP: 146-- - Start typing text that should be recognized by LSP (like variable name). 147-- - After 100ms a popup menu with candidates appears. 148-- - Press `<Tab>` / `<S-Tab>` to navigate down/up the list. These are set up 149-- in 'mini.keymap'. You can also use `<C-n>` / `<C-p>`. 150-- - During navigation there is an info window to the right showing extra info 151-- that the LSP server can provide about the candidate. It appears after the 152-- candidate stays selected for 100ms. Use `<C-f>` / `<C-b>` to scroll it. 153-- - Navigating to an entry also changes buffer text. If you are happy with it, 154-- keep typing after it. To discard completion completely, press `<C-e>`. 155-- - After pressing special trigger(s), usually `(`, a window appears that shows 156-- the signature of the current function/method. It gets updated as you type 157-- showing the currently active parameter. 158-- 159-- Example usage in Insert mode without an attached LSP or in places not 160-- supported by the LSP (like comments): 161-- - Start typing a word that is present in current or opened buffers. 162-- - After 100ms popup menu with candidates appears. 163-- - Navigate with `<Tab>` / `<S-Tab>` or `<C-n>` / `<C-p>`. This also updates 164-- buffer text. If happy with choice, keep typing. Stop with `<C-e>`. 165-- 166-- It also works with snippet candidates provided by LSP server. Best experience 167-- when paired with 'mini.snippets' (which is set up in this file). 168now_if_args(function() 169 -- Customize post-processing of LSP responses for a better user experience. 170 -- Don't show 'Text' suggestions (usually noisy) and show snippets last. 171 local process_items_opts = { kind_priority = { Text = -1, Snippet = 99 } } 172 local process_items = function(items, base) 173 return MiniCompletion.default_process_items(items, base, process_items_opts) 174 end 175 require('mini.completion').setup({ 176 lsp_completion = { 177 -- Without this config autocompletion is set up through `:h 'completefunc'`. 178 -- Although not needed, setting up through `:h 'omnifunc'` is cleaner 179 -- (sets up only when needed) and makes it possible to use `<C-u>`. 180 source_func = 'omnifunc', 181 auto_setup = false, 182 process_items = process_items, 183 }, 184 }) 185 186 -- Set 'omnifunc' for LSP completion only when needed. 187 local on_attach = function(ev) 188 vim.bo[ev.buf].omnifunc = 'v:lua.MiniCompletion.completefunc_lsp' 189 end 190 Config.new_autocmd('LspAttach', nil, on_attach, "Set 'omnifunc'") 191 192 -- Advertise to servers that Neovim now supports certain set of completion and 193 -- signature features through 'mini.completion'. 194 vim.lsp.config('*', { capabilities = MiniCompletion.get_lsp_capabilities() }) 195end) 196 197-- Navigate and manipulate file system 198-- 199-- Navigation is done using column view (Miller columns) to display nested 200-- directories, they are displayed in floating windows in top left corner. 201-- 202-- Manipulate files and directories by editing text as regular buffers. 203-- 204-- Example usage: 205-- - `<Leader>ed` - open current working directory 206-- - `<Leader>ef` - open directory of current file (needs to be present on disk) 207-- 208-- Basic navigation: 209-- - `l` - go in entry at cursor: navigate into directory or open file 210-- - `h` - go out of focused directory 211-- - Navigate window as any regular buffer 212-- - Press `g?` inside explorer to see more mappings 213-- 214-- Basic manipulation: 215-- - After any following action, press `=` in Normal mode to synchronize, read 216-- carefully about actions, press `y` or `<CR>` to confirm 217-- - New entry: press `o` and type its name; end with `/` to create directory 218-- - Rename: press `C` and type new name 219-- - Delete: type `dd` 220-- - Move/copy: type `dd`/`yy`, navigate to target directory, press `p` 221-- 222-- See also: 223-- - `:h MiniFiles-navigation` - more details about how to navigate 224-- - `:h MiniFiles-manipulation` - more details about how to manipulate 225-- - `:h MiniFiles-examples` - examples of common setups 226now_if_args(function() 227 -- Enable directory/file preview 228 require('mini.files').setup({ windows = { preview = true } }) 229 230 -- Add common bookmarks for every explorer. Example usage inside explorer: 231 -- - `'c` to navigate into your config directory 232 -- - `g?` to see available bookmarks 233 local add_marks = function() 234 MiniFiles.set_bookmark('c', vim.fn.stdpath('config'), { desc = 'Config' }) 235 local minideps_plugins = vim.fn.stdpath('data') .. '/site/pack/deps/opt' 236 MiniFiles.set_bookmark('p', minideps_plugins, { desc = 'Plugins' }) 237 MiniFiles.set_bookmark('w', vim.fn.getcwd, { desc = 'Working directory' }) 238 end 239 Config.new_autocmd('User', 'MiniFilesExplorerOpen', add_marks, 'Add bookmarks') 240end) 241 242-- Miscellaneous small but useful functions. Example usage: 243-- - `<Leader>oz` - toggle between "zoomed" and regular view of current buffer 244-- - `<Leader>or` - resize window to its "editable width" 245-- - `:lua put_text(vim.lsp.get_clients())` - put output of a function below 246-- cursor in current buffer. Useful for a detailed exploration. 247-- - `:lua put(MiniMisc.stat_summary(MiniMisc.bench_time(f, 100)))` - run 248-- function `f` 100 times and report statistical summary of execution times 249now_if_args(function() 250 -- Makes `:h MiniMisc.put()` and `:h MiniMisc.put_text()` public 251 require('mini.misc').setup() 252 253 -- Change current working directory based on the current file path. It 254 -- searches up the file tree until the first root marker ('.git' or 'Makefile') 255 -- and sets their parent directory as a current directory. 256 -- This is helpful when simultaneously dealing with files from several projects. 257 MiniMisc.setup_auto_root() 258 259 -- Restore latest cursor position on file open 260 MiniMisc.setup_restore_cursor() 261 262 -- Synchronize terminal emulator background with Neovim's background to remove 263 -- possibly different color padding around Neovim instance 264 MiniMisc.setup_termbg_sync() 265end) 266 267-- Step two =================================================================== 268 269-- Extra 'mini.nvim' functionality. 270-- 271-- See also: 272-- - `:h MiniExtra.pickers` - pickers. Most are mapped in `<Leader>f` group. 273-- Calling `setup()` makes 'mini.pick' respect 'mini.extra' pickers. 274-- - `:h MiniExtra.gen_ai_spec` - 'mini.ai' textobject specifications 275-- - `:h MiniExtra.gen_highlighter` - 'mini.hipatterns' highlighters 276later(function() require('mini.extra').setup() end) 277 278-- Extend and create a/i textobjects, like `:h a(`, `:h a'`, and more). 279-- Contains not only `a` and `i` type of textobjects, but also their "next" and 280-- "last" variants that will explicitly search for textobjects after and before 281-- cursor. Example usage: 282-- - `ci)` - *c*hange *i*inside parenthesis (`)`) 283-- - `di(` - *d*elete *i*inside padded parenthesis (`(`) 284-- - `yaq` - *y*ank *a*round *q*uote (any of "", '', or ``) 285-- - `vif` - *v*isually select *i*inside *f*unction call 286-- - `cina` - *c*hange *i*nside *n*ext *a*rgument 287-- - `valaala` - *v*isually select *a*round *l*ast (i.e. previous) *a*rgument 288-- and then again reselect *a*round new *l*ast *a*rgument 289-- 290-- See also: 291-- - `:h text-objects` - general info about what textobjects are 292-- - `:h MiniAi-builtin-textobjects` - list of all supported textobjects 293-- - `:h MiniAi-textobject-specification` - examples of custom textobjects 294later(function() 295 local ai = require('mini.ai') 296 ai.setup({ 297 -- 'mini.ai' can be extended with custom textobjects 298 custom_textobjects = { 299 -- Make `aB` / `iB` act on around/inside whole *b*uffer 300 B = MiniExtra.gen_ai_spec.buffer(), 301 -- For more complicated textobjects that require structural awareness, 302 -- use tree-sitter. This example makes `aF`/`iF` mean around/inside function 303 -- definition (not call). See `:h MiniAi.gen_spec.treesitter()` for details. 304 F = ai.gen_spec.treesitter({ a = '@function.outer', i = '@function.inner' }), 305 }, 306 307 -- 'mini.ai' by default mostly mimics built-in search behavior: first try 308 -- to find textobject covering cursor, then try to find to the right. 309 -- Although this works in most cases, some are confusing. It is more robust to 310 -- always try to search only covering textobject and explicitly ask to search 311 -- for next (`an`/`in`) or last (`al`/`il`). 312 -- Try this. If you don't like it - delete next line and this comment. 313 search_method = 'cover', 314 }) 315end) 316 317-- Align text interactively. Example usage: 318-- - `gaip,` - `ga` (align operator) *i*nside *p*aragraph by comma 319-- - `gAip` - start interactive alignment on the paragraph. Choose how to 320-- split, justify, and merge string parts. Press `<CR>` to make it permanent, 321-- press `<Esc>` to go back to initial state. 322-- 323-- See also: 324-- - `:h MiniAlign-example` - hands-on list of examples to practice aligning 325-- - `:h MiniAlign.gen_step` - list of support step customizations 326-- - `:h MiniAlign-algorithm` - how alignment is done on algorithmic level 327later(function() require('mini.align').setup() end) 328 329-- Animate common Neovim actions. Like cursor movement, scroll, window resize, 330-- window open, window close. Animations are done based on Neovim events and 331-- don't require custom mappings. 332-- 333-- It is not enabled by default because its effects are a matter of taste. 334-- Also scroll and resize have some unwanted side effects (see `:h mini.animate`). 335-- Uncomment next line (use `gcc`) to enable. 336-- later(function() require('mini.animate').setup() end) 337 338-- Go forward/backward with square brackets. Implements consistent sets of mappings 339-- for selected targets (like buffers, diagnostic, quickfix list entries, etc.). 340-- Example usage: 341-- - `]b` - go to next buffer 342-- - `[j` - go to previous jump inside current buffer 343-- - `[Q` - go to first entry of quickfix list 344-- - `]X` - go to last conflict marker in a buffer 345-- 346-- See also: 347-- - `:h MiniBracketed` - overall mapping design and list of targets 348later(function() require('mini.bracketed').setup() end) 349 350-- Remove buffers. Opened files occupy space in tabline and buffer picker. 351-- When not needed, they can be removed. Example usage: 352-- - `<Leader>bw` - completely wipeout current buffer (see `:h :bwipeout`) 353-- - `<Leader>bW` - completely wipeout current buffer even if it has changes 354-- - `<Leader>bd` - delete current buffer (see `:h :bdelete`) 355later(function() require('mini.bufremove').setup() end) 356 357-- Show next key clues in a bottom right window. Requires explicit opt-in for 358-- keys that act as clue trigger. Example usage: 359-- - Press `<Leader>` and wait for 1 second. A window with information about 360-- next available keys should appear. 361-- - Press one of the listed keys. Window updates immediately to show information 362-- about new next available keys. You can press `<BS>` to go back in key sequence. 363-- - Press keys until they resolve into some mapping. 364-- 365-- Note: it is designed to work in buffers for normal files. It doesn't work in 366-- special buffers (like for 'mini.starter' or 'mini.files') to not conflict 367-- with its local mappings. 368-- 369-- See also: 370-- - `:h MiniClue-examples` - examples of common setups 371-- - `:h MiniClue.ensure_buf_triggers()` - use it to enable triggers in buffer 372-- - `:h MiniClue.set_mapping_desc()` - change mapping description not from config 373later(function() 374 local miniclue = require('mini.clue') 375 -- stylua: ignore 376 miniclue.setup({ 377 -- Define which clues to show. By default shows only clues for custom mappings 378 -- (uses `desc` field from the mapping; takes precedence over custom clue). 379 clues = { 380 -- This is defined in 'plugin/20_keymaps.lua' with Leader group descriptions 381 Config.leader_group_clues, 382 miniclue.gen_clues.builtin_completion(), 383 miniclue.gen_clues.g(), 384 miniclue.gen_clues.marks(), 385 miniclue.gen_clues.registers(), 386 miniclue.gen_clues.square_brackets(), 387 -- This creates a submode for window resize mappings. Try the following: 388 -- - Press `<C-w>s` to make a window split. 389 -- - Press `<C-w>+` to increase height. Clue window still shows clues as if 390 -- `<C-w>` is pressed again. Keep pressing just `+` to increase height. 391 -- Try pressing `-` to decrease height. 392 -- - Stop submode either by `<Esc>` or by any key that is not in submode. 393 miniclue.gen_clues.windows({ submode_resize = true }), 394 miniclue.gen_clues.z(), 395 }, 396 -- Explicitly opt-in for set of common keys to trigger clue window 397 triggers = { 398 { mode = { 'n', 'x' }, keys = '<Leader>' }, -- Leader triggers 399 { mode = 'n', keys = '\\' }, -- mini.basics 400 { mode = { 'n', 'x' }, keys = '[' }, -- mini.bracketed 401 { mode = { 'n', 'x' }, keys = ']' }, 402 { mode = 'i', keys = '<C-x>' }, -- Built-in completion 403 { mode = { 'n', 'x' }, keys = 'g' }, -- `g` key 404 { mode = { 'n', 'x' }, keys = "'" }, -- Marks 405 { mode = { 'n', 'x' }, keys = '`' }, 406 { mode = { 'n', 'x' }, keys = '"' }, -- Registers 407 { mode = { 'i', 'c' }, keys = '<C-r>' }, 408 { mode = 'n', keys = '<C-w>' }, -- Window commands 409 { mode = { 'n', 'x' }, keys = 's' }, -- `s` key (mini.surround, etc.) 410 { mode = { 'n', 'x' }, keys = 'z' }, -- `z` key 411 }, 412 }) 413end) 414 415-- Command line tweaks. Improves command line editing with: 416-- - Autocompletion. Basically an automated `:h cmdline-completion`. 417-- - Autocorrection of words as-you-type. Like `:W`->`:w`, `:lau`->`:lua`, etc. 418-- - Autopeek command range (like line number at the start) as-you-type. 419later(function() require('mini.cmdline').setup() end) 420 421-- Tweak and save any color scheme. Contains utility functions to work with 422-- color spaces and color schemes. Example usage: 423-- - `:Colorscheme default` - switch with animation to the default color scheme 424-- 425-- See also: 426-- - `:h MiniColors.interactive()` - interactively tweak color scheme 427-- - `:h MiniColors-recipes` - common recipes to use during interactive tweaking 428-- - `:h MiniColors.convert()` - convert between color spaces 429-- - `:h MiniColors-color-spaces` - list of supported color sapces 430-- 431-- It is not enabled by default because it is not really needed on a daily basis. 432-- Uncomment next line (use `gcc`) to enable. 433-- later(function() require('mini.colors').setup() end) 434 435-- Comment lines. Provides functionality to work with commented lines. 436-- Uses `:h 'commentstring'` option to infer comment structure. 437-- Example usage: 438-- - `gcip` - toggle comment (`gc`) *i*inside *p*aragraph 439-- - `vapgc` - *v*isually select *a*round *p*aragraph and toggle comment (`gc`) 440-- - `gcgc` - uncomment (`gc`, operator) comment block at cursor (`gc`, textobject) 441-- 442-- The built-in `:h commenting` is based on 'mini.comment'. Yet this module is 443-- still enabled as it provides more customization opportunities. 444later(function() require('mini.comment').setup() end) 445 446-- Autohighlight word under cursor with a customizable delay. 447-- Word boundaries are defined based on `:h 'iskeyword'` option. 448-- 449-- It is not enabled by default because its effects are a matter of taste. 450-- Uncomment next line (use `gcc`) to enable. 451-- later(function() require('mini.cursorword').setup() end) 452 453-- Work with diff hunks that represent the difference between the buffer text and 454-- some reference text set by a source. Default source uses text from Git index. 455-- Also provides summary info used in developer section of 'mini.statusline'. 456-- Example usage: 457-- - `ghip` - apply hunks (`gh`) within *i*nside *p*aragraph 458-- - `gHG` - reset hunks (`gH`) from cursor until end of buffer (`G`) 459-- - `ghgh` - apply (`gh`) hunk at cursor (`gh`) 460-- - `gHgh` - reset (`gH`) hunk at cursor (`gh`) 461-- - `<Leader>go` - toggle overlay 462-- 463-- See also: 464-- - `:h MiniDiff-overview` - overview of how module works 465-- - `:h MiniDiff-diff-summary` - available summary information 466-- - `:h MiniDiff.gen_source` - available built-in sources 467later(function() require('mini.diff').setup() end) 468 469-- Git integration for more straightforward Git actions based on Neovim's state. 470-- It is not meant as a fully featured Git client, only to provide helpers that 471-- integrate better with Neovim. Example usage: 472-- - `<Leader>gs` - show information at cursor 473-- - `<Leader>gd` - show unstaged changes as a patch in separate tabpage 474-- - `<Leader>gL` - show Git log of current file 475-- - `:Git help git` - show output of `git help git` inside Neovim 476-- 477-- See also: 478-- - `:h MiniGit-examples` - examples of common setups 479-- - `:h :Git` - more details about `:Git` user command 480-- - `:h MiniGit.show_at_cursor()` - what information at cursor is shown 481later(function() require('mini.git').setup() end) 482 483-- Highlight patterns in text. Like `TODO`/`NOTE` or color hex codes. 484-- Example usage: 485-- - `:Pick hipatterns` - pick among all highlighted patterns 486-- 487-- See also: 488-- - `:h MiniHipatterns-examples` - examples of common setups 489later(function() 490 local hipatterns = require('mini.hipatterns') 491 local hi_words = MiniExtra.gen_highlighter.words 492 hipatterns.setup({ 493 highlighters = { 494 -- Highlight a fixed set of common words. Will be highlighted in any place, 495 -- not like "only in comments". 496 fixme = hi_words({ 'FIXME', 'Fixme', 'fixme' }, 'MiniHipatternsFixme'), 497 hack = hi_words({ 'HACK', 'Hack', 'hack' }, 'MiniHipatternsHack'), 498 todo = hi_words({ 'TODO', 'Todo', 'todo' }, 'MiniHipatternsTodo'), 499 note = hi_words({ 'NOTE', 'Note', 'note' }, 'MiniHipatternsNote'), 500 501 -- Highlight hex color string (#aabbcc) with that color as a background 502 hex_color = hipatterns.gen_highlighter.hex_color(), 503 }, 504 }) 505end) 506 507-- Visualize and work with indent scope. It visualizes indent scope "at cursor" 508-- with animated vertical line. Provides relevant motions and textobjects. 509-- Example usage: 510-- - `cii` - *c*hange *i*nside *i*ndent scope 511-- - `Vaiai` - *V*isually select *a*round *i*ndent scope and then again 512-- reselect *a*round new *i*indent scope 513-- - `[i` / `]i` - navigate to scope's top / bottom 514-- 515-- See also: 516-- - `:h MiniIndentscope.gen_animation` - available animation rules 517later(function() require('mini.indentscope').setup() end) 518 519-- Jump to next/previous single character. It implements "smarter `fFtT` keys" 520-- (see `:h f`) that work across multiple lines, start "jumping mode", and 521-- highlight all target matches. Example usage: 522-- - `fxff` - move *f*orward onto next character "x", then next, and next again 523-- - `dt)` - *d*elete *t*ill next closing parenthesis (`)`) 524later(function() require('mini.jump').setup() end) 525 526-- Jump within visible lines to pre-defined spots via iterative label filtering. 527-- Spots are computed by a configurable spotter function. Example usage: 528-- - Lock eyes on desired location to jump 529-- - `<CR>` - start jumping; this shows character labels over target spots 530-- - Type character that appears over desired location; number of target spots 531-- should be reduced 532-- - Keep typing labels until target spot is unique to perform the jump 533-- 534-- See also: 535-- - `:h MiniJump2d.gen_spotter` - list of available spotters 536later(function() require('mini.jump2d').setup() end) 537 538-- Special key mappings. Provides helpers to map: 539-- - Multi-step actions. Apply action 1 if condition is met; else apply 540-- action 2 if condition is met; etc. 541-- - Combos. Sequence of keys where each acts immediately plus execute extra 542-- action if all are typed fast enough. Useful for Insert mode mappings to not 543-- introduce delay when typing mapping keys without intention to execute action. 544-- 545-- See also: 546-- - `:h MiniKeymap-examples` - examples of common setups 547-- - `:h MiniKeymap.map_multistep()` - map multi-step action 548-- - `:h MiniKeymap.map_combo()` - map combo 549later(function() 550 require('mini.keymap').setup() 551 -- Navigate 'mini.completion' menu with `<Tab>` / `<S-Tab>` 552 MiniKeymap.map_multistep('i', '<Tab>', { 'pmenu_next' }) 553 MiniKeymap.map_multistep('i', '<S-Tab>', { 'pmenu_prev' }) 554 -- On `<CR>` try to accept current completion item, fall back to accounting 555 -- for pairs from 'mini.pairs' 556 MiniKeymap.map_multistep('i', '<CR>', { 'pmenu_accept', 'minipairs_cr' }) 557 -- On `<BS>` just try to account for pairs from 'mini.pairs' 558 MiniKeymap.map_multistep('i', '<BS>', { 'minipairs_bs' }) 559end) 560 561-- Window with text overview. It is displayed on the right hand side. Can be used 562-- for quick overview and navigation. Hidden by default. Example usage: 563-- - `<Leader>mt` - toggle map window 564-- - `<Leader>mf` - focus on the map for fast navigation 565-- - `<Leader>ms` - change map's side (if it covers something underneath) 566-- 567-- See also: 568-- - `:h MiniMap.gen_encode_symbols` - list of symbols to use for text encoding 569-- - `:h MiniMap.gen_integration` - list of integrations to show in the map 570-- 571-- NOTE: Might introduce lag on very big buffers (10000+ lines) 572later(function() 573 local map = require('mini.map') 574 map.setup({ 575 -- Use Braille dots to encode text 576 symbols = { encode = map.gen_encode_symbols.dot('4x2') }, 577 -- Show built-in search matches, 'mini.diff' hunks, and diagnostic entries 578 integrations = { 579 map.gen_integration.builtin_search(), 580 map.gen_integration.diff(), 581 map.gen_integration.diagnostic(), 582 }, 583 }) 584 585 -- Map built-in navigation characters to force map refresh 586 for _, key in ipairs({ 'n', 'N', '*', '#' }) do 587 local rhs = key 588 -- Also open enough folds when jumping to the next match 589 .. 'zv' 590 .. '<Cmd>lua MiniMap.refresh({}, { lines = false, scrollbar = false })<CR>' 591 vim.keymap.set('n', key, rhs) 592 end 593end) 594 595-- Move any selection in any direction. Example usage in Normal mode: 596-- - `<M-j>`/`<M-k>` - move current line down / up 597-- - `<M-h>`/`<M-l>` - decrease / increase indent of current line 598-- 599-- Example usage in Visual mode: 600-- - `<M-h>`/`<M-j>`/`<M-k>`/`<M-l>` - move selection left/down/up/right 601later(function() require('mini.move').setup() end) 602 603-- Text edit operators. All operators have mappings for: 604-- - Regular operator (waits for motion/textobject to use) 605-- - Current line action (repeat second character of operator to activate) 606-- - Act on visual selection (type operator in Visual mode) 607-- 608-- Example usage: 609-- - `griw` - replace (`gr`) *i*inside *w*ord 610-- - `gmm` - multiple/duplicate (`gm`) current line (extra `m`) 611-- - `vipgs` - *v*isually select *i*nside *p*aragraph and sort it (`gs`) 612-- - `gxiww.` - exchange (`gx`) *i*nside *w*ord with next word (`w` to navigate 613-- to it and `.` to repeat exchange operator) 614-- - `g==` - execute current line as Lua code and replace with its output. 615-- For example, typing `g==` over line `vim.lsp.get_clients()` shows 616-- information about all available LSP clients. 617-- 618-- See also: 619-- - `:h MiniOperators-mappings` - overview of how mappings are created 620-- - `:h MiniOperators-overview` - overview of present operators 621later(function() 622 require('mini.operators').setup() 623 624 -- Create mappings for swapping adjacent arguments. Notes: 625 -- - Relies on `a` argument textobject from 'mini.ai'. 626 -- - It is not 100% reliable, but mostly works. 627 -- - It overrides `:h (` and `:h )`. 628 -- Explanation: `gx`-`ia`-`gx`-`ila` <=> exchange current and last argument 629 -- Usage: when on `a` in `(aa, bb)` press `)` followed by `(`. 630 vim.keymap.set('n', '(', 'gxiagxila', { remap = true, desc = 'Swap arg left' }) 631 vim.keymap.set('n', ')', 'gxiagxina', { remap = true, desc = 'Swap arg right' }) 632end) 633 634-- Autopairs functionality. Insert pair when typing opening character and go over 635-- right character if it is already to cursor's right. Also provides mappings for 636-- `<CR>` and `<BS>` to perform extra actions when inside pair. 637-- Example usage in Insert mode: 638-- - `(` - insert "()" and put cursor between them 639-- - `)` when there is ")" to the right - jump over ")" without inserting new one 640-- - `<C-v>(` - always insert a single "(" literally. This is useful since 641-- 'mini.pairs' doesn't provide particularly smart behavior, like auto balancing 642later(function() 643 -- Create pairs not only in Insert, but also in Command line mode 644 require('mini.pairs').setup({ modes = { command = true } }) 645end) 646 647-- Pick anything with single window layout and fast matching. This is one of 648-- the main usability improvements as it powers a lot of "find things quickly" 649-- workflows. How to use a picker: 650-- - Start picker, usually with `:Pick <picker-name>` command. Like `:Pick files`. 651-- It shows a single window in the bottom left corner filled with possible items 652-- to choose from. Current item has special full line highlighting. 653-- At the top there is a current query used to filter+sort items. 654-- - Type characters (appear at top) to narrow down items. There is fuzzy matching: 655-- characters may not match one-by-one, but they should be in correct order. 656-- - Navigate down/up with `<C-n>`/`<C-p>`. 657-- - Press `<Tab>` to show item's preview. `<Tab>` again goes back to items. 658-- - Press `<S-Tab>` to show picker's info. `<S-Tab>` again goes back to items. 659-- - Press `<CR>` to choose an item. The exact action depends on the picker: `files` 660-- picker opens a selected file, `help` picker opens help page on selected tag. 661-- To close picker without choosing an item, press `<Esc>`. 662-- 663-- Example usage: 664-- - `<Leader>ff` - *f*ind *f*iles; for best performance requires `ripgrep` 665-- - `<Leader>fg` - *f*ind inside files (a.k.a. "to *g*rep"); requires `ripgrep` 666-- - `<Leader>fh` - *f*ind *h*elp tag 667-- - `<Leader>fr` - *r*esume latest picker 668-- - `:h vim.ui.select()` - implemented with 'mini.pick' 669-- 670-- See also: 671-- - `:h MiniPick-overview` - overview of picker functionality 672-- - `:h MiniPick-examples` - examples of common setups 673-- - `:h MiniPick.builtin` and `:h MiniExtra.pickers` - available pickers; 674-- Execute one either with Lua function, `:Pick <picker-name>` command, or 675-- one of `<Leader>f` mappings defined in 'plugin/20_keymaps.lua' 676later(function() require('mini.pick').setup() end) 677 678-- Manage and expand snippets (templates for a frequently used text). 679-- Typical workflow is to type snippet's (configurable) prefix and expand it 680-- into a snippet session. 681-- 682-- How to manage snippets: 683-- - 'mini.snippets' itself doesn't come with preconfigured snippets. Instead there 684-- is a flexible system of how snippets are prepared before expanding. 685-- They can come from pre-defined path on disk, 'snippets/' directories inside 686-- config or plugins, defined inside `setup()` call directly. 687-- - This config, however, does come with snippet configuration: 688-- - 'snippets/global.json' is a file with global snippets that will be 689-- available in any buffer 690-- - 'after/snippets/lua.json' defines personal snippets for Lua language 691-- - 'friendly-snippets' plugin configured in 'plugin/40_plugins.lua' provides 692-- a collection of language snippets 693-- 694-- How to expand a snippet in Insert mode: 695-- - If you know snippet's prefix, type it as a word and press `<C-j>`. Snippet's 696-- body should be inserted instead of the prefix. 697-- - If you don't remember snippet's prefix, type only part of it (or none at all) 698-- and press `<C-j>`. It should show picker with all snippets that have prefixes 699-- matching typed characters (or all snippets if none was typed). 700-- Choose one and its body should be inserted instead of previously typed text. 701-- 702-- How to navigate during snippet session: 703-- - Snippets can contain tabstops - places for user to interactively adjust text. 704-- Each tabstop is highlighted depending on session progression - whether tabstop 705-- is current, was or was not visited. If tabstop doesn't yet have text, it is 706-- visualized with special "ghost" inline text: • and ∎ by default. 707-- - Type necessary text at current tabstop and navigate to next/previous one 708-- by pressing `<C-l>` / `<C-h>`. 709-- - Repeat previous step until you reach special final tabstop, usually denoted 710-- by ∎ symbol. If you spotted a mistake in an earlier tabstop, navigate to it 711-- and return back to the final tabstop. 712-- - To end a snippet session when at final tabstop, keep typing or go into 713-- Normal mode. To force end snippet session, press `<C-c>`. 714-- 715-- See also: 716-- - `:h MiniSnippets-overview` - overview of how module works 717-- - `:h MiniSnippets-examples` - examples of common setups 718-- - `:h MiniSnippets-session` - details about snippet session 719-- - `:h MiniSnippets.gen_loader` - list of available loaders 720later(function() 721 -- Define language patterns to work better with 'friendly-snippets' 722 local latex_patterns = { 'latex/**/*.json', '**/latex.json' } 723 local lang_patterns = { 724 tex = latex_patterns, 725 plaintex = latex_patterns, 726 -- Recognize special injected language of markdown tree-sitter parser 727 markdown_inline = { 'markdown.json' }, 728 } 729 730 local snippets = require('mini.snippets') 731 local config_path = vim.fn.stdpath('config') 732 snippets.setup({ 733 snippets = { 734 -- Always load 'snippets/global.json' from config directory 735 snippets.gen_loader.from_file(config_path .. '/snippets/global.json'), 736 -- Load from 'snippets/' directory of plugins, like 'friendly-snippets' 737 snippets.gen_loader.from_lang({ lang_patterns = lang_patterns }), 738 }, 739 }) 740 741 -- By default snippets available at cursor are not shown as candidates in 742 -- 'mini.completion' menu. This requires a dedicated in-process LSP server 743 -- that will provide them. To have that, uncomment next line (use `gcc`). 744 -- MiniSnippets.start_lsp_server() 745end) 746 747-- Split and join arguments (regions inside brackets between allowed separators). 748-- It uses Lua patterns to find arguments, which means it works in comments and 749-- strings but can be not as accurate as tree-sitter based solutions. 750-- Each action can be configured with hooks (like add/remove trailing comma). 751-- Example usage: 752-- - `gS` - toggle between joined (all in one line) and split (each on a separate 753-- line and indented) arguments. It is dot-repeatable (see `:h .`). 754-- 755-- See also: 756-- - `:h MiniSplitjoin.gen_hook` - list of available hooks 757later(function() require('mini.splitjoin').setup() end) 758 759-- Surround actions: add/delete/replace/find/highlight. Working with surroundings 760-- is surprisingly common: surround word with quotes, replace `)` with `]`, etc. 761-- This module comes with many built-in surroundings, each identified by a single 762-- character. It searches only for surrounding that covers cursor and comes with 763-- a special "next" / "last" versions of actions to search forward or backward 764-- (just like 'mini.ai'). All text editing actions are dot-repeatable (see `:h .`). 765-- 766-- Example usage (this may feel intimidating at first, but after practice it 767-- becomes second nature during text editing): 768-- - `saiw)` - *s*urround *a*dd for *i*nside *w*ord parenthesis (`)`) 769-- - `sdf` - *s*urround *d*elete *f*unction call (like `f(var)` -> `var`) 770-- - `srb[` - *s*urround *r*eplace *b*racket (any of [], (), {}) with padded `[` 771-- - `sf*` - *s*urround *f*ind right part of `*` pair (like bold in markdown) 772-- - `shf` - *s*urround *h*ighlight current *f*unction call 773-- - `srn{{` - *s*urround *r*eplace *n*ext curly bracket `{` with padded `{` 774-- - `sdl'` - *s*urround *d*elete *l*ast quote pair (`'`) 775-- - `vaWsa<Space>` - *v*isually select *a*round *W*ORD and *s*urround *a*dd 776-- spaces (`<Space>`) 777-- 778-- See also: 779-- - `:h MiniSurround-builtin-surroundings` - list of all supported surroundings 780-- - `:h MiniSurround-surrounding-specification` - examples of custom surroundings 781-- - `:h MiniSurround-vim-surround-config` - alternative set of action mappings 782later(function() 783 require('mini.surround').setup({ 784 custom_surroundings = { 785 ['l'] = { output = { left = '[', right = ']()' } } 786 } 787 }) 788end) 789 790-- Highlight and remove trailspace. Temporarily stops highlighting in Insert mode 791-- to reduce noise when typing. Example usage: 792-- - `<Leader>ot` - trim all trailing whitespace in a buffer 793later(function() require('mini.trailspace').setup() end) 794 795-- Track and reuse file system visits. Every file/directory visit is persistently 796-- tracked on disk to later reuse: show in special frecency order, etc. It also 797-- supports adding labels to visited paths to quickly navigate between them. 798-- Example usage: 799-- - `<Leader>fv` - find across all visits 800-- - `<Leader>vv` / `<Leader>vV` - add/remove special "core" label to current file 801-- - `<Leader>vc` / `<Leader>vC` - show files with "core" label; all or added within 802-- current working directory 803-- 804-- See also: 805-- - `:h MiniVisits-overview` - overview of how module works 806-- - `:h MiniVisits-examples` - examples of common setups 807later(function() require('mini.visits').setup() end) 808 809-- Not mentioned here, but can be useful: 810-- - 'mini.doc' - needed only for plugin developers. 811-- - 'mini.fuzzy' - not really needed on a daily basis. 812-- - 'mini.test' - needed only for plugin developers.