This commit is contained in:
iFargle 2024-02-08 14:32:46 +09:00
parent e33849ec54
commit f49091e960

View file

@ -11,6 +11,38 @@
globals.mapleader = " "; globals.mapleader = " ";
globals.maplocalleader = " "; globals.maplocalleader = " ";
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)
# Leave insert mode by pressing j and k simultaneously
(imap "jk" "<Esc>")
(imap "kj" "<Esc>")
# 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")
];
options = { options = {
number = true; number = true;
shiftwidth = 2; shiftwidth = 2;
@ -38,8 +70,37 @@
telescope = { telescope = {
enable = true; enable = true;
extensions = { extensions.frecency.enable = true;
frecency.enable = true; extensions.fzf-native.enable = true;
keymaps = {
"<leader><leader>" = {
action = "find_files";
desc = "Search files by name";
};
"ss" = {
action = "live_grep";
desc = "[S]earch by live grep";
};
"sb" = {
action = "buffers";
desc = "[S]earch open [B]uffers by file name";
};
"sh" = {
action = "help_tags";
desc = "[S]earch [H]elp";
};
"sw" = {
action = "grep_string";
desc = "[S]earch for [W]ord under cursor";
};
"sg" = {
action = "buffers";
desc = "[S]earch [G]it files";
};
"sr" = {
action = "oldfiles";
desc = "[S]earch [R]ecently opened files by name";
};
}; };
}; };