summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2022-03-31 00:07:48 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2022-03-31 00:07:48 +0200
commit8922578321d9e3a0be5d6dbedabd039406c2740b (patch)
tree2be2177d33574453ba8ea762adbc9eb57f3d9249
parentc3452161c118bbac031c623ce0146fb602c0623b (diff)
feat(settings): add keymaps
-rw-r--r--fnl/settings/keymaps.fnl57
1 files changed, 57 insertions, 0 deletions
diff --git a/fnl/settings/keymaps.fnl b/fnl/settings/keymaps.fnl
new file mode 100644
index 0000000..9c4b0e8
--- /dev/null
+++ b/fnl/settings/keymaps.fnl
@@ -0,0 +1,57 @@
+-- Custom keymappings.
+(module settings.keymaps
+ {autoload {nvim aniseed.nvim}})
+
+(def- opts {:noremap true :silent true})
+(defn- map [mode lhs rhs opt]
+ (nvim.set_keymap mode lhs rhs opt)
+
+--Remap space as leader key
+(map "" "<Space>" "<Nop>" opts)
+
+-- Modes
+-- normal_mode = "n"
+-- insert_mode = "i"
+-- visual_mode = "v"
+-- visual_block_mode = "x"
+-- term_mode = "t"
+-- command_mode = "c"
+
+-- Normal --
+-- Better window navigation
+(map "n" "<C-h>" "<C-w>h" opts)
+(map "n" "<C-j>" "<C-w>j" opts)
+(map "n" "<C-k>" "<C-w>k" opts)
+(map "n" "<C-l>" "<C-w>l" opts)
+
+
+-- Resize with arrows
+(map "n" "<C-Up>" ":resize -2<CR>" opts)
+(map "n" "<C-Down>" ":resize +2<CR>" opts)
+(map "n" "<C-Left>" ":vertical resize -2<CR>" opts)
+(map "n" "<C-Right>" ":vertical resize +2<CR>" opts)
+
+-- Navigate buffers
+(map "n" "<S-l>" ":bnext<CR>" opts)
+(map "n" "<S-h>" ":bprevious<CR>" opts)
+
+-- Insert --
+-- Press jk fast to enter
+(map "i" "jk" "<ESC>" opts)
+
+-- Visual --
+-- Stay in indent mode
+(map "v" "<" "<gv" opts)
+(map "v" ">" ">gv" opts)
+
+-- Move text up and down
+(map "v" "<A-j>" ":m .+1<CR>==" opts)
+(map "v" "<A-k>" ":m .-2<CR>==" opts)
+(map "v" "p" '"_dP' opts)
+
+-- Visual Block --
+-- Move text up and down
+(map "x" "J" ":move '>+1<CR>gv-gv" opts)
+(map "x" "K" ":move '<-2<CR>gv-gv" opts)
+(map "x" "<A-j>" ":move '>+1<CR>gv-gv" opts)
+(map "x" "<A-k>" ":move '<-2<CR>gv-gv" opts)