-- Clone 'mini.nvim' manually in a way that it gets managed by 'mini.deps' local path_package = vim.fn.stdpath('data') .. '/site/' local mini_path = path_package .. 'pack/deps/start/mini.nvim' if not (vim.uv or vim.loop).fs_stat(mini_path) then vim.cmd('echo "Installing [`mini.nvim`](../doc/mini-nvim.qmd#mini.nvim)" | redraw') local clone_cmd = { 'git', 'clone', '--filter=blob:none', 'https://github.com/nvim-mini/mini.nvim', mini_path } vim.fn.system(clone_cmd) vim.cmd('packadd mini.nvim | helptags ALL') vim.cmd('echo "Installed [`mini.nvim`](../doc/mini-nvim.qmd#mini.nvim)" | redraw') end require('mini.deps').setup({ path = { package = path_package } }) require('mini.ai').setup() -- enhances the use of a/i textobjects require('mini.align').setup() -- utility to align text in various ways require('mini.comment').setup() -- for toggling comments inline require('mini.move').setup() -- moving lines require('mini.operators').setup() -- duplicating lines and evaluating equations inline require('mini.pairs').setup() -- automatic closing pairs require('mini.surround').setup() -- surround stuff require('mini.clue').setup({ -- shows available keybinds when performing keybind actions window = { delay = 50 }, triggers = { -- Leader triggers { mode = 'n', keys = '' }, { mode = 'x', keys = '' }, -- Built-in completion { mode = 'i', keys = '' }, -- `g` key { mode = 'n', keys = 'g' }, { mode = 'x', keys = 'g' }, -- Marks { mode = 'n', keys = "'" }, { mode = 'n', keys = '`' }, { mode = 'x', keys = "'" }, { mode = 'x', keys = '`' }, -- Registers { mode = 'n', keys = '"' }, { mode = 'x', keys = '"' }, { mode = 'i', keys = '' }, { mode = 'c', keys = '' }, -- Window commands { mode = 'n', keys = '' }, -- `z` key { mode = 'n', keys = 'z' }, { mode = 'x', keys = 'z' }, }, clues = { -- Enhance this by adding descriptions for mapping groups require('mini.clue').gen_clues.builtin_completion(), require('mini.clue').gen_clues.g(), require('mini.clue').gen_clues.marks(), require('mini.clue').gen_clues.registers(), require('mini.clue').gen_clues.windows(), require('mini.clue').gen_clues.z(), }, }) require('mini.diff').setup({ -- shows git diffs in the file view = { style = 'sign', } }) require('mini.files').setup({ -- file browser content = { -- Sort is faster than content.filter, since git is invoked once. sort = function(entries) -- Prepare the paths for sending via STDIN later. local pats = table.concat(vim.iter(entries) :map(function(e) return e.path end):totable(), '\n') -- Open up the git command, where we will send the list over STDIN local out = {} local id = vim.fn.jobstart({ "git", "check-ignore", "--stdin" }, { stdout_buffered = true, on_stdout = function(_, dat) out = dat end }) -- Return the entries if the command failed if id < 1 then return entries end -- Send the lines over STDIN, and await a response. vim.fn.chansend(id, pats) vim.fn.chanclose(id, 'stdin') vim.fn.jobwait({ id }) -- This response is used to filter out everything that was sent back; -- I.e. should be ignored. return MiniFiles.default_sort( vim.iter(entries):filter(function(e) return not vim.tbl_contains(out, e.path) end):totable()) end } }) Map('n', 'o', MiniFiles.open, { desc = "Open mini file browser" }) require('mini.jump').setup() -- extends f,F,t,T to work across multiple lines require('mini.pick').setup() Map('n', '', MiniPick.builtin.files, { desc = "File Picker" }) Map('n', '', MiniPick.builtin.live_grep, { desc = "Live Grep" }) Map('n', 'p', MiniPick.builtin.files, { desc = "File Picker" }) Map('n', 'sg', MiniPick.builtin.grep_live, { desc = "Search Live Grep" }) Map('n', 'sd', MiniExtra.pickers.diagnositc, { desc = "Search Diagnostics" }) require('mini.cursorword').setup() -- highlight words beneath the cursor require('mini.hipatterns').setup({ highlighters = { bug = { pattern = '%f[%w]()BUG()%f[%W]', group = '@comment.error' }, warn = { pattern = '%f[%w]()WARN()%f[%W]', group = '@comment.warning' }, todo = { pattern = '%f[%w]()TODO()%f[%W]', group = '@comment.todo' }, note = { pattern = '%f[%w]()NOTE()%f[%W]', group = '@comment.note' }, -- Highlight hex color strings (`#rrggbb`) using that color -- hex_color = MiniHipatterns.gen_highlighter.hex_color(), }, }) require('mini.icons').setup() require('mini.indentscope').setup({ draw = { delay = 50, -- delay in MS before writing the indicator animation = require('mini.indentscope').gen_animation.none(), }, }) MiniDeps.later(function() vim.api.nvim_set_hl(0, 'MiniIndentscopeSymbol', { link = 'Whitespace' }) end) require('mini.notify').setup() -- has more noticeable / utilitarian / aesthetically pleasing notifications Map('n', 'N', MiniNotify.show_history, { desc = 'Show Notification History' }) -- Custom `^V` and `^S` symbols to make this file appropriate for copy-paste -- (otherwise those symbols are not displayed). local CTRL_S = vim.api.nvim_replace_termcodes('', true, true, true) local CTRL_V = vim.api.nvim_replace_termcodes('', true, true, true) local modes = setmetatable({ ['n'] = { long = 'NORMAL', short = 'N', hl = 'MiniStatuslineModeNormal' }, ['v'] = { long = 'VISUAL', short = 'V', hl = 'MiniStatuslineModeVisual' }, ['V'] = { long = 'V-LINE', short = 'V-L', hl = 'MiniStatuslineModeVisual' }, [CTRL_V] = { long = 'V-BLOCK', short = 'V-B', hl = 'MiniStatuslineModeVisual' }, ['s'] = { long = 'SELECT', short = 'S', hl = 'MiniStatuslineModeVisual' }, ['S'] = { long = 'S-LINE', short = 'S-L', hl = 'MiniStatuslineModeVisual' }, [CTRL_S] = { long = 'S-BLOCK', short = 'S-B', hl = 'MiniStatuslineModeVisual' }, ['i'] = { long = 'INSERT', short = 'I', hl = 'MiniStatuslineModeInsert' }, ['R'] = { long = 'REPLACE', short = 'R', hl = 'MiniStatuslineModeReplace' }, ['c'] = { long = 'COMMAND', short = 'C', hl = 'MiniStatuslineModeCommand' }, ['r'] = { long = 'PROMPT', short = 'P', hl = 'MiniStatuslineModeOther' }, ['!'] = { long = 'SHELL', short = 'Sh', hl = 'MiniStatuslineModeOther' }, ['t'] = { long = 'TERMINAL', short = 'T', hl = 'MiniStatuslineModeOther' }, }, { -- By default return 'Unknown' but this shouldn't be needed __index = function() return { long = 'Unknown', short = 'U', hl = '%#MiniStatuslineModeOther#' } end, }) require('mini.statusline').setup({ content = { active = function() local mode_info = modes[vim.fn.mode()] local mode = MiniStatusline.is_truncated(120) and mode_info.short or mode_info.long local mode_hl = mode_info.hl local git = MiniStatusline.section_git({ trunc_width = 40 }) local diff = MiniStatusline.section_diff({ trunc_width = 75 }) local diagnostics = MiniStatusline.section_diagnostics({ trunc_width = 75 }) local lsp = MiniStatusline.section_lsp({ trunc_width = 75 }) local filename = MiniStatusline.section_filename({ trunc_width = 140 }) local fileinfo = MiniStatusline.section_fileinfo({ trunc_width = 120 }) return MiniStatusline.combine_groups({ { hl = mode_hl, strings = { mode } }, { hl = 'MiniStatuslineDevinfo', strings = { git, diff, diagnostics, lsp } }, '%<', -- general truncation point { hl = 'MiniStatuslineFilename', strings = { filename } }, '%=', -- align right { hl = 'MiniStatuslineFileInfo', strings = { fileinfo } }, { hl = mode_hl, strings = { '%3l:%-3c' } } }) end, inactive = function() return MiniStatusline.combine_groups({ {}, }) end }, use_icons = true, set_vim_settings = true, }) require('mini.tabline').setup() -- shows buffers that are open require('mini.trailspace').setup() -- trailing space indication and removal. ---@module 'lazy' ---@type LazySpec return {}