2024-11-25 17:47:14 -08:00
|
|
|
{lib, ...}: let
|
|
|
|
inherit
|
|
|
|
(lib)
|
2024-11-24 19:46:48 -08:00
|
|
|
map
|
|
|
|
mapAttrsToList
|
|
|
|
toUpper
|
|
|
|
substring
|
|
|
|
mapCartesianProduct
|
|
|
|
toLower
|
|
|
|
;
|
2024-11-25 17:47:14 -08:00
|
|
|
in {
|
2024-11-24 19:46:48 -08:00
|
|
|
globals = {
|
|
|
|
mapleader = " ";
|
|
|
|
maplocalleader = "\\";
|
|
|
|
};
|
|
|
|
|
|
|
|
keymaps =
|
|
|
|
# Disable Arrow Key Movement - - - - - - - - - - - - - - - - - - - - - - - -
|
2024-11-25 17:47:14 -08:00
|
|
|
(
|
|
|
|
map
|
2024-11-24 19:46:48 -08:00
|
|
|
(d: {
|
|
|
|
mode = [
|
|
|
|
"i"
|
|
|
|
"n"
|
|
|
|
];
|
|
|
|
key = d;
|
|
|
|
action = "<nop>";
|
|
|
|
})
|
|
|
|
[
|
|
|
|
"<Down>"
|
|
|
|
"<Up>"
|
|
|
|
"<Left>"
|
|
|
|
"<Right>"
|
|
|
|
]
|
|
|
|
)
|
|
|
|
# Better Up/Down - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2024-11-25 17:47:14 -08:00
|
|
|
++ (
|
|
|
|
mapAttrsToList
|
2024-11-24 19:46:48 -08:00
|
|
|
(d: k: {
|
|
|
|
mode = [
|
|
|
|
"n"
|
|
|
|
"x"
|
|
|
|
];
|
|
|
|
key = k;
|
|
|
|
action = "v:count == 0 ? 'g${k}' : '${k}'";
|
|
|
|
options = {
|
|
|
|
desc = d;
|
|
|
|
expr = true;
|
|
|
|
silent = true;
|
|
|
|
};
|
|
|
|
})
|
|
|
|
{
|
|
|
|
Down = "j";
|
|
|
|
Up = "k";
|
|
|
|
}
|
|
|
|
)
|
|
|
|
# Resize Windows - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2024-11-25 17:47:14 -08:00
|
|
|
++ (
|
|
|
|
mapAttrsToList
|
2024-11-24 19:46:48 -08:00
|
|
|
(
|
2024-11-25 17:47:14 -08:00
|
|
|
k: d: let
|
|
|
|
s =
|
|
|
|
if (d == "Increase")
|
|
|
|
then "+"
|
|
|
|
else "-";
|
|
|
|
in {
|
|
|
|
mode = ["n"];
|
2024-11-24 19:46:48 -08:00
|
|
|
key = "<C-${k}>";
|
|
|
|
action = "<cmd>resize ${s}4<cr>";
|
|
|
|
options = {
|
|
|
|
desc = "${d} Window Height";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
)
|
|
|
|
{
|
|
|
|
Up = "Increase";
|
|
|
|
Down = "Decrease";
|
|
|
|
Left = "Decrease";
|
|
|
|
Right = "Increase";
|
|
|
|
}
|
|
|
|
)
|
|
|
|
# Buffers - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2024-11-25 17:47:14 -08:00
|
|
|
++ (
|
|
|
|
mapAttrsToList
|
2024-11-24 19:46:48 -08:00
|
|
|
(
|
2024-11-25 17:47:14 -08:00
|
|
|
k: d: let
|
2024-11-24 19:46:48 -08:00
|
|
|
# previous -> Prev
|
|
|
|
prettyDir = (toUpper (substring 0 1 d)) + (substring 1 3 d);
|
2024-11-25 17:47:14 -08:00
|
|
|
in {
|
|
|
|
mode = ["n"];
|
2024-11-24 19:46:48 -08:00
|
|
|
key = k;
|
|
|
|
action = "<cmd>b${d}<cr>";
|
|
|
|
options = {
|
|
|
|
desc = "${prettyDir} Buffer";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
)
|
|
|
|
{
|
|
|
|
"<S-h>" = "previous";
|
|
|
|
"<S-l>" = "next";
|
|
|
|
"[b" = "previous";
|
|
|
|
"]b" = "next";
|
|
|
|
}
|
|
|
|
)
|
|
|
|
++ [
|
|
|
|
{
|
2024-11-25 17:47:14 -08:00
|
|
|
mode = ["n"];
|
2024-11-24 19:46:48 -08:00
|
|
|
key = "<leader>bD";
|
|
|
|
action = "<cmd>bd<cr>";
|
|
|
|
options = {
|
|
|
|
desc = "Delete Buffer and Window";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
]
|
|
|
|
# Clear Search/Diff Update/Redraw - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
++ [
|
|
|
|
{
|
|
|
|
mode = [
|
|
|
|
"i"
|
|
|
|
"n"
|
|
|
|
];
|
|
|
|
key = "<esc>";
|
|
|
|
action = "<cmd>noh<cr><esc>";
|
|
|
|
options = {
|
|
|
|
desc = "Escape and Clear hlsearch";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2024-11-25 17:47:14 -08:00
|
|
|
mode = ["n"];
|
2024-11-24 19:46:48 -08:00
|
|
|
key = "<leader>ur";
|
|
|
|
action = "<cmd>nohlsearch<bar>diffupdate<bar>normal! <C-l><cr>";
|
|
|
|
options = {
|
|
|
|
desc = "Redraw / Clear hlsearch / Diff Update";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
]
|
|
|
|
# Better n & N - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2024-11-25 17:47:14 -08:00
|
|
|
++ (
|
|
|
|
mapCartesianProduct
|
2024-11-24 19:46:48 -08:00
|
|
|
(
|
|
|
|
{
|
2024-11-25 17:47:14 -08:00
|
|
|
m,
|
|
|
|
d,
|
|
|
|
}: let
|
|
|
|
nn =
|
|
|
|
if (d == "Next")
|
|
|
|
then "Nn"
|
|
|
|
else "nN";
|
|
|
|
zv =
|
|
|
|
if (m == "n")
|
|
|
|
then ".'zv'"
|
|
|
|
else "";
|
|
|
|
in {
|
|
|
|
mode = [m];
|
|
|
|
key =
|
|
|
|
if (d == "Next")
|
|
|
|
then "n"
|
|
|
|
else "N";
|
2024-11-24 19:46:48 -08:00
|
|
|
action = "'${nn}'[v:searchforward]${zv}";
|
|
|
|
options = {
|
|
|
|
desc = "${d} Search Result";
|
|
|
|
expr = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
)
|
|
|
|
{
|
|
|
|
m = [
|
|
|
|
"n"
|
|
|
|
"x"
|
|
|
|
"o"
|
|
|
|
];
|
|
|
|
d = [
|
|
|
|
"Next"
|
|
|
|
"Prev"
|
|
|
|
];
|
|
|
|
}
|
|
|
|
)
|
|
|
|
# Undo Break-Points - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2024-11-25 17:47:14 -08:00
|
|
|
++ (
|
|
|
|
map
|
2024-11-24 19:46:48 -08:00
|
|
|
(c: {
|
2024-11-25 17:47:14 -08:00
|
|
|
mode = ["i"];
|
2024-11-24 19:46:48 -08:00
|
|
|
key = c;
|
|
|
|
action = "${c}<c-g>u";
|
|
|
|
})
|
|
|
|
[
|
|
|
|
","
|
|
|
|
"."
|
|
|
|
";"
|
|
|
|
]
|
|
|
|
)
|
|
|
|
# Search Docs (keywordprog) - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
# https://til.codeinthehole.com/posts/about-how-to-use-keywordprg-effectively/
|
|
|
|
++ [
|
|
|
|
{
|
2024-11-25 17:47:14 -08:00
|
|
|
mode = ["n"];
|
2024-11-24 19:46:48 -08:00
|
|
|
key = "<leader>K";
|
|
|
|
action = "<cmd>norm! K<cr>";
|
|
|
|
options = {
|
|
|
|
desc = "Search <keywordprog> for word";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
]
|
|
|
|
# Better Indenting - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2024-11-25 17:47:14 -08:00
|
|
|
++ (
|
|
|
|
map
|
2024-11-24 19:46:48 -08:00
|
|
|
(c: {
|
2024-11-25 17:47:14 -08:00
|
|
|
mode = ["v"];
|
2024-11-24 19:46:48 -08:00
|
|
|
key = c;
|
|
|
|
action = "${c}gv";
|
|
|
|
})
|
|
|
|
[
|
|
|
|
"<"
|
|
|
|
">"
|
|
|
|
]
|
|
|
|
)
|
|
|
|
# Commenting - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2024-11-25 17:47:14 -08:00
|
|
|
++ (
|
|
|
|
mapAttrsToList
|
2024-11-24 19:46:48 -08:00
|
|
|
(k: d: {
|
2024-11-25 17:47:14 -08:00
|
|
|
mode = ["n"];
|
2024-11-24 19:46:48 -08:00
|
|
|
key = "gc${k}";
|
|
|
|
action = "${k}<esc>Vcx<esc><cmd>normal gcc<cr>fxa<bs>";
|
|
|
|
options = {
|
|
|
|
desc = "Add Comment ${d}";
|
|
|
|
};
|
|
|
|
})
|
|
|
|
{
|
|
|
|
o = "Below";
|
|
|
|
O = "Above";
|
|
|
|
}
|
|
|
|
)
|
|
|
|
# New File - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
++ [
|
|
|
|
{
|
2024-11-25 17:47:14 -08:00
|
|
|
mode = ["n"];
|
2024-11-24 19:46:48 -08:00
|
|
|
key = "<leader>fn";
|
|
|
|
action = "<cmd>enew<cr>";
|
|
|
|
options = {
|
|
|
|
desc = "New File";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
]
|
|
|
|
# Locations/Quickfixes - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
++ [
|
|
|
|
{
|
2024-11-25 17:47:14 -08:00
|
|
|
mode = ["n"];
|
2024-11-24 19:46:48 -08:00
|
|
|
key = "<leader>xl";
|
|
|
|
action = "<cmd>lopen<cr>";
|
|
|
|
options = {
|
|
|
|
desc = "Location List";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2024-11-25 17:47:14 -08:00
|
|
|
mode = ["n"];
|
2024-11-24 19:46:48 -08:00
|
|
|
key = "<leader>xq";
|
|
|
|
action = "<cmd>copen<cr>";
|
|
|
|
options = {
|
|
|
|
desc = "Quickfix list";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
]
|
2024-11-25 17:47:14 -08:00
|
|
|
++ (
|
|
|
|
mapAttrsToList
|
2024-11-24 19:46:48 -08:00
|
|
|
(
|
2024-11-25 17:47:14 -08:00
|
|
|
k: d: let
|
2024-11-24 19:46:48 -08:00
|
|
|
cmd = substring 0 4 (toLower d);
|
2024-11-25 17:47:14 -08:00
|
|
|
in {
|
|
|
|
mode = ["n"];
|
2024-11-24 19:46:48 -08:00
|
|
|
key = "${k}q";
|
|
|
|
action = "<cmd>c${cmd}<cr>";
|
|
|
|
options = {
|
|
|
|
desc = "${d} Quickfix";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
)
|
|
|
|
{
|
|
|
|
"[" = "Previous";
|
|
|
|
"]" = "Next";
|
|
|
|
}
|
|
|
|
)
|
|
|
|
# Diagnostics - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
++ [
|
|
|
|
{
|
2024-11-25 17:47:14 -08:00
|
|
|
mode = ["n"];
|
2024-11-24 19:46:48 -08:00
|
|
|
key = "<leader>cd";
|
2024-11-25 17:47:14 -08:00
|
|
|
action.__raw =
|
|
|
|
# lua
|
2024-11-24 19:46:48 -08:00
|
|
|
"function() vim.diagnostic.open_float() end";
|
|
|
|
options = {
|
|
|
|
desc = "Line Diagnostics";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
]
|
2024-11-25 17:47:14 -08:00
|
|
|
++ (
|
|
|
|
mapCartesianProduct
|
2024-11-24 19:46:48 -08:00
|
|
|
(
|
2024-11-25 17:47:14 -08:00
|
|
|
{
|
|
|
|
dir,
|
|
|
|
key,
|
|
|
|
}: let
|
2024-11-24 19:46:48 -08:00
|
|
|
sevs = {
|
|
|
|
d = {
|
|
|
|
key = "nil";
|
|
|
|
desc = "Diagnostic";
|
|
|
|
};
|
|
|
|
e = {
|
|
|
|
key = "vim.diagnostic.severity.ERROR";
|
|
|
|
desc = "Error";
|
|
|
|
};
|
|
|
|
w = {
|
|
|
|
key = "vim.diagnostic.severity.WARN";
|
|
|
|
desc = "Warning";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
cmd = toLower dir;
|
|
|
|
sev = sevs."${key}".key;
|
2024-11-25 17:47:14 -08:00
|
|
|
in {
|
|
|
|
mode = ["n"];
|
|
|
|
key = "${
|
|
|
|
if (dir == "Next")
|
|
|
|
then "]"
|
|
|
|
else "["
|
|
|
|
}${key}";
|
|
|
|
action.__raw =
|
|
|
|
# lua
|
2024-11-24 19:46:48 -08:00
|
|
|
"function() vim.diagnostic.goto_${cmd}({ severity = ${sev} }) end";
|
|
|
|
options = {
|
|
|
|
desc = "${dir} ${sevs."${key}".desc}";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
)
|
|
|
|
{
|
|
|
|
dir = [
|
|
|
|
"Next"
|
|
|
|
"Prev"
|
|
|
|
];
|
|
|
|
key = [
|
|
|
|
"d"
|
|
|
|
"e"
|
|
|
|
"w"
|
|
|
|
];
|
|
|
|
}
|
|
|
|
)
|
|
|
|
# Quit - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
++ [
|
|
|
|
{
|
2024-11-25 17:47:14 -08:00
|
|
|
mode = ["n"];
|
2024-11-24 19:46:48 -08:00
|
|
|
key = "<leader>qq";
|
|
|
|
action = "<cmd>qa<cr>";
|
|
|
|
options = {
|
|
|
|
desc = "Quit All";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
]
|
|
|
|
# Inspect - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
++ [
|
|
|
|
{
|
2024-11-25 17:47:14 -08:00
|
|
|
mode = ["n"];
|
2024-11-24 19:46:48 -08:00
|
|
|
key = "<leader>ui";
|
2024-11-25 17:47:14 -08:00
|
|
|
action.__raw =
|
|
|
|
# lua
|
2024-11-24 19:46:48 -08:00
|
|
|
"vim.show_pos";
|
|
|
|
options = {
|
|
|
|
desc = "Inspect Position";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
]
|
|
|
|
# Window Management - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
++ [
|
|
|
|
{
|
2024-11-25 17:47:14 -08:00
|
|
|
mode = ["n"];
|
2024-11-24 19:46:48 -08:00
|
|
|
key = "<leader>w";
|
|
|
|
action = "<C-w>";
|
|
|
|
options = {
|
|
|
|
desc = "Windows";
|
|
|
|
remap = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2024-11-25 17:47:14 -08:00
|
|
|
mode = ["n"];
|
2024-11-24 19:46:48 -08:00
|
|
|
key = "<leader>-";
|
|
|
|
action = "<C-w>s";
|
|
|
|
options = {
|
|
|
|
desc = "Split Window Below";
|
|
|
|
remap = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2024-11-25 17:47:14 -08:00
|
|
|
mode = ["n"];
|
2024-11-24 19:46:48 -08:00
|
|
|
key = "<leader>|";
|
|
|
|
action = "<C-w>v";
|
|
|
|
options = {
|
|
|
|
desc = "Split Window Right";
|
|
|
|
remap = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2024-11-25 17:47:14 -08:00
|
|
|
mode = ["n"];
|
2024-11-24 19:46:48 -08:00
|
|
|
key = "<leader>wd";
|
|
|
|
action = "<C-w>c";
|
|
|
|
options = {
|
|
|
|
desc = "Delete Window";
|
|
|
|
remap = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
]
|
|
|
|
# Tab Management - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2024-11-25 17:47:14 -08:00
|
|
|
++ (
|
|
|
|
mapAttrsToList
|
2024-11-24 19:46:48 -08:00
|
|
|
(k: a: {
|
2024-11-25 17:47:14 -08:00
|
|
|
mode = ["n"];
|
2024-11-24 19:46:48 -08:00
|
|
|
key = "<leader><tab>${k}";
|
|
|
|
action = "<cmd>tab${toLower a}<cr>";
|
|
|
|
options = {
|
2024-11-25 17:47:14 -08:00
|
|
|
desc =
|
|
|
|
if (a == "Only")
|
|
|
|
then "Close Other Tabs"
|
|
|
|
else "${a} Tab";
|
2024-11-24 19:46:48 -08:00
|
|
|
};
|
|
|
|
})
|
|
|
|
{
|
|
|
|
l = "Last";
|
|
|
|
o = "Only";
|
|
|
|
f = "First";
|
|
|
|
"<Tab>" = "New";
|
|
|
|
"]" = "Next";
|
|
|
|
d = "Close";
|
|
|
|
"[" = "Previous";
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|