blob: 1fd3e860dae07ab1040af98887acff60b55a4c64 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
{
config,
lib,
options,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.binds) mkKeymap pushDownDefault;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.tabline.nvimBufferline;
inherit (options.vim.tabline.nvimBufferline) mappings;
in {
config = mkIf cfg.enable {
vim = {
startPlugins = [
"bufferline-nvim"
"bufdelete-nvim"
];
# Soft-dependency for bufferline.
# Recommended by upstream, so enabled here.
visuals.nvim-web-devicons.enable = true;
# See `:help bufferline-hover-events`
options = mkIf cfg.setupOpts.options.hover.enabled {
mousemoveevent = true;
};
keymaps = [
(
mkKeymap "n" cfg.mappings.closeCurrent "require('bufdelete').bufdelete"
{
desc = mappings.closeCurrent.description;
lua = true;
}
)
(mkKeymap "n" cfg.mappings.cycleNext ":BufferLineCycleNext<CR>" {desc = mappings.cycleNext.description;})
(mkKeymap "n" cfg.mappings.cycleNext ":BufferLineCycleNext<CR>" {desc = mappings.cycleNext.description;})
(mkKeymap "n" cfg.mappings.cyclePrevious ":BufferLineCyclePrev<CR>" {desc = mappings.cyclePrevious.description;})
(mkKeymap "n" cfg.mappings.pick ":BufferLinePick<CR>" {desc = mappings.pick.description;})
(mkKeymap "n" cfg.mappings.sortByExtension ":BufferLineSortByExtension<CR>" {desc = mappings.sortByExtension.description;})
(mkKeymap "n" cfg.mappings.sortByDirectory ":BufferLineSortByDirectory<CR>" {desc = mappings.sortByDirectory.description;})
(
mkKeymap "n" cfg.mappings.sortById
"function() require('bufferline').sort_buffers_by(function (buf_a, buf_b) return buf_a.id < buf_b.id end) end"
{
desc = mappings.sortById.description;
lua = true;
}
)
(mkKeymap "n" cfg.mappings.moveNext ":BufferLineMoveNext<CR>" {desc = mappings.moveNext.description;})
(mkKeymap "n" cfg.mappings.movePrevious ":BufferLineMovePrev<CR>" {desc = mappings.movePrevious.description;})
];
binds.whichKey.register = pushDownDefault {
"<leader>b" = "+Buffer";
"<leader>bm" = "BufferLineMove";
"<leader>bs" = "BufferLineSort";
"<leader>bsi" = "BufferLineSortById";
};
pluginRC.nvimBufferline = entryAnywhere ''
require("bufferline").setup(${toLuaObject cfg.setupOpts})
'';
};
};
}
|