refactor: extracted alpha shortcut creation into its own function

This commit is contained in:
Ceferino Patino 2025-07-04 08:34:35 -05:00
commit 495bb98edb
Signed by: c4patino
SSH key fingerprint: SHA256:9fQ9TsujGrdNNi76mnsu63v7dS5JOmHRZEqBOl49OR8

View file

@ -3,12 +3,40 @@
enable = true;
theme = null;
layout = let
padding = val: {
mkPadding = val: {
type = "padding";
inherit val;
};
mkButton = label: shortcut: command: {
type = "button";
val = label;
on_press.__raw = ''
function()
local key = vim.api.nvim_replace_termcodes("${shortcut}", true, false, true)
vim.api.nvim_feedkeys(key, "n", false)
end
'';
opts = {
keymap = [
"n"
shortcut
command
{
noremap = true;
silent = true;
nowait = true;
}
];
shortcut = shortcut;
position = "center";
cursor = 3;
width = 38;
align_shortcut = "right";
hl_shortcut = "Keyword";
};
};
in [
(padding 4)
(mkPadding 4)
{
opts = {
hl = "AlphaHeader";
@ -29,160 +57,18 @@
" git@github.com:c4patino "
];
}
(padding 2)
{
type = "button";
val = " Find File";
on_press = {
__raw = "function() require('telescope.builtin').find_files() end";
};
opts = {
keymap = [
"n"
"f"
":Telescope find_files <CR>"
{
noremap = true;
silent = true;
nowait = true;
}
];
shortcut = "f";
position = "center";
cursor = 3;
width = 38;
align_shortcut = "right";
hl_shortcut = "Keyword";
};
}
(padding 1)
{
type = "button";
val = " New File";
on_press = {
__raw = "function() vim.cmd[[ene]] end";
};
opts = {
keymap = [
"n"
"n"
":ene <BAR> startinsert <CR>"
{
noremap = true;
silent = true;
nowait = true;
}
];
shortcut = "n";
position = "center";
cursor = 3;
width = 38;
align_shortcut = "right";
hl_shortcut = "Keyword";
};
}
(padding 1)
{
type = "button";
val = "󰈚 Recent Files";
on_press.__raw = "function() require('telescope.builtin').oldfiles() end";
opts = {
keymap = [
"n"
"r"
":Telescope oldfiles <CR>"
{
noremap = true;
silent = true;
nowait = true;
}
];
shortcut = "r";
position = "center";
cursor = 3;
width = 38;
align_shortcut = "right";
hl_shortcut = "Keyword";
};
}
(padding 1)
{
type = "button";
val = "󰈭 Find Word";
on_press.__raw = "function() require('telescope.builtin').live_grep() end";
opts = {
keymap = [
"n"
"g"
":Telescope live_grep <CR>"
{
noremap = true;
silent = true;
nowait = true;
}
];
shortcut = "g";
position = "center";
cursor = 3;
width = 38;
align_shortcut = "right";
hl_shortcut = "Keyword";
};
}
(padding 1)
{
type = "button";
val = " Restore Session";
on_press.__raw = "function() require('persistence').load() end";
opts = {
keymap = [
"n"
"s"
":lua require('persistence').load()<cr>"
{
noremap = true;
silent = true;
nowait = true;
}
];
shortcut = "s";
position = "center";
cursor = 3;
width = 38;
align_shortcut = "right";
hl_shortcut = "Keyword";
};
}
(padding 1)
{
type = "button";
val = " Quit Neovim";
on_press.__raw = "function() vim.cmd[[qa]] end";
opts = {
keymap = [
"n"
"q"
":qa<CR>"
{
noremap = true;
silent = true;
nowait = true;
}
];
shortcut = "q";
position = "center";
cursor = 3;
width = 38;
align_shortcut = "right";
hl_shortcut = "Keyword";
};
}
(mkPadding 2)
(mkButton " Find File" "f" "<CMD>Telescope find_files<CR>")
(mkPadding 1)
(mkButton " New File" "n" "<CMD>ene <BAR> startinsert<CR>")
(mkPadding 1)
(mkButton "󰈚 Recent Files" "r" "<CMD>Telescope oldfiles<CR>")
(mkPadding 1)
(mkButton "󰈭 Find Word" "g" "<CMD>Telescope live_grep<CR>")
(mkPadding 1)
(mkButton " Restore Session" "s" "<CMD>lua require('persistence').load()<CR>")
(mkPadding 1)
(mkButton " Quit Neovim" "q" "<CMD>qa<CR>")
];
};
}