modules/tabline: switch to explicit lib calls

This commit is contained in:
NotAShelf 2024-03-12 03:47:41 +03:00
parent 32c2e7733a
commit e80f2c9280
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
4 changed files with 86 additions and 82 deletions

View file

@ -1,4 +1,4 @@
_: { {
imports = [ imports = [
./nvim-bufferline ./nvim-bufferline
]; ];

View file

@ -3,13 +3,14 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkIf mkMerge mkLuaBinding mkBinding nvim pushDownDefault; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) mkLuaBinding mkBinding pushDownDefault;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.tabline.nvimBufferline; cfg = config.vim.tabline.nvimBufferline;
self = import ./nvim-bufferline.nix {
inherit lib; self = import ./nvim-bufferline.nix {inherit lib;};
}; inherit (self.options.vim.tabline.nvimBufferline) mappings;
mappings = self.options.vim.tabline.nvimBufferline.mappings;
in { in {
config = mkIf cfg.enable ( config = mkIf cfg.enable (
let let
@ -22,12 +23,13 @@ in {
''; '';
}; };
in { in {
vim.startPlugins = [ vim = {
(assert config.vim.visuals.nvimWebDevicons.enable == true; "nvim-bufferline-lua") startPlugins = [
(assert config.vim.visuals.nvimWebDevicons.enable; "nvim-bufferline-lua")
"bufdelete-nvim" "bufdelete-nvim"
]; ];
vim.maps.normal = mkMerge [ maps.normal = mkMerge [
(mkLuaBinding cfg.mappings.closeCurrent "require(\"bufdelete\").bufdelete" mappings.closeCurrent.description) (mkLuaBinding cfg.mappings.closeCurrent "require(\"bufdelete\").bufdelete" mappings.closeCurrent.description)
(mkBinding cfg.mappings.cycleNext ":BufferLineCycleNext<CR>" mappings.cycleNext.description) (mkBinding cfg.mappings.cycleNext ":BufferLineCycleNext<CR>" mappings.cycleNext.description)
(mkBinding cfg.mappings.cycleNext ":BufferLineCycleNext<CR>" mappings.cycleNext.description) (mkBinding cfg.mappings.cycleNext ":BufferLineCycleNext<CR>" mappings.cycleNext.description)
@ -40,14 +42,14 @@ in {
(mkBinding cfg.mappings.movePrevious ":BufferLineMovePrev<CR>" mappings.movePrevious.description) (mkBinding cfg.mappings.movePrevious ":BufferLineMovePrev<CR>" mappings.movePrevious.description)
]; ];
vim.binds.whichKey.register = pushDownDefault { binds.whichKey.register = pushDownDefault {
"<leader>b" = "+Buffer"; "<leader>b" = "+Buffer";
"<leader>bm" = "BufferLineMove"; "<leader>bm" = "BufferLineMove";
"<leader>bs" = "BufferLineSort"; "<leader>bs" = "BufferLineSort";
"<leader>bsi" = "BufferLineSortById"; "<leader>bsi" = "BufferLineSortById";
}; };
vim.luaConfigRC.nvimBufferline = nvim.dag.entryAnywhere '' luaConfigRC.nvimBufferline = entryAnywhere ''
require("bufferline").setup{ require("bufferline").setup{
options = { options = {
mode = "buffers", mode = "buffers",
@ -98,6 +100,7 @@ in {
} }
} }
''; '';
};
} }
); );
} }

View file

@ -1,4 +1,4 @@
_: { {
imports = [ imports = [
./nvim-bufferline.nix ./nvim-bufferline.nix
./config.nix ./config.nix

View file

@ -1,8 +1,9 @@
{lib, ...}: let {lib, ...}: let
inherit (lib) mkEnableOption mkMappingOption; inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
in { in {
options.vim.tabline.nvimBufferline = { options.vim.tabline.nvimBufferline = {
enable = mkEnableOption "nvim-bufferline-lua as a bufferline"; enable = mkEnableOption "neovim bufferline";
mappings = { mappings = {
closeCurrent = mkMappingOption "Close buffer" null; closeCurrent = mkMappingOption "Close buffer" null;