diff options
author | Soispha <soispha@vhack.eu> | 2023-08-26 23:42:21 +0200 |
---|---|---|
committer | Soispha <soispha@vhack.eu> | 2023-08-26 23:42:21 +0200 |
commit | 3f600ab07dbad3b6dd7655587ddea158b19aea71 (patch) | |
tree | 7164ccd965e1d14ade970aeb8eb188b1442a6c91 /hm/soispha/conf/nvim/mappings/default.nix | |
parent | Style(treewide): Format all lua-files makes lua ➛ nix easier (diff) | |
download | nixos-config-3f600ab07dbad3b6dd7655587ddea158b19aea71.zip |
Refactor(treewide): Abbreviate path names
Diffstat (limited to 'hm/soispha/conf/nvim/mappings/default.nix')
-rw-r--r-- | hm/soispha/conf/nvim/mappings/default.nix | 222 |
1 files changed, 222 insertions, 0 deletions
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 = { + "<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'); + + 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 + "<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"; + }; + + # Unmap some old keys + #"s" = "'<Nop>'"; + #"t" = "'<Nop>'"; + "<Up>" = "<Nop>"; + "<Down>" = "<Nop>"; + "<Left>" = "<Nop>"; + "<Right>" = "<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"; + }; + + # 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"; + }; + + # 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 { + "<Tab>" = { + action = ":"; + desc = "jump to command line"; + }; + + "\\f" = { + action = "function() require('lf').start() end"; + lua = true; + 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"; + }; + + # 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"; + }; + + "<leader>p" = { + action = "\"_dP"; + desc = "keep the cut thing in the base 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; + }; + + "<leader>s" = { + action = ":%s/\\<<C-r><C-w>\\>/<C-r><C-w>/gI<Left><Left><Left>"; + desc = "replace for the word under the cursor"; + }; + + "<C-s>" = { + action = "<cmd>mksession! <CR>"; + 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"; + }; + }; + }; + }; +} |