lib: move all binding related functions to lib/binds

This commit is contained in:
raf 2024-04-07 18:31:06 +03:00
commit a12ba5689a
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
10 changed files with 51 additions and 112 deletions

View file

@ -236,6 +236,11 @@ in {
else abort ("Dependency cycle in ${name}: " + toJSON sortedDag);
in
result;
mkSection = r: ''
-- SECTION: ${r.name}
${r.data}
'';
in {
vim = {
startPlugins = map (x: x.package) (attrValues cfg.extraPlugins);
@ -243,10 +248,6 @@ in {
globalsScript = entryAnywhere (concatStringsSep "\n" globalsScript);
luaScript = let
mkSection = r: ''
-- SECTION: ${r.name}
${r.data}
'';
mapResult = r: (wrapLuaConfig (concatStringsSep "\n" (map mkSection r)));
luaConfig = resolveDag {
name = "lua config script";
@ -257,10 +258,6 @@ in {
entryAfter ["globalsScript"] luaConfig;
extraPluginConfigs = let
mkSection = r: ''
-- SECTION: ${r.name}
${r.data}
'';
mapResult = r: (wrapLuaConfig (concatStringsSep "\n" (map mkSection r)));
extraPluginsDag = mapAttrs (_: {
after,

View file

@ -9,6 +9,7 @@ inputs: {
inherit (pkgs) wrapNeovimUnstable vimPlugins;
inherit (pkgs.vimUtils) buildVimPlugin;
inherit (pkgs.neovimUtils) makeNeovimConfig;
inherit (lib.attrsets) recursiveUpdate;
extendedLib = import ../lib/stdlib-extended.nix lib;
@ -19,7 +20,7 @@ inputs: {
module = extendedLib.evalModules {
modules = [configuration] ++ nvimModules;
specialArgs = {modulesPath = toString ./.;} // extraSpecialArgs;
specialArgs = recursiveUpdate {modulesPath = toString ./.;} extraSpecialArgs;
};
vimOptions = module.config.vim;

View file

@ -7,16 +7,41 @@
cfg = config.vim;
in {
vim.maps.normal =
mkIf cfg.disableArrows {
vim.maps = {
normal =
mkIf cfg.disableArrows {
"<up>" = {
action = "<nop>";
noremap = false;
};
"<down>" = {
action = "<nop>";
noremap = false;
};
"<left>" = {
action = "<nop>";
noremap = false;
};
"<right>" = {
action = "<nop>";
noremap = false;
};
}
// mkIf cfg.mapLeaderSpace {
"<space>" = {
action = "<nop>";
};
};
insert = mkIf cfg.disableArrows {
"<up>" = {
action = "<nop>";
noremap = false;
};
"<down>" = {
action = "<nop>";
noremap = false;
};
"<left>" = {
@ -27,29 +52,6 @@ in {
action = "<nop>";
noremap = false;
};
}
// mkIf cfg.mapLeaderSpace {
"<space>" = {
action = "<nop>";
};
};
vim.maps.insert = mkIf cfg.disableArrows {
"<up>" = {
action = "<nop>";
noremap = false;
};
"<down>" = {
action = "<nop>";
noremap = false;
};
"<left>" = {
action = "<nop>";
noremap = false;
};
"<right>" = {
action = "<nop>";
noremap = false;
};
};
}

View file

@ -9,8 +9,7 @@
inherit (lib.nvim.binds) mkBinding;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
# TODO: move this to its own module
inherit (lib) pushDownDefault;
inherit (lib.nvim.binds) pushDownDefault;
cfg = config.vim.filetree.nvimTree;
self = import ./nvimtree.nix {inherit pkgs lib;};

View file

@ -5,10 +5,8 @@
}: let
inherit (builtins) toJSON;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetExprBinding mkSetLuaBinding;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetExprBinding mkSetLuaBinding pushDownDefault;
inherit (lib.nvim.dag) entryAnywhere;
# TODO: move this to its own module
inherit (lib) pushDownDefault;
cfg = config.vim.git;

View file

@ -4,7 +4,8 @@
lib,
...
}: let
inherit (lib) mkMerge mkBinding mkIf;
inherit (lib) mkMerge mkIf;
inherit (lib.nvim.binds) mkBinding;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.notes.todo-comments;

View file

@ -3,7 +3,8 @@
lib,
...
}: let
inherit (lib) mkEnableOption mkOption types mkMappingOption mkRenamedOptionModule;
inherit (lib) mkEnableOption mkOption types mkRenamedOptionModule;
inherit (lib.nvim.binds) mkMappingOption;
in {
imports = let
renamedSetupOption = oldPath: newPath:

View file

@ -7,8 +7,7 @@
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
inherit (lib.nvim.dag) entryAnywhere;
# TODO: move this to its own module
inherit (lib) pushDownDefault;
inherit (lib.nvim.binds) pushDownDefault;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.telescope;