From 7e1fbc9a233096e54fb33d723b8eb8393213380d Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sun, 21 Jun 2026 21:27:20 +0200 Subject: modules/lf: Use nix attrs to avoid overlapping mappings Previously the `n*` mapping for movement were not accessible, because they accidentally overlapped with the vim `n` mapping. This is now impossible. --- modules/by-name/lf/lf/keybindings/default.nix | 113 ++++++++++++++++---------- modules/by-name/lf/lf/module.nix | 14 +++- 2 files changed, 82 insertions(+), 45 deletions(-) diff --git a/modules/by-name/lf/lf/keybindings/default.nix b/modules/by-name/lf/lf/keybindings/default.nix index b6b7a548..d7f8eb95 100644 --- a/modules/by-name/lf/lf/keybindings/default.nix +++ b/modules/by-name/lf/lf/keybindings/default.nix @@ -15,50 +15,69 @@ "'\"'" = null; ";" = null; "\"'\"" = null; - c = null; - d = null; - e = null; - j = null; - k = null; - m = null; - f = null; # Sorting - kn = ":set sortby natural; set info"; - ks = ":set sortby size; set info size"; - kt = ":set sortby time; set info time"; - ka = ":set sortby atime; set info atime"; - kc = ":set sortby ctime; set info ctime"; - ke = ":set sortby ext; set info"; + # k = null; + k = { + n = ":set sortby natural; set info"; + s = ":set sortby size; set info size"; + t = ":set sortby time; set info time"; + a = ":set sortby atime; set info atime"; + c = ":set sortby ctime; set info ctime"; + e = ":set sortby ext; set info"; + }; # Searching l = "search-next"; L = "search-prev"; - # File Openers - ee = "\$\$EDITOR \"$f\""; - es = "\$ nvim -S \"$f\""; + # File edit + # e = null; + e = { + e = "\$\$EDITOR \"$f\""; + s = "\$ nvim -S \"$f\""; + }; + u = "view_file"; - cc = "\$sudo -e \"$f\""; - fe = "execute"; - fl = "follow_link"; - cp = "set_clipboard_path"; + + # f = null; + f = { + e = "execute"; + l = "follow_link"; + }; + + # c = null; + c = { + p = "set_clipboard_path"; + s = "stripspace"; + h = "chmod"; + }; # Archive Mappings - au = "archive_decompress"; - aa = "archive_compress"; + a = { + u = "archive_decompress"; + a = "archive_compress"; + }; - # Trash Mappings - dd = "trash"; - jc = "trash_clear"; - jr = "trash_restore"; + D = { + D = "delete"; + }; + # d = null; + d = { + # Trash Mappings + d = "trash"; - # Dragon Mapping - dr = "dragon"; - ds = "dragon_stay"; - di = "dragon_individual"; + # Dragon Mapping + r = "dragon"; + s = "dragon_stay"; + i = "dragon_individual"; + }; - cs = "stripspace"; + # j = null; + j = { + c = "trash_clear"; + r = "trash_restore"; + }; # Vim keys h = "updir"; @@ -68,30 +87,36 @@ # Basic Functions "." = "set hidden!"; - DD = "delete"; p = "paste"; x = "cut"; y = "copy"; "" = "open"; - mk = "mk_link"; - mf = "mk_file"; - md = "mk_directory"; - ms = "mk_script"; + # m = null; + m = { + k = "mk_link"; + f = "mk_file"; + d = "mk_directory"; + s = "mk_script"; + }; + + b = { + g = "set_wallpaper"; + }; - ch = "chmod"; - bg = "set_wallpaper"; r = ":rename; cmd-end"; R = "reload"; C = "clear"; U = "unselect"; - # Movement - nu = "cd /run/user/${builtins.toString uid}"; - ne = "cd /etc"; - nd = "cd ${downloadDir}"; - nt = "cd /tmp"; - nh = "cd_project_root"; + # (walking) Movement + w = { + u = "cd /run/user/${builtins.toString uid}"; + e = "cd /etc"; + d = "cd ${downloadDir}"; + t = "cd /tmp"; + h = "cd_project_root"; + }; g = "cd_lf_make_map"; } diff --git a/modules/by-name/lf/lf/module.nix b/modules/by-name/lf/lf/module.nix index daa236e6..0a0e193f 100644 --- a/modules/by-name/lf/lf/module.nix +++ b/modules/by-name/lf/lf/module.nix @@ -17,7 +17,19 @@ ... }: let commands = import ./commands {inherit pkgs sysLib shell_library system;}; - keybindings = import ./keybindings {inherit (cfg.keymaps) uid downloadDir;}; + keybindings_raw = import ./keybindings {inherit (cfg.keymaps) uid downloadDir;}; + + process = prefix: attrs: + lib.mapAttrsToList (name: value: + if (builtins.isAttrs value) + then + (process name value) + ++ [(lib.nameValuePair name null)] + else if prefix == null + then (lib.nameValuePair name value) + else (lib.nameValuePair (prefix + name) value)) + attrs; + keybindings = builtins.listToAttrs (lib.lists.flatten (process null keybindings_raw)); packages = import ./wrappers {inherit pkgs;}; -- cgit v1.3.1