aboutsummaryrefslogtreecommitdiffstats
path: root/hm/soispha/conf/nvim/mappings/default.nix
diff options
context:
space:
mode:
authorSoispha <soispha@vhack.eu>2023-10-08 13:12:44 +0200
committerSoispha <soispha@vhack.eu>2023-10-08 13:12:44 +0200
commit8fbcfc8698f97fc4701d09cb3de3e095d5ddd7c7 (patch)
tree90530153a36e969569115c6e06ea17c473826670 /hm/soispha/conf/nvim/mappings/default.nix
parentchore(version): v1.15.0 (diff)
downloadnixos-config-8fbcfc8698f97fc4701d09cb3de3e095d5ddd7c7.zip
fix(hm/conf/nvim): Update to new keymap format
Diffstat (limited to 'hm/soispha/conf/nvim/mappings/default.nix')
-rw-r--r--hm/soispha/conf/nvim/mappings/default.nix494
1 files changed, 275 insertions, 219 deletions
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 = {
- "<Esc>" = {
- action = "<cmd>noh<CR><Esc>";
- desc = "Disable the search highlighting and send Escape";
- };
- };
- in {
- insert =
- lib.recursiveUpdate {
- "hh" = {
- action = ''
- function()
- local cmp = require('cmp');
- local luasnip = require('luasnip');
+ keymaps = [
+ {
+ mode = ["n" "i"];
+ key = "<Esc>";
+ action = "<cmd>noh<CR><Esc>";
+ 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;
- 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>
+ 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>
+ {
# "<C-Tab>"
- "ztn" = {
- action = "<cmd>tabnext<CR>";
- desc = "cycle to the next tab";
- };
+ key = "ztn";
+ action = "<cmd>tabnext<CR>";
+ options.desc = "cycle to the next tab";
+ }
+ {
# "<S-C-Tab>"
- "ztp" = {
- action = "<cmd>tabprevious<CR>";
- desc = "cycle to the previous tab";
- };
+ key = "ztp";
+ action = "<cmd>tabprevious<CR>";
+ options.desc = "cycle to the previous tab";
+ }
- # yank/ cut to the system clipboard
- "<leader>y" = {
- action = "\"+y";
- desc = "yank to the system clipboard";
- };
- "<leader>Y" = {
- action = "\"+Y";
- desc = "yank until the end of the line to the system clipboard";
- };
+ # yank/ cut to the system clipboard
+ {
+ key = "<leader>y";
+ action = "\"+y";
+ options.desc = "yank to the system clipboard";
+ }
+ {
+ key = "<leader>Y";
+ action = "\"+Y";
+ options.desc = "yank until the end of the line to the system clipboard";
+ }
- # Unmap some old keys
- #"s" = "'<Nop>'";
- #"t" = "'<Nop>'";
- "<Up>" = "<Nop>";
- "<Down>" = "<Nop>";
- "<Left>" = "<Nop>";
- "<Right>" = "<Nop>";
+ # Unmap some old keys
+ #{key = "s"; action = "'<Nop>'";}
+ #{key = "t"; action = "'<Nop>'";}
+ {
+ key = "<Up>";
+ action = "<Nop>";
+ }
+ {
+ key = "<Down>";
+ action = "<Nop>";
+ }
+ {
+ key = "<Left>";
+ action = "<Nop>";
+ }
+ {
+ key = "<Right>";
+ action = "<Nop>";
+ }
- # 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";
- };
+ # 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";
+ }
- # Change Vim-keys
- "h" = {
- action = "<left>";
- desc = "go left";
- };
- "t" = {
- action = "g<down>";
- desc = "go down, with displaylines";
- };
- "n" = {
- action = "g<up>";
- desc = "go up, with displaylines";
- };
- "s" = {
- action = "<right>";
- desc = "go right";
- };
+ # Change Vim-keys
+ {
+ key = "h";
+ action = "<left>";
+ options.desc = "go left";
+ }
+ {
+ key = "t";
+ action = "g<down>";
+ options.desc = "go down, with displaylines";
+ }
+ {
+ key = "n";
+ action = "g<up>";
+ options.desc = "go up, with displaylines";
+ }
+ {
+ key = "s";
+ action = "<right>";
+ options.desc = "go right";
+ }
- # 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 {
- "<Enter>" = {
- action = "gf";
- desc = "open file/url under cursor";
- };
- "<Tab>" = {
- action = ":";
- desc = "jump to command line";
- };
+ # 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 = "<Enter>";
+ action = "gf";
+ options.desc = "open file/url under cursor";
+ }
+ {
+ mode = ["n"];
+ key = "<Tab>";
+ action = ":";
+ options.desc = "jump to command line";
+ }
- "\\f" = {
- action = "function() require('lf').start() end";
- lua = true;
- desc = "open lf in a floating window";
- };
+ {
+ mode = ["n"];
+ key = "\\f";
+ action = "function() require('lf').start() end";
+ lua = true;
+ options.desc = "open lf in a floating window";
+ }
- # Splits
- "<C-t>" = {
- action = "<C-w>p";
- desc = "go to previous split";
- };
- "<C-n>" = {
- action = "<C-w>w";
- desc = "go to next split";
- };
- "<leader>-" = {
- action = "<C-W>s";
- desc = "New horizontal split";
- };
- "<leader>|" = {
- action = "<C-W>v";
- desc = "New vertical split";
- };
+ # Splits
+ {
+ mode = ["n"];
+ key = "<C-t>";
+ action = "<C-w>p";
+ options.desc = "go to previous split";
+ }
+ {
+ mode = ["n"];
+ key = "<C-n>";
+ action = "<C-w>w";
+ options.desc = "go to next split";
+ }
+ {
+ mode = ["n"];
+ key = "<leader>-";
+ action = "<C-W>s";
+ options.desc = "New horizontal split";
+ }
+ {
+ mode = ["n"];
+ key = "<leader>|";
+ action = "<C-W>v";
+ options.desc = "New vertical split";
+ }
- # Exit insert mode after creating a new line above or below the current line.";
- "o" = {
- action = "o<Esc>";
- desc = "add new line below";
- };
- "O" = {
- action = "O<Esc>";
- desc = "add new line above";
- };
+ # Exit insert mode after creating a new line above or below the current line.";
+ {
+ mode = ["n"];
+ key = "o";
+ action = "o<Esc>";
+ options.desc = "add new line below";
+ }
+ {
+ mode = ["n"];
+ key = "O";
+ action = "O<Esc>";
+ options.desc = "add new line above";
+ }
- "<leader>p" = {
- action = "\"_dP";
- desc = "keep the cut thing in the base register";
- };
- "<leader>c" = {
- action = "\"_c";
- desc = "change without saving to register";
- };
+ {
+ mode = ["n"];
+ key = "<leader>p";
+ action = "\"_dP";
+ options.desc = "keep the cut thing in the base register";
+ }
+ {
+ mode = ["n"];
+ key = "<leader>c";
+ action = "\"_c";
+ options.desc = "change without saving to register";
+ }
- "<leader>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;
- };
+ {
+ mode = ["n"];
+ key = "<leader>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;
+ };
+ }
- "<leader>s" = {
- action = ":%s/\\<<C-r><C-w>\\>/<C-r><C-w>/gI<Left><Left><Left>";
- desc = "replace for the word under the cursor";
- };
+ {
+ mode = ["n"];
+ key = "<leader>s";
+ action = ":%s/\\<<C-r><C-w>\\>/<C-r><C-w>/gI<Left><Left><Left>";
+ options.desc = "replace for the word under the cursor";
+ }
- "<C-s>" = {
- action = "<cmd>mksession! <CR>";
- desc = "overwrite/create a session";
- };
+ {
+ mode = ["n"];
+ key = "<C-s>";
+ action = "<cmd>mksession! <CR>";
+ options.desc = "overwrite/create a session";
+ }
- "<leader>X" = {
- action = "!!$SHELL <CR>";
- 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 = {
- "<Esc><Esc>" = {
- action = "<C-\\><C-n>";
- desc = "Exit terminal mode with <Esc><Esc>";
- };
- };
- visual = {
- # move selected lines in visual mode
- "T" = {
- action = ":m '>+1<CR>gv=gv";
- desc = "move selected lines in visual mode down";
- };
- "N" = {
- action = ":m '<-2<CR>gv=gv";
- desc = "move selected lines in visual mode up";
- };
- };
- };
+ {
+ mode = ["n"];
+ key = "<leader>X";
+ action = "!!$SHELL <CR>";
+ 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 = "<Esc><Esc>";
+ action = "<C-\\><C-n>";
+ options.desc = "Exit terminal mode with <Esc><Esc>";
+ }
+
+ # move selected lines in visual mode
+ {
+ mode = ["v"];
+ key = "T";
+ action = ":m '>+1<CR>gv=gv";
+ options.desc = "move selected lines in visual mode down";
+ }
+ {
+ mode = ["v"];
+ key = "N";
+ action = ":m '<-2<CR>gv=gv";
+ options.desc = "move selected lines in visual mode up";
+ }
+ ];
};
}