From 3f600ab07dbad3b6dd7655587ddea158b19aea71 Mon Sep 17 00:00:00 2001 From: Soispha Date: Sat, 26 Aug 2023 23:42:21 +0200 Subject: Refactor(treewide): Abbreviate path names --- hm/soispha/conf/nvim/mappings/default.nix | 222 ++++++++++++++++++++++++++++++ 1 file changed, 222 insertions(+) create mode 100644 hm/soispha/conf/nvim/mappings/default.nix (limited to 'hm/soispha/conf/nvim/mappings') diff --git a/hm/soispha/conf/nvim/mappings/default.nix b/hm/soispha/conf/nvim/mappings/default.nix new file mode 100644 index 00000000..1d00b0a4 --- /dev/null +++ b/hm/soispha/conf/nvim/mappings/default.nix @@ -0,0 +1,222 @@ +{lib, ...}: { + programs.nixvim = { + globals = { + 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"; + }; + "cc" = { + action = '' + function() + local cmp = require('cmp'); + cmp.confirm() + end + ''; + lua = true; + desc = "confirm the selected item"; + }; + } + normal_and_insert; + normalVisualOp = { + # 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"; + }; + + # 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"; + }; + + # 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"; + }; + + # 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 = ":"; + 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"; + }; + + "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"; + }; + }; + }; + }; +} -- cgit 1.4.1