84 lines
4.4 KiB
Nix
84 lines
4.4 KiB
Nix
{ ... }: {
|
|
programs.nixvim.keymaps =
|
|
let
|
|
map = mode: key: action: { mode = mode; key = key; action = action; };
|
|
nmap = key: action: map [ "n" ] key action;
|
|
nvmap = key: action: map [ "n" "v" ] key action;
|
|
# imap = key: action: map [ "i" ] key action;
|
|
desc = d: { options.desc = d; };
|
|
silent = { options.silent = true; };
|
|
expr = { options.expr = true; };
|
|
in [
|
|
# Unmap keys that aren't useful, or that we want to use for different things
|
|
(nvmap "<Space>" "<Nop>" // silent)
|
|
(nvmap "<Cr>" "<Nop>" // silent)
|
|
(nvmap "s" "<Nop>" // silent)
|
|
# Redo
|
|
(nmap "R" "<C-r>")
|
|
# Copy and paste
|
|
(nvmap "<leader>y" "\"+y" // desc "Cop[y] to clipboard")
|
|
(nvmap "<leader>p" "\"+p" // desc "[P]aste from clipboard")
|
|
# Jump to start/end of line
|
|
(nvmap "H" "0")
|
|
(nvmap "L" "$")
|
|
# Navigate up and down word wrapped text as if it were not word wrapped
|
|
(nmap "k" "v:count == 0 ? 'gk' : 'k'" // silent // expr)
|
|
(nmap "j" "v:count == 0 ? 'gj' : 'j'" // silent // expr)
|
|
# Center cursor when jumping foward or back
|
|
(nmap "<C-o>" "<C-o>zz")
|
|
(nmap "<C-i>" "<C-i>zz")
|
|
# Insert Mode
|
|
|
|
# Normal Mode
|
|
# NVimTree
|
|
(nmap "<leader>n" "<Nop>" // desc "[N]vimTree")
|
|
(nmap "<leader>nf" ":NvimTreeFocus<CR>" // desc "[F]ocus NvimTree")
|
|
(nmap "<leader>nt" ":NvimTreeToggle<CR>" // desc "[T]oggle NvimTree")
|
|
(nmap "<leader>ns" ":NvimTreeFindFile<CR>"// desc "[S]earch NvimTree")
|
|
(nmap "<leader>nc" ":NvimTreeClose<CR>" // desc "[C]lose NvimTree")
|
|
(nmap "<leader>nr" ":NvimTreeRefresh<CR>" // desc "[R]efresh NvimTree")
|
|
(nmap "<leader>nT" ":NoiceTelescope<CR>" // desc "Noice [T]elescope")
|
|
# ToggleTerm
|
|
(nmap "<leader>Tt" ":ToggleTerm<CR>" // desc "[T]oggle Terminal")
|
|
(nmap "<leader>Ts" ":TermSelect<CR>" // desc "[S]elect a terminal")
|
|
# Fugitive
|
|
(nmap "<leader>gc" ":Git cam \"" // desc "[C]ommit" )
|
|
(nmap "<leader>gp" ":Git push<CR>" // desc "Git [p]ush")
|
|
(nmap "<leader>gP" ":Git pull<CR>" // desc "[P]ull")
|
|
(nmap "<leader>ga" ":Git add " // desc "[A]dd file...")
|
|
(nmap "<leader>gb" ":Git blame<CR>" // desc "[B]lame")
|
|
(nmap "<leader>gd" ":Git diff<CR>" // desc "[D]iff")
|
|
# Trouble
|
|
(nmap "<leader>tf" ":Trouble<CR>" // desc "[F]ocus")
|
|
(nmap "<leader>tt" ":TroubleToggle<CR>" // desc "[T]oggle")
|
|
(nmap "<leader>tc" ":TroubleClose<CR>" // desc "[C]lose")
|
|
# Window Management
|
|
(nmap "<leader>wh" ":wincmd h<CR>" // desc "Move left")
|
|
(nmap "<leader>wl" ":wincmd l<CR>" // desc "Move right")
|
|
(nmap "<leader>wj" ":wincmd j<CR>" // desc "Move down")
|
|
(nmap "<leader>wk" ":wincmd k<CR>" // desc "Move up")
|
|
(nmap "<leader>wn" ":wincmd w<CR>" // desc "Move to next")
|
|
(nmap "<leader>wN" ":wincmd p<CR>" // desc "Move to previous")
|
|
(nmap "<leader>wc" ":wincmd c<CR>" // desc "[C]lose active window")
|
|
(nmap "<leader>woh" ":wincmd n<CR>" // desc "Open [H]orizontal window")
|
|
(nmap "<leader>wov" ":wincmd v<CR>" // desc "Open [V]ertical window")
|
|
# resize window
|
|
(nmap "<leader>wrh" ":resize " // desc "Resize Horizontal")
|
|
(nmap "<leader>wrv" ":vertical resize " // desc "Resize Vertical")
|
|
# Buffer Management
|
|
(nmap "<leader>bn" ":bnext<CR>" // desc "Next buffer")
|
|
(nmap "<leader>bN" ":bNext<CR>" // desc "Previous buffer")
|
|
(nmap "<leader>bc" ":bdelete<CR>" // desc "[c]lose buffer")
|
|
(nmap "<leader>bt" ":enew<CR>" // desc "New [T]ab")
|
|
# Multicursors
|
|
(nmap "<leader>ms" ":MCstart<CR>" // desc "[S]tart Multicorsor")
|
|
(nmap "<leader>mv" ":MCvisual<CR>" // desc "[V]isual Multicorsor")
|
|
(nmap "<leader>mc" ":MCclear<CR>" // desc "[C]lear Multicorsor")
|
|
(nmap "<leader>mu" ":MCunderCursor<CR>" // desc "Select [U]nder Corsor")
|
|
(nmap "<leader>mp" ":MCpattern<CR>" // desc "Select [P]attern")
|
|
# Ollama
|
|
(nmap "<leader>os" ":OllamaServe<CR>" // desc "Ollama [S]erve")
|
|
(nmap "<leader>op" ":Ollama<CR>" // desc "Ollama [P]rompt")
|
|
(nmap "<leader>om" ":OllamaModel<CR>" // desc "Ollama [M]odel")
|
|
];
|
|
}
|