diff --git a/lib/icons/default.nix b/lib/icons/default.nix new file mode 100644 index 0000000..561c7ad --- /dev/null +++ b/lib/icons/default.nix @@ -0,0 +1,10 @@ +_: { + icons = { + diagnostics = { + error = " "; + warn = " "; + hint = " "; + info = " "; + }; + }; +} diff --git a/modules/nixvim/plugins/ui/bufferline/default.nix b/modules/nixvim/plugins/ui/bufferline/default.nix new file mode 100644 index 0000000..c20d0dd --- /dev/null +++ b/modules/nixvim/plugins/ui/bufferline/default.nix @@ -0,0 +1,73 @@ +{ + lib, + helpers, + ... +}: let + inherit (helpers) mkRaw; + inherit (lib) flatten mapAttrsToList map; + inherit (lib.marleyvim) icons keys; +in { + plugins.bufferline = { + enable = true; + + settings = { + options = { + close_command = + mkRaw + # lua + "function(n) Snacks.bufdelete(n) end"; + right_mouse_command = + mkRaw + # lua + "function(n) Snacks.bufdelete(n) end"; + + diagnostics = "nvim_lsp"; + diagnostics_indicator = + mkRaw + # 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 + ''; + }; + }; + }; + + 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 = "]"; + } + ); +}