plugins/edgy: switch from mkDesc to pluginDefault

This commit is contained in:
Matt Sturgeon 2024-06-11 02:30:37 +01:00
parent a8943f2502
commit 44cd01b253
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299

View file

@ -120,7 +120,7 @@ helpers.neovim-plugin.mkNeovimPlugin config {
'' "Callback for the ending of animations."; '' "Callback for the ending of animations.";
# This option accepts an attrs or a lua string. # This option accepts an attrs or a lua string.
# Hence, we use `mkOption` to convert the string to raw lua in `apply`. # Hence, we convert the string to raw lua in `apply`.
spinner = spinner =
let let
defaultFrames = [ defaultFrames = [
@ -136,30 +136,29 @@ helpers.neovim-plugin.mkNeovimPlugin config {
"" ""
]; ];
in in
mkOption { helpers.mkNullOrOption' {
type = type =
with helpers.nixvimTypes; with helpers.nixvimTypes;
nullOr ( either strLua (submodule {
either strLua (submodule { freeformType = attrsOf anything;
freeformType = attrsOf anything; options = {
options = { frames = helpers.defaultNullOpts.mkListOf types.str defaultFrames ''
frames = helpers.defaultNullOpts.mkListOf types.str defaultFrames '' Frame characters.
Frame characters. '';
'';
interval = helpers.defaultNullOpts.mkUnsignedInt 80 '' interval = helpers.defaultNullOpts.mkUnsignedInt 80 ''
Interval time between two consecutive frames. Interval time between two consecutive frames.
''; '';
}; };
}) });
);
default = null; default = null;
example = "require('noice.util.spinners').spinners.circleFull"; example = "require('noice.util.spinners').spinners.circleFull";
apply = v: if isString v then helpers.mkRaw v else v; apply = v: if isString v then helpers.mkRaw v else v;
description = helpers.defaultNullOpts.mkDesc { description = "Spinner for pinned views that are loading.";
pluginDefault = {
frames = defaultFrames; frames = defaultFrames;
interval = 80; interval = 80;
} "Spinner for pinned views that are loading."; };
}; };
}; };
@ -182,84 +181,81 @@ helpers.neovim-plugin.mkNeovimPlugin config {
} "Global window options for edgebar windows."; } "Global window options for edgebar windows.";
# This option accepts an attrs or a lua string. # This option accepts an attrs or a lua string.
# Hence, we use `mkOption` to convert the string to raw lua in `apply`. # Hence, we convert the string to raw lua in `apply`.
keys = mkOption { keys = helpers.defaultNullOpts.mkAttrsOf' {
type = with helpers.nixvimTypes; attrsOf (either strLuaFn (enum [ false ])); type = with helpers.nixvimTypes; either strLuaFn (enum [ false ]);
default = { }; apply = x: if x == null then null else mapAttrs (_: v: if isString v then helpers.mkRaw v else v) x;
apply = mapAttrs (_: v: if isString v then helpers.mkRaw v else v); description = ''
description = Buffer-local keymaps to be added to edgebar buffers.
helpers.defaultNullOpts.mkDesc Existing buffer-local keymaps will never be overridden.
{
q = ''
function(win)
win:close()
end
'';
"<c-q>" = ''
function(win)
win:hide()
end
'';
Q = ''
function(win)
win.view.edgebar:close()
end
'';
"]w" = ''
function(win)
win:next({ visible = true, focus = true })
end
'';
"[w" = ''
function(win)
win:prev({ visible = true, focus = true })
end
'';
"]W" = ''
function(win)
win:next({ pinned = false, focus = true })
end
'';
"[W" = ''
function(win)
win:prev({ pinned = false, focus = true })
end
'';
"<c-w>>" = ''
function(win)
win:resize("width", 2)
end
'';
"<c-w><lt>" = ''
function(win)
win:resize("width", -2)
end
'';
"<c-w>+" = ''
function(win)
win:resize("height", 2)
end
'';
"<c-w>-" = ''
function(win)
win:resize("height", -2)
end
'';
"<c-w>=" = ''
function(win)
win.view.edgebar:equalize()
end
'';
}
''
Buffer-local keymaps to be added to edgebar buffers.
Existing buffer-local keymaps will never be overridden.
Each value is either: Each value is either:
- A function declaration (as a raw lua string) - A function declaration (as a raw lua string)
-> `fun(win:Edgy.Window)` -> `fun(win:Edgy.Window)`
- `false` to disable this mapping. - `false` to disable this mapping.
''; '';
pluginDefault = {
q = ''
function(win)
win:close()
end
'';
"<c-q>" = ''
function(win)
win:hide()
end
'';
Q = ''
function(win)
win.view.edgebar:close()
end
'';
"]w" = ''
function(win)
win:next({ visible = true, focus = true })
end
'';
"[w" = ''
function(win)
win:prev({ visible = true, focus = true })
end
'';
"]W" = ''
function(win)
win:next({ pinned = false, focus = true })
end
'';
"[W" = ''
function(win)
win:prev({ pinned = false, focus = true })
end
'';
"<c-w>>" = ''
function(win)
win:resize("width", 2)
end
'';
"<c-w><lt>" = ''
function(win)
win:resize("width", -2)
end
'';
"<c-w>+" = ''
function(win)
win:resize("height", 2)
end
'';
"<c-w>-" = ''
function(win)
win:resize("height", -2)
end
'';
"<c-w>=" = ''
function(win)
win.view.edgebar:equalize()
end
'';
};
}; };
icons = { icons = {