From e1f88771f873128195ba477b5ee7bafdfe061c2f Mon Sep 17 00:00:00 2001 From: iFargle Date: Thu, 8 Feb 2024 20:56:57 +0900 Subject: [PATCH] Re-add keybindings --- home-manager/common/software/cli/nixvim.nix | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/home-manager/common/software/cli/nixvim.nix b/home-manager/common/software/cli/nixvim.nix index cbbd1136..5d5453cc 100644 --- a/home-manager/common/software/cli/nixvim.nix +++ b/home-manager/common/software/cli/nixvim.nix @@ -11,6 +11,38 @@ globals.mapleader = " "; globals.maplocalleader = " "; + 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) + # Leave insert mode by pressing j and k simultaneously + (imap "jk" "") + (imap "kj" "") + # 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") + ]; + options = { number = true; shiftwidth = 2;