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

@ -187,7 +187,7 @@ in {
height = helpers.defaultNullOpts.mkPositiveInt 5 "Height of the window.";
onLines = helpers.mkNullOrOption types.str ''
onLines = helpers.defaultNullOpts.mkLuaFn "nil" ''
A callback which will be called with (multi-line) stderr output.
e.g., use:
@ -302,7 +302,7 @@ in {
enable
height
;
on_lines = helpers.mkRaw onLines;
on_lines = onLines;
};
inherit lsp3;
}

View file

@ -24,7 +24,7 @@ in {
"how to execute terminal commands";
onInitialized =
helpers.defaultNullOpts.mkStr "null"
helpers.defaultNullOpts.mkLuaFn "null"
''
Callback to execute once rust-analyzer is done initializing the workspace
The callback receives one parameter indicating the `health` of the server:
@ -143,7 +143,7 @@ in {
helpers.ifNonNull' cfg.executor
(helpers.mkRaw "require(${rust-tools.executors}).${cfg.executor}");
on_initialized = helpers.mkRaw cfg.onInitialized;
on_initialized = cfg.onInitialized;
reload_workspace_from_cargo_toml = cfg.reloadWorkspaceFromCargoToml;
inlay_hints = with cfg.inlayHints; {

View file

@ -50,7 +50,7 @@ in {
The Z-index of the context window.
'';
onAttach = helpers.mkNullOrOption types.str ''
onAttach = helpers.defaultNullOpts.mkLuaFn "nil" ''
The implementation of a lua function which takes an integer `buf` as parameter and returns a
boolean.
Return `false` to disable attaching.
@ -70,7 +70,7 @@ in {
separator
zindex
;
on_attach = helpers.mkRaw onAttach;
on_attach = onAttach;
}
// cfg.extraOptions;
in