{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"; }; "HH" = { 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" = "\"+y"; "<leader>Y" = "\"+Y"; # 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" = "nzzzv"; "L" = "Nzzzv"; # remap the other keys to dvorak "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"; }; "\\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" = "o<Esc>"; "O" = "O<Esc>"; "<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 = "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"; }; }; }; }