about summary refs log tree commit diff stats
path: root/home-manager/soispha/config/neovim/nixneovim/mappings
diff options
context:
space:
mode:
Diffstat (limited to 'home-manager/soispha/config/neovim/nixneovim/mappings')
-rw-r--r--home-manager/soispha/config/neovim/nixneovim/mappings/default.nix177
1 files changed, 177 insertions, 0 deletions
diff --git a/home-manager/soispha/config/neovim/nixneovim/mappings/default.nix b/home-manager/soispha/config/neovim/nixneovim/mappings/default.nix
new file mode 100644
index 00000000..8b38a1d0
--- /dev/null
+++ b/home-manager/soispha/config/neovim/nixneovim/mappings/default.nix
@@ -0,0 +1,177 @@
+{lib, ...}: {
+  programs.nixneovim = {
+    globals = {
+      mapleader = " ";
+      maplocalleader = " ";
+    };
+    mapping = let
+      normal_and_insert = {
+        "<Esc>" = {
+          action = "'<cmd>noh<CR><Esc>'";
+          desc = "Disable the search highlighting and send Escape";
+        };
+      };
+    in {
+      insert =
+        lib.recursiveUpate {
+          "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
+            '';
+            desc = "completion trigger/ forward in completen menu";
+          };
+          "<S-Tab>" = {
+            action = ''
+              function()
+                local cmp = require('cmp');
+                cmp.confirm()
+              end
+            '';
+            desc = "confirm the selected item";
+          };
+        }
+        normal_and_insert;
+      normalVisualOp = {
+        # yank/ cut to the system clipboard
+        "<leader>y" = "'\"+y'";
+        "<leader>Y" = "'\"+Y'";
+
+        # Unmap some old keys
+        #"s" = "'<Nop>'";
+        #"t" = "'<Nop>'";
+        "<Up>" = "'<Nop>'";
+        "<Down>" = "'<Nop>'";
+        "<Left>" = "'<Nop>'";
+        "<Right>" = "'<Nop>'";
+
+        # remap dvorak
+        "l" = "n";
+        "L" = "N";
+        "k" = "t";
+        "K" = "T";
+        "j" = "k";
+        "J" = "K";
+
+        # Change Vim-keys
+        "h" = "<left>";
+        "t" = "g<down>";
+        "n" = "g<up>";
+        "s" = "<right>";
+
+        # Move display lines
+        "0" = "g0";
+        "$" = "g$";
+      };
+      normal =
+        lib.recursiveUpdate {
+          "<Tab>" = {
+            action = "':'";
+            desc = "jump to command line";
+          };
+
+          "N" = {
+            action = "vim.diagnostic.goto_prev()";
+            desc = "go to previous diagnostic message";
+          };
+          "T" = {
+            action = "vim.diagnostic.goto_next()";
+            desc = "go to next diagnostic message";
+          };
+          "<leader>e" = {
+            action = "vim.diagnostic.open_float()";
+            desc = "open float for the symbol";
+          };
+          "<leader>q" = {
+            action = "vim.diagnostic.setloclist()";
+            desc = "add buffer diagnostic to the location list (quick-fix)";
+          };
+
+          # 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" = "'o<Esc>'";
+          "O" = "'O<Esc>'";
+
+          # Center the cursor vertically when moving to the next word during a search.
+          "n" = "'nzzzv'";
+          #"N" = "'Nzzzv'";
+
+          "<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
+            '';
+            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 = "to 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" = "':m '>+1<CR>gv=gv'";
+        "N" = "':m '<-2<CR>gv=gv'";
+      };
+    };
+  };
+}