From 8fbcfc8698f97fc4701d09cb3de3e095d5ddd7c7 Mon Sep 17 00:00:00 2001 From: Soispha Date: Sun, 8 Oct 2023 13:12:44 +0200 Subject: fix(hm/conf/nvim): Update to new keymap format --- hm/soispha/conf/nvim/mappings/default.nix | 512 +++++++++++++++++------------- 1 file changed, 284 insertions(+), 228 deletions(-) (limited to 'hm/soispha/conf/nvim/mappings/default.nix') diff --git a/hm/soispha/conf/nvim/mappings/default.nix b/hm/soispha/conf/nvim/mappings/default.nix index 1f778d24..d5b4dd30 100644 --- a/hm/soispha/conf/nvim/mappings/default.nix +++ b/hm/soispha/conf/nvim/mappings/default.nix @@ -4,241 +4,297 @@ mapleader = " "; maplocalleader = " "; }; - maps = let - normal_and_insert = { - "" = { - action = "noh"; - desc = "Disable the search highlighting and send Escape"; - }; - }; - in { - insert = - lib.recursiveUpdate { - "hh" = { - action = '' - function() - local cmp = require('cmp'); - local luasnip = require('luasnip'); - - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - end - end - ''; - lua = true; - desc = "completion trigger/ forward in completen menu"; - }; - "uu" = { - action = '' - function() - local cmp = require('cmp'); - cmp.confirm() - end - ''; - lua = true; - desc = "confirm the selected item"; - }; - } - normal_and_insert; - normalVisualOp = { - # FIXME: Add the below keymappings, when alacritty gets support for the kitty - # keyboard protocol <2023-08-29> + keymaps = [ + { + mode = ["n" "i"]; + key = ""; + action = "noh"; + options.desc = "Disable the search highlighting and send Escape"; + } + { + key = "hh"; + mode = ["i"]; + action = '' + function() + local cmp = require('cmp'); + local luasnip = require('luasnip'); + + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + end + end + ''; + lua = true; + options.desc = "completion trigger/ forward in completen menu"; + } + { + key = "uu"; + mode = ["i"]; + action = '' + function() + local cmp = require('cmp'); + cmp.confirm() + end + ''; + lua = true; + options.desc = "confirm the selected item"; + } + # FIXME: Add the below keymappings, when alacritty gets support for the kitty + # keyboard protocol <2023-08-29> + { # "" - "ztn" = { - action = "tabnext"; - desc = "cycle to the next tab"; - }; + key = "ztn"; + action = "tabnext"; + options.desc = "cycle to the next tab"; + } + { # "" - "ztp" = { - action = "tabprevious"; - desc = "cycle to the previous tab"; - }; + key = "ztp"; + action = "tabprevious"; + options.desc = "cycle to the previous tab"; + } - # yank/ cut to the system clipboard - "y" = { - action = "\"+y"; - desc = "yank to the system clipboard"; - }; - "Y" = { - action = "\"+Y"; - desc = "yank until the end of the line to the system clipboard"; - }; + # yank/ cut to the system clipboard + { + key = "y"; + action = "\"+y"; + options.desc = "yank to the system clipboard"; + } + { + key = "Y"; + action = "\"+Y"; + options.desc = "yank until the end of the line to the system clipboard"; + } - # Unmap some old keys - #"s" = "''"; - #"t" = "''"; - "" = ""; - "" = ""; - "" = ""; - "" = ""; - - # Center the cursor vertically when moving to the next word during a search. - "l" = { - action = "nzzzv"; - desc = "Center the cursor vertically when moving to the next word during a - search."; - }; - "L" = { - action = "Nzzzv"; - desc = "Center the cursor vertically when moving to the next word during a - search."; - }; - # remap the other keys to dvorak - "k" = { - action = "t"; - desc = "go the the right on char"; - }; - "K" = { - action = "T"; - desc = "go to the left on char"; - }; - "j" = { - action = "k"; - desc = "go to the right before the char"; - }; - "J" = { - action = "K"; - desc = "go to the left before the char"; - }; + # Unmap some old keys + #{key = "s"; action = "''";} + #{key = "t"; action = "''";} + { + key = ""; + action = ""; + } + { + key = ""; + action = ""; + } + { + key = ""; + action = ""; + } + { + key = ""; + action = ""; + } - # Change Vim-keys - "h" = { - action = ""; - desc = "go left"; - }; - "t" = { - action = "g"; - desc = "go down, with displaylines"; - }; - "n" = { - action = "g"; - desc = "go up, with displaylines"; - }; - "s" = { - action = ""; - desc = "go right"; - }; + # Center the cursor vertically when moving to the next word during a search. + { + key = "l"; + action = "nzzzv"; + options.desc = "Center the cursor vertically when moving to the next word during a search."; + } + { + key = "L"; + action = "Nzzzv"; + options.desc = "Center the cursor vertically when moving to the next word during a search."; + } + # remap the other keys to dvorak + { + key = "k"; + action = "t"; + options.desc = "go the the right on char"; + } + { + key = "K"; + action = "T"; + options.desc = "go to the left on char"; + } + { + key = "j"; + action = "k"; + options.desc = "go to the right before the char"; + } + { + key = "J"; + action = "K"; + options.desc = "go to the left before the char"; + } - # Move display lines - "0" = { - action = "g0"; - desc = "go to the leftmost character in the screen line"; - }; - "$" = { - action = "g$"; - desc = "go to the rightmost character in the screen line"; - }; - }; - normal = - lib.recursiveUpdate { - "" = { - action = "gf"; - desc = "open file/url under cursor"; - }; - "" = { - action = ":"; - desc = "jump to command line"; - }; - - "\\f" = { - action = "function() require('lf').start() end"; - lua = true; - desc = "open lf in a floating window"; - }; - - # Splits - "" = { - action = "p"; - desc = "go to previous split"; - }; - "" = { - action = "w"; - desc = "go to next split"; - }; - "-" = { - action = "s"; - desc = "New horizontal split"; - }; - "|" = { - action = "v"; - desc = "New vertical split"; - }; - - # Exit insert mode after creating a new line above or below the current line."; - "o" = { - action = "o"; - desc = "add new line below"; - }; - "O" = { - action = "O"; - desc = "add new line above"; - }; - - "p" = { - action = "\"_dP"; - desc = "keep the cut thing in the base register"; - }; - "c" = { - action = "\"_c"; - desc = "change without saving to register"; - }; - - "d" = { - action = "\"_d"; - desc = "delete without saving to register"; - }; - "dd" = { - action = '' - function() - if vim.api.nvim_get_current_line():match("^%s*$") then - return '"_dd' - else - return "dd" - end - end - ''; - lua = true; - desc = "Pipe all blank line deletions to the blackhole register"; - expr = true; - silent = true; - }; - - "s" = { - action = ":%s/\\<\\>//gI"; - desc = "replace for the word under the cursor"; - }; - - "" = { - action = "mksession! "; - desc = "overwrite/create a session"; - }; - - "X" = { - action = "!!$SHELL "; - desc = "Read the current line and execute that line in your $SHELL. The resulting output will replace the curent line that was being executed."; - }; - } - normal_and_insert; - terminal = { - "" = { - action = ""; - desc = "Exit terminal mode with "; - }; - }; - visual = { - # move selected lines in visual mode - "T" = { - action = ":m '>+1gv=gv"; - desc = "move selected lines in visual mode down"; - }; - "N" = { - action = ":m '<-2gv=gv"; - desc = "move selected lines in visual mode up"; + # Change Vim-keys + { + key = "h"; + action = ""; + options.desc = "go left"; + } + { + key = "t"; + action = "g"; + options.desc = "go down, with displaylines"; + } + { + key = "n"; + action = "g"; + options.desc = "go up, with displaylines"; + } + { + key = "s"; + action = ""; + options.desc = "go right"; + } + + # Move display lines + { + key = "0"; + action = "g0"; + options.desc = "go to the leftmost character in the screen line"; + } + { + key = "$"; + action = "g$"; + options.desc = "go to the rightmost character in the screen line"; + } + { + mode = ["n"]; + key = ""; + action = "gf"; + options.desc = "open file/url under cursor"; + } + { + mode = ["n"]; + key = ""; + action = ":"; + options.desc = "jump to command line"; + } + + { + mode = ["n"]; + key = "\\f"; + action = "function() require('lf').start() end"; + lua = true; + options.desc = "open lf in a floating window"; + } + + # Splits + { + mode = ["n"]; + key = ""; + action = "p"; + options.desc = "go to previous split"; + } + { + mode = ["n"]; + key = ""; + action = "w"; + options.desc = "go to next split"; + } + { + mode = ["n"]; + key = "-"; + action = "s"; + options.desc = "New horizontal split"; + } + { + mode = ["n"]; + key = "|"; + action = "v"; + options.desc = "New vertical split"; + } + + # Exit insert mode after creating a new line above or below the current line."; + { + mode = ["n"]; + key = "o"; + action = "o"; + options.desc = "add new line below"; + } + { + mode = ["n"]; + key = "O"; + action = "O"; + options.desc = "add new line above"; + } + + { + mode = ["n"]; + key = "p"; + action = "\"_dP"; + options.desc = "keep the cut thing in the base register"; + } + { + mode = ["n"]; + key = "c"; + action = "\"_c"; + options.desc = "change without saving to register"; + } + + { + mode = ["n"]; + key = "d"; + action = "\"_d"; + options.desc = "delete without saving to register"; + } + { + key = "dd"; + mode = ["n"]; + action = '' + function() + if vim.api.nvim_get_current_line():match("^%s*$") then + return '"_dd' + else + return "dd" + end + end + ''; + lua = true; + options = { + desc = "Pipe all blank line deletions to the blackhole register"; + expr = true; + silent = true; }; - }; - }; + } + + { + mode = ["n"]; + key = "s"; + action = ":%s/\\<\\>//gI"; + options.desc = "replace for the word under the cursor"; + } + + { + mode = ["n"]; + key = ""; + action = "mksession! "; + options.desc = "overwrite/create a session"; + } + + { + mode = ["n"]; + key = "X"; + action = "!!$SHELL "; + options.desc = "Read the current line and execute that line in your $SHELL. The resulting output will replace the curent line that was being executed."; + } + { + mode = ["t"]; + key = ""; + action = ""; + options.desc = "Exit terminal mode with "; + } + + # move selected lines in visual mode + { + mode = ["v"]; + key = "T"; + action = ":m '>+1gv=gv"; + options.desc = "move selected lines in visual mode down"; + } + { + mode = ["v"]; + key = "N"; + action = ":m '<-2gv=gv"; + options.desc = "move selected lines in visual mode up"; + } + ]; }; } -- cgit 1.4.1