plugins: Introduce helpers.defaultNullOpts.mkLuaFn (#855)

This allows to avoid calling `mkRaw` on lua functions, as they will get
applied automatically.

This could also help in the future to refactor the use of Lua code to
make it more user-friendly.
This commit is contained in:
traxys 2023-12-29 15:24:42 +01:00 committed by GitHub
parent b38dbdb0dc
commit 1d8e7906c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 140 additions and 119 deletions

View file

@ -41,7 +41,7 @@ with lib; {
helpers.defaultNullOpts.mkNullable (with types; listOf (enum sessionOpts))
''["buffers" "curdir" "tabpages" "winsize" "skiprtp"]'' "sessionoptions used for saving";
preSave = helpers.mkNullOrOption types.str "a function to call before saving the session";
preSave = helpers.defaultNullOpts.mkLuaFn "nil" "a function to call before saving the session";
saveEmpty = helpers.defaultNullOpts.mkBool false ''
don't save if there are no open file buffers
@ -57,7 +57,7 @@ with lib; {
extraConfigLua = let
opts = {
inherit (cfg) dir options;
pre_save = helpers.mkRaw cfg.preSave;
pre_save = cfg.preSave;
save_empty = cfg.saveEmpty;
};
in ''