diff --git a/modules/neovim.nix b/modules/neovim.nix index 49f2216..329323d 100644 --- a/modules/neovim.nix +++ b/modules/neovim.nix @@ -29,43 +29,122 @@ in tabstop = 4; }; - # https://github.com/pupbrained/nix-config/blob/29af4835f21940af51b86313c451fb572a29874a/pkgs/nixvim.nix#L8 - maps.normal = { - "ot" = "vs | te"; - "op" = "NvimTreeToggle"; - "o." = "Telescope file_browser"; - "." = "Telescope find_files"; # cwd full sub-dir fuzzy find - "of" = "Telescope live_grep"; # cwd search file + keymaps = [ + # Modes: https://superuser.com/questions/1702308/how-can-i-configure-shortcut-keys-in-all-modes-of-vim + # n - normal + # i - insert + # c - cmd + # v - visual select + # x - visual only + # s - selection + # o - oper + # t - terminal + # l - lang + { + # Open new vertical split and starts a new terminal window + mode = "n"; + key = "ot"; + action = "vs | te"; + } + { + # toggle the left tree panel + mode = "n"; + key = "op"; + action = "NvimTreeToggle"; + } + { + # Open cwd filename fuzzy search + mode = "n"; + key = "o."; + action = "Telescope file_browser"; + } + { + # Open fuzzy filename recursive search + mode = "n"; + key = "."; + action = "Telescope find_files"; + } + { + # Search file contents of cwd + mode = "n"; + key = "of"; + action = "Telescope live_grep"; + } + { + # Keep cursor centered while navigating + mode = "n"; + key = ""; + action = "zz"; + } + { + # Keep cursor centered while navigating + mode = "n"; + key = ""; + action = "zz"; + } + { + # Keep cursor centered while skipping to search results + mode = "n"; + key = "n"; + action = "nzzzv"; + } + { + # Keep cursor centered while skipping to search results + mode = "n"; + key = "N"; + action = "Nzzzv"; + } + { + # Yank to system clipboard + mode = "n"; + key = "y"; + action = "\"+y"; + } + { + # Yank to system clipboard + mode = "n"; + key = "Y"; + action = "\"+Y"; + } + { + # Delete into the void + mode = "n"; + key = "d"; + action = "\"_d"; + } - # keep cursor centered while navigating - "" = "zz"; - "" = "zz"; - "n" = "nzzzv"; - "N" = "Nzzzv"; + { + # Move visual selection up one row + mode = "v"; + key = "J"; + action = ":m '>+1gv=gv"; + } + { + # Move visual selection down one row + mode = "v"; + key = "K"; + action = ":m '<-2gv=gv"; + } + { + # Yank selection to system clipboard + mode = "v"; + key = "y"; + action = "\"+y"; + } + { + # Delete selection into void + mode = "v"; + key = "d"; + action = "\"_d"; + } - # yank to system clipboard - "y" = "\"+y"; - "Y" = "\"+Y"; - - # perma-delete without putting on any clipboard - "d" = "\"_d"; - }; - - maps.visual = { - # moves visual selection up and down lines - "J" = ":m '>+1gv=gv"; - "K" = ":m '<-2gv=gv"; - - # copy to system clipboard - "y" = "\"+y"; - - # perma-delete without putting on any clipboard - "d" = "\"_d"; - }; - - maps.visualOnly = { - "p" = "\"_dP"; # leader+p deletes the selection to null, then pastes - }; + { + # leader+p delete the selection to the void, then paste + mode = "x"; + key = "p"; + action = "\"_dP"; + } + ]; plugins = {