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

@ -137,17 +137,17 @@ in {
custom callback for null-ls, or leave this undefined.
'';
onInit = helpers.defaultNullOpts.mkStr "null" ''
onInit = helpers.defaultNullOpts.mkLuaFn "null" ''
Defines an `on_init` callback to run when null-ls initializes. From here, you
can make changes to the client (the first argument) or `initialize_result` (the
second argument, which as of now is not used).
'';
onExit = helpers.defaultNullOpts.mkStr "null" ''
onExit = helpers.defaultNullOpts.mkLuaFn "null" ''
Defines an `on_exit` callback to run when the null-ls client exits.
'';
rootDir = helpers.defaultNullOpts.mkStr "null" ''
rootDir = helpers.defaultNullOpts.mkLuaFn "null" ''
Determines the root of the null-ls server. On startup, null-ls will call
`root_dir` with the full path to the first file that null-ls attaches to.
@ -161,7 +161,7 @@ in {
directory.
'';
shouldAttach = helpers.defaultNullOpts.mkStr "null" ''
shouldAttach = helpers.defaultNullOpts.mkLuaFn "null" ''
A user-defined function that controls whether to enable null-ls for a given
buffer. Receives `bufnr` as its first argument.
@ -257,10 +257,10 @@ in {
log_level = logLevel;
notify_format = notifyFormat;
on_attach = helpers.mkRaw onAttach';
on_init = helpers.mkRaw onInit;
on_exit = helpers.mkRaw onExit;
root_dir = helpers.mkRaw rootDir;
should_attach = helpers.mkRaw shouldAttach;
on_init = onInit;
on_exit = onExit;
root_dir = rootDir;
should_attach = shouldAttach;
temp_dir = tempDir;
update_in_insert = updateInInsert;