2024-11-25 18:29:33 -08:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
helpers,
|
|
|
|
...
|
|
|
|
}: let
|
2024-11-25 17:47:14 -08:00
|
|
|
inherit
|
|
|
|
(lib)
|
2024-11-24 19:46:48 -08:00
|
|
|
map
|
|
|
|
mapAttrsToList
|
|
|
|
toUpper
|
|
|
|
substring
|
|
|
|
mapCartesianProduct
|
|
|
|
toLower
|
|
|
|
;
|
2024-11-25 18:29:33 -08:00
|
|
|
|
2024-11-25 20:33:41 -08:00
|
|
|
inherit (lib.marleyvim) keys;
|
2024-11-25 18:29:33 -08:00
|
|
|
inherit (helpers) mkRaw;
|
2024-11-25 17:47:14 -08:00
|
|
|
in {
|
2024-11-24 19:46:48 -08:00
|
|
|
globals = {
|
|
|
|
mapleader = " ";
|
|
|
|
maplocalleader = "\\";
|
|
|
|
};
|
|
|
|
|
|
|
|
keymaps =
|
2024-11-25 18:58:53 -08:00
|
|
|
#
|
2024-11-24 19:46:48 -08:00
|
|
|
# Disable Arrow Key Movement - - - - - - - - - - - - - - - - - - - - - - - -
|
2024-11-25 21:23:29 -08:00
|
|
|
(map (d: keys.mk' ["i" "n"] d "<NOP>") ["<DOWN>" "<UP>" "<LEFT>" "<RIGHT>"])
|
2024-11-25 18:58:53 -08:00
|
|
|
#
|
2024-11-24 19:46:48 -08:00
|
|
|
# Better Up/Down - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2024-11-25 17:47:14 -08:00
|
|
|
++ (
|
|
|
|
mapAttrsToList
|
2024-11-25 18:58:53 -08:00
|
|
|
(d: k:
|
2024-11-25 19:05:18 -08:00
|
|
|
keys.mkWithOpts ["n" "x"] k "v:count == 0 ? 'g${k}' : '${k}'" d
|
2024-11-25 21:11:06 -08:00
|
|
|
{
|
|
|
|
expr = true;
|
|
|
|
silent = true;
|
|
|
|
})
|
2024-11-24 19:46:48 -08:00
|
|
|
{
|
|
|
|
Down = "j";
|
|
|
|
Up = "k";
|
|
|
|
}
|
|
|
|
)
|
2024-11-25 18:58:53 -08:00
|
|
|
#
|
2024-11-24 19:46:48 -08:00
|
|
|
# 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 "-";
|
2024-11-25 18:58:53 -08:00
|
|
|
in
|
2024-11-25 21:23:29 -08:00
|
|
|
keys.mk ["n"] "<C-${k}>" "<CMD>resize ${s}4<CR>" "${d} Window Height"
|
2024-11-24 19:46:48 -08:00
|
|
|
)
|
|
|
|
{
|
|
|
|
Up = "Increase";
|
|
|
|
Down = "Decrease";
|
|
|
|
Left = "Decrease";
|
|
|
|
Right = "Increase";
|
|
|
|
}
|
|
|
|
)
|
2024-11-25 18:58:53 -08:00
|
|
|
#
|
2024-11-24 19:46:48 -08:00
|
|
|
# Buffers - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2024-11-25 17:47:14 -08:00
|
|
|
++ (
|
2024-11-25 18:58:53 -08:00
|
|
|
mapAttrsToList (
|
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 18:58:53 -08:00
|
|
|
in
|
2024-11-25 21:23:29 -08:00
|
|
|
keys.mk ["n"] k "<CMD>b${d}<CR>" "${prettyDir} Buffer"
|
2024-11-24 19:46:48 -08:00
|
|
|
)
|
|
|
|
{
|
2024-11-25 21:23:29 -08:00
|
|
|
"<S-H>" = "previous";
|
|
|
|
"<S-L>" = "next";
|
2024-11-24 19:46:48 -08:00
|
|
|
"[b" = "previous";
|
|
|
|
"]b" = "next";
|
|
|
|
}
|
|
|
|
)
|
2024-11-25 21:23:29 -08:00
|
|
|
++ [(keys.mk ["n"] "<LEADER>bD" "<CMD>bd<CR>" "Delete Buffer and Window")]
|
2024-11-25 18:58:53 -08:00
|
|
|
#
|
2024-11-24 19:46:48 -08:00
|
|
|
# Clear Search/Diff Update/Redraw - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
++ [
|
2024-11-25 21:23:29 -08:00
|
|
|
(keys.mk ["i" "n"] "<ESC>" "<CMD>noh<CR><ESC>" "Escape and Clear hlsearch")
|
2024-11-25 18:29:33 -08:00
|
|
|
(
|
2024-11-25 21:23:29 -08:00
|
|
|
keys.mk ["n"] "<LEADER>ur"
|
|
|
|
"<CMD>nohlsearch<BAR>diffupdate<BAR>normal! <C-l><CR>"
|
2024-11-25 18:29:33 -08:00
|
|
|
"Redraw / Clear hlsearch / Diff Update"
|
|
|
|
)
|
2024-11-24 19:46:48 -08:00
|
|
|
]
|
2024-11-25 18:58:53 -08:00
|
|
|
#
|
2024-11-24 19:46:48 -08:00
|
|
|
# Better n & N - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2024-11-25 17:47:14 -08:00
|
|
|
++ (
|
2024-11-25 18:58:53 -08:00
|
|
|
mapCartesianProduct (
|
2024-11-24 19:46:48 -08:00
|
|
|
{
|
2024-11-25 17:47:14 -08:00
|
|
|
m,
|
|
|
|
d,
|
|
|
|
}: let
|
2024-11-25 18:58:53 -08:00
|
|
|
k =
|
|
|
|
if (d == "Next")
|
|
|
|
then "n"
|
|
|
|
else "N";
|
2024-11-25 17:47:14 -08:00
|
|
|
nn =
|
|
|
|
if (d == "Next")
|
|
|
|
then "Nn"
|
|
|
|
else "nN";
|
|
|
|
zv =
|
|
|
|
if (m == "n")
|
|
|
|
then ".'zv'"
|
|
|
|
else "";
|
2024-11-25 18:58:53 -08:00
|
|
|
in
|
2024-11-25 19:05:18 -08:00
|
|
|
keys.mkWithOpts [m] k "'${nn}'[v:searchforward]${zv}"
|
2024-11-25 18:58:53 -08:00
|
|
|
"${d} Search Result" {expr = true;}
|
2024-11-24 19:46:48 -08:00
|
|
|
)
|
|
|
|
{
|
2024-11-25 18:58:53 -08:00
|
|
|
m = ["n" "x" "o"];
|
|
|
|
d = ["Next" "Prev"];
|
2024-11-24 19:46:48 -08:00
|
|
|
}
|
|
|
|
)
|
2024-11-25 18:58:53 -08:00
|
|
|
#
|
2024-11-24 19:46:48 -08:00
|
|
|
# Undo Break-Points - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2024-11-25 21:23:29 -08:00
|
|
|
++ (map (c: keys.mk' ["i"] c "${c}<C-g>u") ["," "." ";"])
|
2024-11-25 18:58:53 -08:00
|
|
|
#
|
2024-11-24 19:46:48 -08:00
|
|
|
# Search Docs (keywordprog) - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
# https://til.codeinthehole.com/posts/about-how-to-use-keywordprg-effectively/
|
2024-11-25 21:23:29 -08:00
|
|
|
++ [(keys.mk ["n"] "<LEADER>K" "<CMD>norm! K<CR>" "Search <KEYWORDPROG> for word")]
|
2024-11-25 18:58:53 -08:00
|
|
|
#
|
2024-11-24 19:46:48 -08:00
|
|
|
# Better Indenting - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2024-11-25 19:05:18 -08:00
|
|
|
++ (map (c: keys.mk' ["v"] c "${c}gv") ["<" ">"])
|
2024-11-25 18:58:53 -08:00
|
|
|
#
|
2024-11-24 19:46:48 -08:00
|
|
|
# Commenting - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2024-11-25 17:47:14 -08:00
|
|
|
++ (
|
2024-11-25 18:58:53 -08:00
|
|
|
mapAttrsToList (
|
|
|
|
k: d:
|
2024-11-25 21:23:29 -08:00
|
|
|
keys.mk ["n"] "gc${k}" "${k}<ESC>Vcx<ESC><CMD>normal gcc<CR>fxa<BS>"
|
2024-11-25 19:05:18 -08:00
|
|
|
"Add Comment ${d}"
|
2024-11-25 18:58:53 -08:00
|
|
|
)
|
2024-11-24 19:46:48 -08:00
|
|
|
{
|
|
|
|
o = "Below";
|
|
|
|
O = "Above";
|
|
|
|
}
|
|
|
|
)
|
2024-11-25 18:58:53 -08:00
|
|
|
#
|
2024-11-24 19:46:48 -08:00
|
|
|
# New File - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2024-11-25 21:23:29 -08:00
|
|
|
++ [(keys.mk ["n"] "<LEADER>fn" "<CMD>enew<CR>" "New File")]
|
2024-11-25 18:58:53 -08:00
|
|
|
#
|
2024-11-24 19:46:48 -08:00
|
|
|
# Locations/Quickfixes - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
++ [
|
2024-11-25 21:23:29 -08:00
|
|
|
(keys.mk ["n"] "<LEADER>xl" "<CMD>lopen<CR>" "Location List")
|
|
|
|
(keys.mk ["n"] "<LEADER>xq" "<CMD>copen<CR>" "Quickfix list")
|
2024-11-24 19:46:48 -08:00
|
|
|
]
|
2024-11-25 17:47:14 -08:00
|
|
|
++ (
|
2024-11-25 18:58:53 -08:00
|
|
|
mapAttrsToList (
|
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 18:58:53 -08:00
|
|
|
in
|
2024-11-25 21:23:29 -08:00
|
|
|
keys.mk ["n"] "${k}q" "<CMD>c${cmd}<CR>" "${d} Quickfix"
|
2024-11-24 19:46:48 -08:00
|
|
|
)
|
|
|
|
{
|
|
|
|
"[" = "Previous";
|
|
|
|
"]" = "Next";
|
|
|
|
}
|
|
|
|
)
|
2024-11-25 18:58:53 -08:00
|
|
|
#
|
2024-11-24 19:46:48 -08:00
|
|
|
# Diagnostics - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
++ [
|
2024-11-25 21:23:29 -08:00
|
|
|
(keys.mk ["n"] "<LEADER>cd" (
|
2024-11-26 20:50:32 -08:00
|
|
|
mkRaw ''
|
|
|
|
function() vim.diagnostic.open_float() end
|
|
|
|
''
|
2024-11-25 18:29:33 -08:00
|
|
|
) "Line Diagnostics")
|
2024-11-24 19:46:48 -08:00
|
|
|
]
|
2024-11-25 17:47:14 -08:00
|
|
|
++ (
|
2024-11-25 18:58:53 -08:00
|
|
|
mapCartesianProduct (
|
2024-11-25 17:47:14 -08:00
|
|
|
{
|
|
|
|
dir,
|
|
|
|
key,
|
|
|
|
}: let
|
2024-11-25 18:58:53 -08:00
|
|
|
kmap = "${
|
|
|
|
if (dir == "Next")
|
|
|
|
then "]"
|
|
|
|
else "["
|
|
|
|
}${key}";
|
|
|
|
|
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 18:58:53 -08:00
|
|
|
in
|
2024-11-26 20:50:32 -08:00
|
|
|
keys.mk ["n"] kmap (
|
|
|
|
mkRaw ''
|
|
|
|
function() vim.diagnostic.goto_${cmd}({ severity = ${sev} }) end
|
|
|
|
''
|
|
|
|
) "${dir} ${sevs."${key}".desc}"
|
2024-11-24 19:46:48 -08:00
|
|
|
)
|
|
|
|
{
|
2024-11-25 18:58:53 -08:00
|
|
|
dir = ["Next" "Prev"];
|
|
|
|
key = ["d" "e" "w"];
|
2024-11-24 19:46:48 -08:00
|
|
|
}
|
|
|
|
)
|
2024-11-25 18:58:53 -08:00
|
|
|
#
|
2024-11-24 19:46:48 -08:00
|
|
|
# Quit - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2024-11-25 21:23:29 -08:00
|
|
|
++ [(keys.mk ["n"] "<LEADER>qq" "<CMD>qa<CR>" "Quit All")]
|
2024-11-25 18:58:53 -08:00
|
|
|
#
|
2024-11-24 19:46:48 -08:00
|
|
|
# Inspect - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2024-11-25 21:23:29 -08:00
|
|
|
++ [(keys.mk ["n"] "<LEADER>ui" (mkRaw "vim.show_pos") "Inspect Position")]
|
2024-11-25 18:58:53 -08:00
|
|
|
#
|
2024-11-24 19:46:48 -08:00
|
|
|
# Window Management - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
++ [
|
2024-11-25 21:23:29 -08:00
|
|
|
(keys.mkWithOpts ["n"] "<LEADER>w" "<C-w>" "Windows" {remap = true;})
|
|
|
|
(keys.mkWithOpts ["n"] "<LEADER>-" "<C-w>s" "Split Window Below" {remap = true;})
|
|
|
|
(keys.mkWithOpts ["n"] "<LEADER>|" "<C-w>v" "Split Window Right" {remap = true;})
|
|
|
|
(keys.mkWithOpts ["n"] "<LEADER>wd" "<C-w>c" "Delete Window" {remap = true;})
|
2024-11-24 19:46:48 -08:00
|
|
|
]
|
2024-11-25 18:58:53 -08:00
|
|
|
#
|
2024-11-24 19:46:48 -08:00
|
|
|
# Tab Management - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2024-11-25 17:47:14 -08:00
|
|
|
++ (
|
2024-11-25 18:58:53 -08:00
|
|
|
mapAttrsToList (
|
|
|
|
k: a: let
|
2024-11-25 17:47:14 -08:00
|
|
|
desc =
|
|
|
|
if (a == "Only")
|
|
|
|
then "Close Other Tabs"
|
|
|
|
else "${a} Tab";
|
2024-11-25 18:58:53 -08:00
|
|
|
in
|
2024-11-25 21:23:29 -08:00
|
|
|
keys.mk ["n"] "<LEADER><TAB>${k}" "<CMD>tab${toLower a}<CR>" desc
|
2024-11-25 18:58:53 -08:00
|
|
|
)
|
2024-11-24 19:46:48 -08:00
|
|
|
{
|
|
|
|
l = "Last";
|
|
|
|
o = "Only";
|
|
|
|
f = "First";
|
2024-11-25 21:23:29 -08:00
|
|
|
"<TAB>" = "New";
|
2024-11-24 19:46:48 -08:00
|
|
|
"]" = "Next";
|
|
|
|
d = "Close";
|
|
|
|
"[" = "Previous";
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|