diff --git a/lib/keymaps/default.nix b/lib/keymaps/default.nix index e330c29..fc92b4b 100644 --- a/lib/keymaps/default.nix +++ b/lib/keymaps/default.nix @@ -1,6 +1,6 @@ _: { keys = rec { - mkKeymap = mode: key: action: desc: { + mk = mode: key: action: desc: { inherit mode key action; options = { inherit desc; @@ -8,19 +8,16 @@ _: { }; }; - mkKeymap' = - mode: key: action: - mkKeymap mode key action null; + mk' = mode: key: action: + mk mode key action null; - mkKeymapWithOpts = - mode: key: action: desc: opts: - (mkKeymap mode key action desc) + mkWithOpts = mode: key: action: desc: opts: + (mk mode key action desc) // { options = opts; }; - mkKeymapWithOpts' = - mode: key: action: opts: - mkKeymapWithOpts mode key action null opts; + mkWithOpts' = mode: key: action: opts: + mkWithOpts mode key action null opts; }; } diff --git a/modules/nixvim/keymaps/default.nix b/modules/nixvim/keymaps/default.nix index b40976a..211fd32 100644 --- a/modules/nixvim/keymaps/default.nix +++ b/modules/nixvim/keymaps/default.nix @@ -13,7 +13,7 @@ toLower ; - inherit (lib.marleyos.keys) mkKeymap mkKeymap' mkKeymapWithOpts; + inherit (lib.marleyos) keys; inherit (helpers) mkRaw; in { globals = { @@ -24,13 +24,13 @@ in { keymaps = # # Disable Arrow Key Movement - - - - - - - - - - - - - - - - - - - - - - - - - (map (d: mkKeymap' ["i" "n"] d "") ["" "" "" ""]) + (map (d: keys.mk' ["i" "n"] d "") ["" "" "" ""]) # # Better Up/Down - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ++ ( mapAttrsToList (d: k: - mkKeymapWithOpts ["n" "x"] k "v:count == 0 ? 'g${k}' : '${k}'" d + keys.mkWithOpts ["n" "x"] k "v:count == 0 ? 'g${k}' : '${k}'" d {expr = true;}) { Down = "j"; @@ -48,7 +48,7 @@ in { then "+" else "-"; in - mkKeymap ["n"] "" "resize ${s}4" "${d} Window Height" + keys.mk ["n"] "" "resize ${s}4" "${d} Window Height" ) { Up = "Increase"; @@ -65,7 +65,7 @@ in { # previous -> Prev prettyDir = (toUpper (substring 0 1 d)) + (substring 1 3 d); in - mkKeymap ["n"] k "b${d}" "${prettyDir} Buffer" + keys.mk ["n"] k "b${d}" "${prettyDir} Buffer" ) { "" = "previous"; @@ -74,13 +74,13 @@ in { "]b" = "next"; } ) - ++ [(mkKeymap ["n"] "bD" "bd" "Delete Buffer and Window")] + ++ [(keys.mk ["n"] "bD" "bd" "Delete Buffer and Window")] # # Clear Search/Diff Update/Redraw - - - - - - - - - - - - - - - - - - - - - ++ [ - (mkKeymap ["i" "n"] "" "noh" "Escape and Clear hlsearch") + (keys.mk ["i" "n"] "" "noh" "Escape and Clear hlsearch") ( - mkKeymap ["n"] "ur" + keys.mk ["n"] "ur" "nohlsearchdiffupdatenormal! " "Redraw / Clear hlsearch / Diff Update" ) @@ -106,7 +106,7 @@ in { then ".'zv'" else ""; in - mkKeymapWithOpts [m] k "'${nn}'[v:searchforward]${zv}" + keys.mkWithOpts [m] k "'${nn}'[v:searchforward]${zv}" "${d} Search Result" {expr = true;} ) { @@ -116,24 +116,21 @@ in { ) # # Undo Break-Points - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ++ (map (c: mkKeymap' ["i"] c "${c}u") ["," "." ";"]) + ++ (map (c: keys.mk' ["i"] c "${c}u") ["," "." ";"]) # # Search Docs (keywordprog) - - - - - - - - - - - - - - - - - - - - - - - - # https://til.codeinthehole.com/posts/about-how-to-use-keywordprg-effectively/ - ++ [ - (mkKeymap ["n"] "K" "norm! K" - "Search for word") - ] + ++ [(keys.mk ["n"] "K" "norm! K" "Search for word")] # # Better Indenting - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ++ (map (c: mkKeymap' ["v"] c "${c}gv") ["<" ">"]) + ++ (map (c: keys.mk' ["v"] c "${c}gv") ["<" ">"]) # # Commenting - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ++ ( mapAttrsToList ( k: d: - mkKeymap ["n"] "gc${k}" - "${k}Vcxnormal gccfxa" "Add Comment ${d}" + keys.mk ["n"] "gc${k}" "${k}Vcxnormal gccfxa" + "Add Comment ${d}" ) { o = "Below"; @@ -142,19 +139,19 @@ in { ) # # New File - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ++ [(mkKeymap ["n"] "fn" "enew" "New File")] + ++ [(keys.mk ["n"] "fn" "enew" "New File")] # # Locations/Quickfixes - - - - - - - - - - - - - - - - - - - - - - - - - - - ++ [ - (mkKeymap ["n"] "xl" "lopen" "Location List") - (mkKeymap ["n"] "xq" "copen" "Quickfix list") + (keys.mk ["n"] "xl" "lopen" "Location List") + (keys.mk ["n"] "xq" "copen" "Quickfix list") ] ++ ( mapAttrsToList ( k: d: let cmd = substring 0 4 (toLower d); in - mkKeymap ["n"] "${k}q" "c${cmd}" "${d} Quickfix" + keys.mk ["n"] "${k}q" "c${cmd}" "${d} Quickfix" ) { "[" = "Previous"; @@ -164,7 +161,7 @@ in { # # Diagnostics - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ++ [ - (mkKeymap ["n"] "cd" ( + (keys.mk ["n"] "cd" ( mkRaw # lua "function() vim.diagnostic.open_float() end" @@ -200,10 +197,12 @@ in { cmd = toLower dir; sev = sevs."${key}".key; in - mkKeymap ["n"] kmap - (mkRaw + keys.mk ["n"] kmap + ( + mkRaw # lua - "function() vim.diagnostic.goto_${cmd}({ severity = ${sev} }) end") + "function() vim.diagnostic.goto_${cmd}({ severity = ${sev} }) end" + ) "${dir} ${sevs."${key}".desc}" ) { @@ -213,17 +212,17 @@ in { ) # # Quit - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ++ [(mkKeymap ["n"] "qq" "qa" "Quit All")] + ++ [(keys.mk ["n"] "qq" "qa" "Quit All")] # # Inspect - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ++ [(mkKeymap ["n"] "ui" (mkRaw "vim.show_pos") "Inspect Position")] + ++ [(keys.mk ["n"] "ui" (mkRaw "vim.show_pos") "Inspect Position")] # # Window Management - - - - - - - - - - - - - - - - - - - - - - - - - - - - ++ [ - (mkKeymapWithOpts ["n"] "w" "" "Windows" {remap = true;}) - (mkKeymapWithOpts ["n"] "-" "s" "Split Window Below" {remap = true;}) - (mkKeymapWithOpts ["n"] "|" "v" "Split Window Right" {remap = true;}) - (mkKeymapWithOpts ["n"] "wd" "c" "Delete Window" {remap = true;}) + (keys.mkWithOpts ["n"] "w" "" "Windows" {remap = true;}) + (keys.mkWithOpts ["n"] "-" "s" "Split Window Below" {remap = true;}) + (keys.mkWithOpts ["n"] "|" "v" "Split Window Right" {remap = true;}) + (keys.mkWithOpts ["n"] "wd" "c" "Delete Window" {remap = true;}) ] # # Tab Management - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -235,7 +234,7 @@ in { then "Close Other Tabs" else "${a} Tab"; in - mkKeymap ["n"] "${k}" "tab${toLower a}" desc + keys.mk ["n"] "${k}" "tab${toLower a}" desc ) { l = "Last"; diff --git a/modules/nixvim/plugins/base/snacks/default.nix b/modules/nixvim/plugins/base/snacks/default.nix index daf0470..294855e 100644 --- a/modules/nixvim/plugins/base/snacks/default.nix +++ b/modules/nixvim/plugins/base/snacks/default.nix @@ -5,7 +5,7 @@ ... }: let inherit (helpers) mkRaw; - inherit (lib.marleyos.keys) mkKeymap; + inherit (lib.marleyos) keys; in { extraPackages = [pkgs.lazygit]; @@ -22,51 +22,51 @@ in { }; keymaps = [ - (mkKeymap ["n"] "un" ( + (keys.mk ["n"] "un" ( mkRaw # lua "function() Snacks.notifier.hide() end" ) "Dismiss All Notifications") - (mkKeymap ["n"] "bd" ( + (keys.mk ["n"] "bd" ( mkRaw # lua "function() Snacks.bufdelete() end" ) "Delete Buffer") - (mkKeymap ["n"] "bo" ( + (keys.mk ["n"] "bo" ( mkRaw # lua "function() Snacks.bufdelete.other() end" ) "Delete Other Buffers") # LazyGit - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (mkKeymap ["n"] "gg" ( + (keys.mk ["n"] "gg" ( mkRaw # lua "function() Snacks.lazygit() end" ) "Lazygit") - (mkKeymap ["n"] "gf" ( + (keys.mk ["n"] "gf" ( mkRaw # lua "function() Snacks.lazygit.log_file() end" ) "Lazygit Current File History") - (mkKeymap ["n"] "gl" ( + (keys.mk ["n"] "gl" ( mkRaw # lua "function() Snacks.lazygit.log() end" ) "Lazygit Log") # Git - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (mkKeymap ["n"] "gb" ( + (keys.mk ["n"] "gb" ( mkRaw # lua "function() Snacks.git.blame_line() end" ) "Git Blame Line") - (mkKeymap ["n" "x"] "gB" ( + (keys.mk ["n" "x"] "gB" ( mkRaw # lua "function() Snacks.gitbrowse() end"