add lazyvim keymaps

This commit is contained in:
Roel de Cort 2024-04-13 01:27:37 +02:00
parent 08d68c00b7
commit 1489d5e976
3 changed files with 515 additions and 0 deletions

467
config/keymaps.nix Normal file
View file

@ -0,0 +1,467 @@
{
globals.mapleader = " ";
keymaps = [
{
mode = ["n" "x"];
key = "j";
action = "v:count == 0 ? 'gj' : 'j'";
options = {expr = true; silent = true;};
}
{
mode = ["n" "x"];
key = "<Down>";
action = "v:count == 0 ? 'gj' : 'j'";
options = {expr = true; silent = true;};
}
{
mode = ["n" "x"];
key = "k";
action = "v:count == 0 ? 'gk' : 'k'";
options = {expr = true; silent = true;};
}
{
mode = ["n" "x"];
key = "<Up>";
action = "v:count == 0 ? 'gk' : 'k'";
options = {expr = true; silent = true;};
}
{
mode = "n";
key = "<C-h>";
action = "<C-w>h";
options = {desc = "Go to Left Window"; remap = true;};
}
{
mode = "n";
key = "<C-j>";
action = "<C-w>j";
options = {desc = "Go to Lower Window"; remap = true;};
}
{
mode = "n";
key = "<C-k>";
action = "<C-w>k";
options = {desc = "Go to Upper Window"; remap = true;};
}
{
mode = "n";
key = "<C-l>";
action = "<C-w>l";
options = {desc = "Go to Right Window"; remap = true;};
}
{
mode = "n";
key = "<C-Up>";
action = "<cmd>resize +2<cr>";
options = {desc = "Increase Window Height";};
}
{
mode = "n";
key = "<C-Down>";
action = "<cmd>resize -2<cr>";
options = {desc = "Decrease Window Height";};
}
{
mode = "n";
key = "<C-Left>";
action = "<cmd>vertical resize -2<cr>";
options = {desc = "Decrease Window Width";};
}
{
mode = "n";
key = "<C-Right>";
action = "<cmd>vertical resize +2<cr>";
options = {desc = "Increase Window Width";};
}
{
mode = "n";
key = "<A-j>";
action = "<cmd>m .+1<cr>==";
options = {desc = "Move Down";};
}
{
mode = "n";
key = "<A-k>";
action = "<cmd>m .-2<cr>==";
options = {desc = "Move Up";};
}
{
mode = "i";
key = "<A-j>";
action = "<esc><cmd>m .+1<cr>==gi";
options = {desc = "Move Down";};
}
{
mode = "i";
key = "<A-k>";
action = "<esc><cmd>m .-2<cr>==gi";
options = {desc = "Move Up";};
}
{
mode = "v";
key = "<A-j>";
action = ":m '>+1<cr>gv=gv";
options = {desc = "Move Down";};
}
{
mode = "v";
key = "<A-k>";
action = ":m '<-2<cr>gv=gv";
options = {desc = "Move Up";};
}
{
mode = "i";
key = ";";
action = ";<c-g>u";
}
{
mode = "i";
key = ".";
action = ".<c-g>u";
}
{
mode = "i";
key = ";";
action = ";<c-g>u";
}
{
mode = ["i" "x" "n" "s"];
key = "<C-s>";
action = "<cmd>w<cr><esc>";
options = {desc = "Save File";};
}
{
mode = ["i" "n"];
key = "<esc>";
action = "<cmd>noh<cr><esc>";
options = {desc = "Escape and Clear hlsearch";};
}
{
mode = "n";
key = "<leader>ur";
action = "<Cmd>nohlsearch<Bar>diffupdate<Bar>normal! <C-L><CR>";
options = {desc = "Redraw / Clear hlsearch / Diff Update";};
}
{
mode = "n";
key = "n";
action = "'Nn'[v:searchforward].'zv'";
options = {expr = true; desc = "Next Search Result";};
}
{
mode = "x";
key = "n";
action = "'Nn'[v:searchforward]";
options = {expr = true; desc = "Next Search Result";};
}
{
mode = "o";
key = "n";
action = "'Nn'[v:searchforward]";
options = {expr = true; desc = "Next Search Result";};
}
{
mode = "n";
key = "N";
action = "'nN'[v:searchforward].'zv'";
options = {expr = true; desc = "Prev Search Result";};
}
{
mode = "x";
key = "N";
action = "'nN'[v:searchforward]";
options = {expr = true; desc = "Prev Search Result";};
}
{
mode = "o";
key = "N";
action = "'nN'[v:searchforward]";
options = {expr = true; desc = "Prev Search Result";};
}
{
mode = ["n" "v"];
key = "<leader>cf";
action = "function()\n LazyVim.format({ force = true })\nend";
options = {desc = "Format";};
}
{
mode = "n";
key = "<leader>cd";
action = "vim.diagnostic.open_float";
options = {desc = "Line Diagnostics";};
}
{
mode = "n";
key = "]d";
action = "diagnostic_goto(true)";
options = {desc = "Next Diagnostic";};
}
{
mode = "n";
key = "[d";
action = "diagnostic_goto(false)";
options = {desc = "Prev Diagnostic";};
}
{
mode = "n";
key = "]e";
action = "diagnostic_goto(true 'ERROR')";
options = {desc = "Next Error";};
}
{
mode = "n";
key = "[e";
action = "diagnostic_goto(false 'ERROR')";
options = {desc = "Prev Error";};
}
{
mode = "n";
key = "]w";
action = "diagnostic_goto(true 'WARN')";
options = {desc = "Next Warning";};
}
{
mode = "n";
key = "[w";
action = "diagnostic_goto(false 'WARN')";
options = {desc = "Prev Warning";};
}
{
mode = "n";
key = "<leader>uf";
action = "function() LazyVim.format.toggle() end";
options = {desc = "Toggle Auto Format (Global)";};
}
{
mode = "n";
key = "<leader>uF";
action = "function() LazyVim.format.toggle(true) end";
options = {desc = "Toggle Auto Format (Buffer)";};
}
{
mode = "n";
key = "<leader>us";
action = "function() LazyVim.toggle('spell') end";
options = {desc = "Toggle Spelling";};
}
{
mode = "n";
key = "<leader>uw";
action = "function() LazyVim.toggle('wrap') end";
options = {desc = "Toggle Word Wrap";};
}
{
mode = "n";
key = "<leader>uL";
action = "function() LazyVim.toggle('relativenumber') end";
options = {desc = "Toggle Relative Line Numbers";};
}
{
mode = "n";
key = "<leader>ul";
action = "function() LazyVim.toggle.number() end";
options = {desc = "Toggle Line Numbers";};
}
{
mode = "n";
key = "<leader>ud";
action = "function() LazyVim.toggle.diagnostics() end";
options = {desc = "Toggle Diagnostics";};
}
{
mode = "n";
key = "<leader>uc";
action = "function() LazyVim.toggle('conceallevel'; false; {0; conceallevel}) end";
options = {desc = "Toggle Conceal";};
}
{
mode = "n";
key = "<leader>uh";
action = "function() if vim.b.ts_highlight then vim.treesitter.stop() else vim.treesitter.start() end end";
options = {desc = "Toggle Treesitter Highlight";};
}
{
mode = "n";
key = "<leader>ub";
action = "function() LazyVim.toggle('background'; false; {'light'; 'dark'}) end";
options = {desc = "Toggle Background";};
}
{
mode = "n";
key = "<leader>gg";
action = "function() LazyVim.lazygit( { cwd = LazyVim.root.git() }) end";
options = {desc = "Lazygit (Root Dir)";};
}
{
mode = "n";
key = "<leader>gG";
action = "function() LazyVim.lazygit() end";
options = {desc = "Lazygit (cwd)";};
}
{
mode = "n";
key = "<leader>gb";
action = "LazyVim.lazygit.blame_line";
options = {desc = "Git Blame Line";};
}
{
mode = "n";
key = "<leader>gf";
action = "function()\n local git_path = vim.api.nvim_buf_get_name(0)\n LazyVim.lazygit({args = { \"-f\"; vim.trim(git_path) }})\nend";
options = {desc = "Lazygit Current File History";};
}
{
mode = "n";
key = "<leader>qq";
action = "<cmd>qa<cr>";
options = {desc = "Quit All";};
}
{
mode = "n";
key = "<leader>ui";
action = "vim.show_pos";
options = {desc = "Inspect Pos";};
}
{
mode = "n";
key = "<leader>ft";
action = "lazyterm";
options = {desc = "Terminal (Root Dir)";};
}
{
mode = "n";
key = "<leader>fT";
action = "function() LazyVim.terminal() end";
options = {desc = "Terminal (cwd)";};
}
{
mode = "n";
key = "<c-/>";
action = "lazyterm";
options = {desc = "Terminal (Root Dir)";};
}
{
mode = "n";
key = "<c-_>";
action = "lazyterm";
options = {desc = "which_key_ignore";};
}
{
mode = "t";
key = "<esc><esc>";
action = "<c-\\><c-n>";
options = {desc = "Enter Normal Mode";};
}
{
mode = "t";
key = "<C-h>";
action = "<cmd>wincmd h<cr>";
options = {desc = "Go to Left Window";};
}
{
mode = "t";
key = "<C-j>";
action = "<cmd>wincmd j<cr>";
options = {desc = "Go to Lower Window";};
}
{
mode = "t";
key = "<C-k>";
action = "<cmd>wincmd k<cr>";
options = {desc = "Go to Upper Window";};
}
{
mode = "t";
key = "<C-l>";
action = "<cmd>wincmd l<cr>";
options = {desc = "Go to Right Window";};
}
{
mode = "t";
key = "<C-/>";
action = "<cmd>close<cr>";
options = {desc = "Hide Terminal";};
}
{
mode = "t";
key = "<c-_>";
action = "<cmd>close<cr>";
options = {desc = "which_key_ignore";};
}
{
mode = "n";
key = "<leader>ww";
action = "<C-W>p";
options = {desc = "Other Window"; remap = true;};
}
{
mode = "n";
key = "<leader>wd";
action = "<C-W>c";
options = {desc = "Delete Window"; remap = true;};
}
{
mode = "n";
key = "<leader>w-";
action = "<C-W>s";
options = {desc = "Split Window Below"; remap = true;};
}
{
mode = "n";
key = "<leader>w|";
action = "<C-W>v";
options = {desc = "Split Window Right"; remap = true;};
}
{
mode = "n";
key = "<leader>-";
action = "<C-W>s";
options = {desc = "Split Window Below"; remap = true;};
}
{
mode = "n";
key = "<leader>|";
action = "<C-W>v";
options = {desc = "Split Window Right"; remap = true;};
}
{
mode = "n";
key = "<leader><tab>l";
action = "<cmd>tablast<cr>";
options = {desc = "Last Tab";};
}
{
mode = "n";
key = "<leader><tab>f";
action = "<cmd>tabfirst<cr>";
options = {desc = "First Tab";};
}
{
mode = "n";
key = "<leader><tab><tab>";
action = "<cmd>tabnew<cr>";
options = {desc = "New Tab";};
}
{
mode = "n";
key = "<leader><tab>]";
action = "<cmd>tabnext<cr>";
options = {desc = "Next Tab";};
}
{
mode = "n";
key = "<leader><tab>d";
action = "<cmd>tabclose<cr>";
options = {desc = "Close Tab";};
}
{
mode = "n";
key = "<leader><tab>[";
action = "<cmd>tabprevious<cr>";
options = {desc = "Previous Tab";};
}
];
}