feat: Rename key lib fns
This commit is contained in:
parent
43ce08cb9c
commit
5458b7a99a
3 changed files with 47 additions and 51 deletions
|
@ -1,6 +1,6 @@
|
|||
_: {
|
||||
keys = rec {
|
||||
mkKeymap = mode: key: action: desc: {
|
||||
mk = mode: key: action: desc: {
|
||||
inherit mode key action;
|
||||
options = {
|
||||
inherit desc;
|
||||
|
@ -8,19 +8,16 @@ _: {
|
|||
};
|
||||
};
|
||||
|
||||
mkKeymap' =
|
||||
mode: key: action:
|
||||
mkKeymap mode key action null;
|
||||
mk' = mode: key: action:
|
||||
mk mode key action null;
|
||||
|
||||
mkKeymapWithOpts =
|
||||
mode: key: action: desc: opts:
|
||||
(mkKeymap mode key action desc)
|
||||
mkWithOpts = mode: key: action: desc: opts:
|
||||
(mk mode key action desc)
|
||||
// {
|
||||
options = opts;
|
||||
};
|
||||
|
||||
mkKeymapWithOpts' =
|
||||
mode: key: action: opts:
|
||||
mkKeymapWithOpts mode key action null opts;
|
||||
mkWithOpts' = mode: key: action: opts:
|
||||
mkWithOpts mode key action null opts;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
toLower
|
||||
;
|
||||
|
||||
inherit (lib.marleyos.keys) mkKeymap mkKeymap' mkKeymapWithOpts;
|
||||
inherit (lib.marleyos) keys;
|
||||
inherit (helpers) mkRaw;
|
||||
in {
|
||||
globals = {
|
||||
|
@ -24,13 +24,13 @@ in {
|
|||
keymaps =
|
||||
#
|
||||
# Disable Arrow Key Movement - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
(map (d: mkKeymap' ["i" "n"] d "<nop>") ["<Down>" "<Up>" "<Left>" "<Right>"])
|
||||
(map (d: keys.mk' ["i" "n"] d "<nop>") ["<Down>" "<Up>" "<Left>" "<Right>"])
|
||||
#
|
||||
# Better Up/Down - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
++ (
|
||||
mapAttrsToList
|
||||
(d: k:
|
||||
mkKeymapWithOpts ["n" "x"] k "v:count == 0 ? 'g${k}' : '${k}'" d
|
||||
keys.mkWithOpts ["n" "x"] k "v:count == 0 ? 'g${k}' : '${k}'" d
|
||||
{expr = true;})
|
||||
{
|
||||
Down = "j";
|
||||
|
@ -48,7 +48,7 @@ in {
|
|||
then "+"
|
||||
else "-";
|
||||
in
|
||||
mkKeymap ["n"] "<C-${k}>" "<cmd>resize ${s}4<cr>" "${d} Window Height"
|
||||
keys.mk ["n"] "<C-${k}>" "<cmd>resize ${s}4<cr>" "${d} Window Height"
|
||||
)
|
||||
{
|
||||
Up = "Increase";
|
||||
|
@ -65,7 +65,7 @@ in {
|
|||
# previous -> Prev
|
||||
prettyDir = (toUpper (substring 0 1 d)) + (substring 1 3 d);
|
||||
in
|
||||
mkKeymap ["n"] k "<cmd>b${d}<cr>" "${prettyDir} Buffer"
|
||||
keys.mk ["n"] k "<cmd>b${d}<cr>" "${prettyDir} Buffer"
|
||||
)
|
||||
{
|
||||
"<S-h>" = "previous";
|
||||
|
@ -74,13 +74,13 @@ in {
|
|||
"]b" = "next";
|
||||
}
|
||||
)
|
||||
++ [(mkKeymap ["n"] "<leader>bD" "<cmd>bd<cr>" "Delete Buffer and Window")]
|
||||
++ [(keys.mk ["n"] "<leader>bD" "<cmd>bd<cr>" "Delete Buffer and Window")]
|
||||
#
|
||||
# Clear Search/Diff Update/Redraw - - - - - - - - - - - - - - - - - - - - -
|
||||
++ [
|
||||
(mkKeymap ["i" "n"] "<esc>" "<cmd>noh<cr><esc>" "Escape and Clear hlsearch")
|
||||
(keys.mk ["i" "n"] "<esc>" "<cmd>noh<cr><esc>" "Escape and Clear hlsearch")
|
||||
(
|
||||
mkKeymap ["n"] "<leader>ur"
|
||||
keys.mk ["n"] "<leader>ur"
|
||||
"<cmd>nohlsearch<bar>diffupdate<bar>normal! <C-l><cr>"
|
||||
"Redraw / Clear hlsearch / Diff Update"
|
||||
)
|
||||
|
@ -106,7 +106,7 @@ in {
|
|||
then ".'zv'"
|
||||
else "";
|
||||
in
|
||||
mkKeymapWithOpts [m] k "'${nn}'[v:searchforward]${zv}"
|
||||
keys.mkWithOpts [m] k "'${nn}'[v:searchforward]${zv}"
|
||||
"${d} Search Result" {expr = true;}
|
||||
)
|
||||
{
|
||||
|
@ -116,24 +116,21 @@ in {
|
|||
)
|
||||
#
|
||||
# Undo Break-Points - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
++ (map (c: mkKeymap' ["i"] c "${c}<c-g>u") ["," "." ";"])
|
||||
++ (map (c: keys.mk' ["i"] c "${c}<c-g>u") ["," "." ";"])
|
||||
#
|
||||
# Search Docs (keywordprog) - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# https://til.codeinthehole.com/posts/about-how-to-use-keywordprg-effectively/
|
||||
++ [
|
||||
(mkKeymap ["n"] "<leader>K" "<cmd>norm! K<cr>"
|
||||
"Search <keywordprog> for word")
|
||||
]
|
||||
++ [(keys.mk ["n"] "<leader>K" "<cmd>norm! K<cr>" "Search <keywordprog> for word")]
|
||||
#
|
||||
# Better Indenting - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
++ (map (c: mkKeymap' ["v"] c "${c}gv") ["<" ">"])
|
||||
++ (map (c: keys.mk' ["v"] c "${c}gv") ["<" ">"])
|
||||
#
|
||||
# Commenting - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
++ (
|
||||
mapAttrsToList (
|
||||
k: d:
|
||||
mkKeymap ["n"] "gc${k}"
|
||||
"${k}<esc>Vcx<esc><cmd>normal gcc<cr>fxa<bs>" "Add Comment ${d}"
|
||||
keys.mk ["n"] "gc${k}" "${k}<esc>Vcx<esc><cmd>normal gcc<cr>fxa<bs>"
|
||||
"Add Comment ${d}"
|
||||
)
|
||||
{
|
||||
o = "Below";
|
||||
|
@ -142,19 +139,19 @@ in {
|
|||
)
|
||||
#
|
||||
# New File - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
++ [(mkKeymap ["n"] "<leader>fn" "<cmd>enew<cr>" "New File")]
|
||||
++ [(keys.mk ["n"] "<leader>fn" "<cmd>enew<cr>" "New File")]
|
||||
#
|
||||
# Locations/Quickfixes - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
++ [
|
||||
(mkKeymap ["n"] "<leader>xl" "<cmd>lopen<cr>" "Location List")
|
||||
(mkKeymap ["n"] "<leader>xq" "<cmd>copen<cr>" "Quickfix list")
|
||||
(keys.mk ["n"] "<leader>xl" "<cmd>lopen<cr>" "Location List")
|
||||
(keys.mk ["n"] "<leader>xq" "<cmd>copen<cr>" "Quickfix list")
|
||||
]
|
||||
++ (
|
||||
mapAttrsToList (
|
||||
k: d: let
|
||||
cmd = substring 0 4 (toLower d);
|
||||
in
|
||||
mkKeymap ["n"] "${k}q" "<cmd>c${cmd}<cr>" "${d} Quickfix"
|
||||
keys.mk ["n"] "${k}q" "<cmd>c${cmd}<cr>" "${d} Quickfix"
|
||||
)
|
||||
{
|
||||
"[" = "Previous";
|
||||
|
@ -164,7 +161,7 @@ in {
|
|||
#
|
||||
# Diagnostics - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
++ [
|
||||
(mkKeymap ["n"] "<leader>cd" (
|
||||
(keys.mk ["n"] "<leader>cd" (
|
||||
mkRaw
|
||||
# lua
|
||||
"function() vim.diagnostic.open_float() end"
|
||||
|
@ -200,10 +197,12 @@ in {
|
|||
cmd = toLower dir;
|
||||
sev = sevs."${key}".key;
|
||||
in
|
||||
mkKeymap ["n"] kmap
|
||||
(mkRaw
|
||||
keys.mk ["n"] kmap
|
||||
(
|
||||
mkRaw
|
||||
# lua
|
||||
"function() vim.diagnostic.goto_${cmd}({ severity = ${sev} }) end")
|
||||
"function() vim.diagnostic.goto_${cmd}({ severity = ${sev} }) end"
|
||||
)
|
||||
"${dir} ${sevs."${key}".desc}"
|
||||
)
|
||||
{
|
||||
|
@ -213,17 +212,17 @@ in {
|
|||
)
|
||||
#
|
||||
# Quit - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
++ [(mkKeymap ["n"] "<leader>qq" "<cmd>qa<cr>" "Quit All")]
|
||||
++ [(keys.mk ["n"] "<leader>qq" "<cmd>qa<cr>" "Quit All")]
|
||||
#
|
||||
# Inspect - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
++ [(mkKeymap ["n"] "<leader>ui" (mkRaw "vim.show_pos") "Inspect Position")]
|
||||
++ [(keys.mk ["n"] "<leader>ui" (mkRaw "vim.show_pos") "Inspect Position")]
|
||||
#
|
||||
# Window Management - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
++ [
|
||||
(mkKeymapWithOpts ["n"] "<leader>w" "<C-w>" "Windows" {remap = true;})
|
||||
(mkKeymapWithOpts ["n"] "<leader>-" "<C-w>s" "Split Window Below" {remap = true;})
|
||||
(mkKeymapWithOpts ["n"] "<leader>|" "<C-w>v" "Split Window Right" {remap = true;})
|
||||
(mkKeymapWithOpts ["n"] "<leader>wd" "<C-w>c" "Delete Window" {remap = true;})
|
||||
(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;})
|
||||
]
|
||||
#
|
||||
# Tab Management - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -235,7 +234,7 @@ in {
|
|||
then "Close Other Tabs"
|
||||
else "${a} Tab";
|
||||
in
|
||||
mkKeymap ["n"] "<leader><tab>${k}" "<cmd>tab${toLower a}<cr>" desc
|
||||
keys.mk ["n"] "<leader><tab>${k}" "<cmd>tab${toLower a}<cr>" desc
|
||||
)
|
||||
{
|
||||
l = "Last";
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
...
|
||||
}: let
|
||||
inherit (helpers) mkRaw;
|
||||
inherit (lib.marleyos.keys) mkKeymap;
|
||||
inherit (lib.marleyos) keys;
|
||||
in {
|
||||
extraPackages = [pkgs.lazygit];
|
||||
|
||||
|
@ -22,51 +22,51 @@ in {
|
|||
};
|
||||
|
||||
keymaps = [
|
||||
(mkKeymap ["n"] "<leader>un" (
|
||||
(keys.mk ["n"] "<leader>un" (
|
||||
mkRaw
|
||||
# lua
|
||||
"function() Snacks.notifier.hide() end"
|
||||
) "Dismiss All Notifications")
|
||||
|
||||
(mkKeymap ["n"] "<leader>bd" (
|
||||
(keys.mk ["n"] "<leader>bd" (
|
||||
mkRaw
|
||||
# lua
|
||||
"function() Snacks.bufdelete() end"
|
||||
) "Delete Buffer")
|
||||
|
||||
(mkKeymap ["n"] "<leader>bo" (
|
||||
(keys.mk ["n"] "<leader>bo" (
|
||||
mkRaw
|
||||
# lua
|
||||
"function() Snacks.bufdelete.other() end"
|
||||
) "Delete Other Buffers")
|
||||
|
||||
# LazyGit - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
(mkKeymap ["n"] "<leader>gg" (
|
||||
(keys.mk ["n"] "<leader>gg" (
|
||||
mkRaw
|
||||
# lua
|
||||
"function() Snacks.lazygit() end"
|
||||
) "Lazygit")
|
||||
|
||||
(mkKeymap ["n"] "<leader>gf" (
|
||||
(keys.mk ["n"] "<leader>gf" (
|
||||
mkRaw
|
||||
# lua
|
||||
"function() Snacks.lazygit.log_file() end"
|
||||
) "Lazygit Current File History")
|
||||
|
||||
(mkKeymap ["n"] "<leader>gl" (
|
||||
(keys.mk ["n"] "<leader>gl" (
|
||||
mkRaw
|
||||
# lua
|
||||
"function() Snacks.lazygit.log() end"
|
||||
) "Lazygit Log")
|
||||
|
||||
# Git - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
(mkKeymap ["n"] "<leader>gb" (
|
||||
(keys.mk ["n"] "<leader>gb" (
|
||||
mkRaw
|
||||
# lua
|
||||
"function() Snacks.git.blame_line() end"
|
||||
) "Git Blame Line")
|
||||
|
||||
(mkKeymap ["n" "x"] "<leader>gB" (
|
||||
(keys.mk ["n" "x"] "<leader>gB" (
|
||||
mkRaw
|
||||
# lua
|
||||
"function() Snacks.gitbrowse() end"
|
||||
|
|
Loading…
Reference in a new issue