feat: Bufferline
This commit is contained in:
parent
8efea03163
commit
af7eb4bf7e
3 changed files with 116 additions and 0 deletions
10
lib/icons/default.nix
Normal file
10
lib/icons/default.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
_: {
|
||||
icons = {
|
||||
diagnostics = {
|
||||
error = " ";
|
||||
warn = " ";
|
||||
hint = " ";
|
||||
info = " ";
|
||||
};
|
||||
};
|
||||
}
|
98
modules/nixvim/plugins/ui/bufferline/default.nix
Normal file
98
modules/nixvim/plugins/ui/bufferline/default.nix
Normal file
|
@ -0,0 +1,98 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) flatten mapAttrsToList map;
|
||||
inherit (lib.marleyvim) icons keys autocmds;
|
||||
inherit (helpers) mkRaw;
|
||||
in {
|
||||
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.marleyos_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"] "<LEADER>bp" "<CMD>BufferLineTogglePin<CR>" "Toggle Pin")
|
||||
(keys.mk ["n"] "<LEADER>bP" "<CMD>BufferLineGroupClose ungrouped<CR>"
|
||||
"Delete Non-Pinned Buffers")
|
||||
(keys.mk ["n"] "<LEADER>br" "<CMD>BufferLineCloseRight<CR>"
|
||||
"Delete Buffers to the Right")
|
||||
(keys.mk ["n"] "<LEADER>bl" "<CMD>BufferLineCloseLeft<CR>"
|
||||
"Delete Buffers to the Left")
|
||||
(keys.mk ["n"] "<S-H>" "<CMD>BufferLineCyclePrev<CR>" "Prev Buffer")
|
||||
(keys.mk ["n"] "<S-L>" "<CMD>BufferLineCycleNext<CR>" "Next Buffer")
|
||||
]
|
||||
++ (flatten (mapAttrsToList (
|
||||
a: ks:
|
||||
map (k: keys.mk ["n"] k "<CMD>BufferLineCycle${a}<CR>" "${a} Buffer") ks
|
||||
) {
|
||||
Prev = ["<S-H>" "[b"];
|
||||
Next = ["<S-L>" "]b"];
|
||||
}))
|
||||
++ (
|
||||
mapAttrsToList (
|
||||
a: k: let
|
||||
befAft =
|
||||
if (a == "Prev")
|
||||
then "After"
|
||||
else "Before";
|
||||
in
|
||||
keys.mk ["n"] "${k}B" "<CMD>BufferLineMove${a}<CR>"
|
||||
"Move Buffer ${befAft} ${a}"
|
||||
) {
|
||||
Prev = "[";
|
||||
After = "]";
|
||||
}
|
||||
);
|
||||
}
|
8
modules/nixvim/plugins/ui/mini.icons/default.nix
Normal file
8
modules/nixvim/plugins/ui/mini.icons/default.nix
Normal file
|
@ -0,0 +1,8 @@
|
|||
_: {
|
||||
plugins.mini = {
|
||||
enable = true;
|
||||
|
||||
mockDevIcons = true;
|
||||
modules.icons = {};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue