{ lib, helpers, ... }: let inherit (lib) flatten mapAttrsToList map; inherit (lib.marleyvim) icons keys autocmds; inherit (helpers) mkRaw; in { plugins.mini = { enable = true; modules.icons = {}; }; plugins.bufferline = { enable = true; settings = { options = { close_command.__raw = "function(n) Snacks.bufdelete(n) end"; right_mouse_command.__raw = "function(n) Snacks.bufdelete(n) end"; diagnostics = "nvim_lsp"; diagnostics_indicator.__raw = # lua '' function(_, _, diag) local ret = (diag.error and "${icons.diagnostics.error}" .. diag.error .. " " or "") .. (diag.warning and "${icons.diagnostics.warn}" .. diag.warning or "") return vim.trim(ret) end ''; always_show_bufferline = true; offsets = [ { filetype = "neo-tree"; text = "Explorer"; highlight = "Directory"; text_align = "left"; } ]; get_element_icon.__raw = '' function(elem) local icon, hl, _ = require('mini.icons').get('filetype', elem.filetype) return icon, hl end ''; }; }; }; autoGroups.marleyvim_bufferline.clear = true; autoCmd = [ (autocmds.mk' ["BufAdd" "BufDelete"] "bufferline" ( mkRaw '' function() vim.schedule(function() pcall(nvim_bufferline) end) end '' ) "Fix bufferline when restoring a session") ]; keymaps = [ (keys.mk ["n"] "bp" "BufferLineTogglePin" "Toggle Pin") (keys.mk ["n"] "bP" "BufferLineGroupClose ungrouped" "Delete Non-Pinned Buffers") (keys.mk ["n"] "br" "BufferLineCloseRight" "Delete Buffers to the Right") (keys.mk ["n"] "bl" "BufferLineCloseLeft" "Delete Buffers to the Left") (keys.mk ["n"] "" "BufferLineCyclePrev" "Prev Buffer") (keys.mk ["n"] "" "BufferLineCycleNext" "Next Buffer") ] ++ (flatten (mapAttrsToList ( a: ks: map (k: keys.mk ["n"] k "BufferLineCycle${a}" "${a} Buffer") ks ) { Prev = ["" "[b"]; Next = ["" "]b"]; })) ++ ( mapAttrsToList ( a: k: let befAft = if (a == "Prev") then "After" else "Before"; in keys.mk ["n"] "${k}B" "BufferLineMove${a}" "Move Buffer ${befAft} ${a}" ) { Prev = "["; After = "]"; } ); }