{ ... }: { programs.nixvim.keymaps = let map = mode: key: action: { mode = mode; key = key; action = action; }; nmap = key: action: map [ "n" ] key action; nvmap = key: action: map [ "n" "v" ] key action; # imap = key: action: map [ "i" ] key action; desc = d: { options.desc = d; }; silent = { options.silent = true; }; expr = { options.expr = true; }; in [ # Unmap keys that aren't useful, or that we want to use for different things (nvmap "" "" // silent) (nvmap "" "" // silent) (nvmap "s" "" // silent) # Redo (nmap "R" "") # Copy and paste (nvmap "y" "\"+y" // desc "Cop[y] to clipboard") (nvmap "p" "\"+p" // desc "[P]aste from clipboard") # Jump to start/end of line (nvmap "H" "0") (nvmap "L" "$") # Navigate up and down word wrapped text as if it were not word wrapped (nmap "k" "v:count == 0 ? 'gk' : 'k'" // silent // expr) (nmap "j" "v:count == 0 ? 'gj' : 'j'" // silent // expr) # Center cursor when jumping foward or back (nmap "" "zz") (nmap "" "zz") # Insert Mode # Normal Mode # NVimTree (nmap "n" "" // desc "[N]vimTree") (nmap "nf" ":NvimTreeFocus" // desc "[F]ocus NvimTree") (nmap "nt" ":NvimTreeToggle" // desc "[T]oggle NvimTree") (nmap "ns" ":NvimTreeFindFile"// desc "[S]earch NvimTree") (nmap "nc" ":NvimTreeClose" // desc "[C]lose NvimTree") (nmap "nr" ":NvimTreeRefresh" // desc "[R]efresh NvimTree") (nmap "nT" ":NoiceTelescope" // desc "Noice [T]elescope") # ToggleTerm (nmap "Tt" ":ToggleTerm" // desc "[T]oggle Terminal") (nmap "Ts" ":TermSelect" // desc "[S]elect a terminal") # Fugitive (nmap "gc" ":Git cam \"" // desc "[C]ommit" ) (nmap "gp" ":Git push" // desc "Git [p]ush") (nmap "gP" ":Git pull" // desc "[P]ull") (nmap "ga" ":Git add " // desc "[A]dd file...") (nmap "gb" ":Git blame" // desc "[B]lame") (nmap "gd" ":Git diff" // desc "[D]iff") # Trouble (nmap "tf" ":Trouble" // desc "[F]ocus") (nmap "tt" ":TroubleToggle" // desc "[T]oggle") (nmap "tc" ":TroubleClose" // desc "[C]lose") # Window Management (nmap "wh" ":wincmd h" // desc "Move left") (nmap "wl" ":wincmd l" // desc "Move right") (nmap "wj" ":wincmd j" // desc "Move down") (nmap "wk" ":wincmd k" // desc "Move up") (nmap "wn" ":wincmd w" // desc "Move to next") (nmap "wN" ":wincmd p" // desc "Move to previous") (nmap "wc" ":wincmd c" // desc "[C]lose active window") (nmap "woh" ":wincmd n" // desc "Open [H]orizontal window") (nmap "wov" ":wincmd v" // desc "Open [V]ertical window") # resize window (nmap "wrh" ":resize " // desc "Resize Horizontal") (nmap "wrv" ":vertical resize " // desc "Resize Vertical") # Buffer Management (nmap "bn" ":bnext" // desc "Next buffer") (nmap "bN" ":bNext" // desc "Previous buffer") (nmap "bc" ":bdelete" // desc "[c]lose buffer") (nmap "bt" ":enew" // desc "New [T]ab") # Multicursors (nmap "ms" ":MCstart" // desc "[S]tart Multicorsor") (nmap "mv" ":MCvisual" // desc "[V]isual Multicorsor") (nmap "mc" ":MCclear" // desc "[C]lear Multicorsor") (nmap "mu" ":MCunderCursor" // desc "Select [U]nder Corsor") (nmap "mp" ":MCpattern" // desc "Select [P]attern") ]; }