aboutsummaryrefslogtreecommitdiffstats
path: root/modules/by-name/nv/nvim/mappings
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-11-09 12:35:44 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-11-09 12:54:51 +0100
commit2122a01f99c6da466b8f0f55c965c11a9043d117 (patch)
tree6c1697afc30a5bb72635bda7db9b5610386a5b71 /modules/by-name/nv/nvim/mappings
parentfix(pkgs/stamp): Fallback to `dot-license` (diff)
downloadnixos-config-2122a01f99c6da466b8f0f55c965c11a9043d117.zip
refactor(modules/legacy/conf/nvim): Move to `by-name`
Diffstat (limited to 'modules/by-name/nv/nvim/mappings')
-rw-r--r--modules/by-name/nv/nvim/mappings/default.nix306
1 files changed, 306 insertions, 0 deletions
diff --git a/modules/by-name/nv/nvim/mappings/default.nix b/modules/by-name/nv/nvim/mappings/default.nix
new file mode 100644
index 00000000..4b6344c2
--- /dev/null
+++ b/modules/by-name/nv/nvim/mappings/default.nix
@@ -0,0 +1,306 @@
+{
+ config,
+ lib,
+ ...
+}: let
+ cfg = config.soispha.programs.nvim;
+in {
+ config.home-manager.users.soispha = lib.mkIf cfg.enable {
+ programs.nixvim = {
+ globals = {
+ mapleader = " ";
+ maplocalleader = " ";
+ };
+ 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.__raw = ''
+ 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
+ '';
+ options.desc = "completion trigger/ forward in completen menu";
+ }
+ {
+ key = "uu";
+ mode = ["i"];
+ action.__raw = ''
+ function()
+ local cmp = require('cmp');
+ cmp.confirm()
+ end
+ '';
+ options.desc = "confirm the selected item";
+ }
+
+ {
+ key = "<C-Tab>";
+ action = "<cmd>tabnext<CR>";
+ options.desc = "cycle to the next tab";
+ }
+ {
+ key = "<S-C-Tab>";
+ action = "<cmd>tabprevious<CR>";
+ options.desc = "cycle to the previous tab";
+ }
+
+ # 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
+ #{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.
+ {
+ 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
+ {
+ 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
+ {
+ 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";
+ }
+
+ {
+ mode = ["n"];
+ key = "\\f";
+ action.__raw = "function() require('lf').start() end";
+ options.desc = "open lf in a floating window";
+ }
+
+ # 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";
+ }
+
+ {
+ 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";
+ }
+
+ {
+ mode = ["n"];
+ key = "<leader>d";
+ action = "\"_d";
+ options.desc = "delete without saving to register";
+ }
+ {
+ key = "x";
+ mode = ["n"];
+ action.__raw = ''
+ function()
+ local col = vim.api.nvim_win_get_cursor(0)[2]
+ local char = vim.api.nvim_get_current_line():sub(col+1,col+1)
+ if char:match("%s") then
+ return '"_x'
+ else
+ return "x"
+ end
+ end
+ '';
+ options = {
+ desc = "Pipe all space only deletions to the blackhole register";
+ expr = true;
+ silent = true;
+ };
+ }
+ {
+ key = "dd";
+ mode = ["n"];
+ action.__raw = ''
+ function()
+ if vim.api.nvim_get_current_line():match("^%s*$") then
+ return '"_dd'
+ else
+ return "dd"
+ end
+ end
+ '';
+ options = {
+ desc = "Pipe all blank line deletions to the blackhole register";
+ expr = true;
+ silent = true;
+ };
+ }
+
+ {
+ 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";
+ }
+
+ {
+ mode = ["n"];
+ key = "<C-s>";
+ action = "<cmd>mksession! <CR>";
+ options.desc = "overwrite/create a session";
+ }
+
+ {
+ 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";
+ }
+ ];
+ };
+ };
+}