mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-24 12:45:24 +02:00
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:
parent
b38dbdb0dc
commit
1d8e7906c9
30 changed files with 140 additions and 119 deletions
|
@ -61,7 +61,7 @@
|
|||
`:LspStart` (|lspconfig-commands|).
|
||||
'';
|
||||
|
||||
rootDir = helpers.mkNullOrOption types.str ''
|
||||
rootDir = helpers.defaultNullOpts.mkLuaFn "nil" ''
|
||||
A function (or function handle) which returns the root of the project used to
|
||||
determine if lspconfig should launch a new language server, or attach a previously
|
||||
launched server when you open a new buffer matching the filetype of the server.
|
||||
|
@ -110,7 +110,7 @@
|
|||
extraOptions =
|
||||
{
|
||||
inherit (cfg) cmd filetypes autostart;
|
||||
root_dir = helpers.mkRaw cfg.rootDir;
|
||||
root_dir = cfg.rootDir;
|
||||
on_attach =
|
||||
helpers.ifNonNull' cfg.onAttach
|
||||
(
|
||||
|
|
|
@ -30,7 +30,7 @@ with lib; {
|
|||
the type of the external input buffer to use
|
||||
'';
|
||||
|
||||
postHook = helpers.defaultNullOpts.mkNullable types.str "null" ''
|
||||
postHook = helpers.defaultNullOpts.mkLuaFn "null" ''
|
||||
callback to run after renaming, receives the result table (from LSP handler) as an argument
|
||||
'';
|
||||
};
|
||||
|
@ -43,7 +43,7 @@ with lib; {
|
|||
preview_empty_name = cfg.previewEmptyName;
|
||||
show_message = cfg.showMessage;
|
||||
input_buffer_type = cfg.inputBufferType;
|
||||
post_hook = helpers.mkRaw cfg.postHook;
|
||||
post_hook = cfg.postHook;
|
||||
};
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
|
|
|
@ -72,9 +72,9 @@ in {
|
|||
"Default search engine.";
|
||||
|
||||
hooks = {
|
||||
requestStarted = helpers.mkNullOrOption types.str "Callback for request start.";
|
||||
requestStarted = helpers.defaultNullOpts.mkLuaFn "nil" "Callback for request start.";
|
||||
|
||||
requestFinished = helpers.mkNullOrOption types.str "Callback for request finished.";
|
||||
requestFinished = helpers.defaultNullOpts.mkLuaFn "nil" "Callback for request finished.";
|
||||
};
|
||||
|
||||
winhighlight = helpers.defaultNullOpts.mkStr "Normal:Normal,FloatBorder:FloatBorder" ''
|
||||
|
@ -96,8 +96,8 @@ in {
|
|||
additional_instructions = additionalInstructions;
|
||||
search_engine = searchEngine;
|
||||
hooks = {
|
||||
request_started = helpers.mkRaw hooks.requestStarted;
|
||||
request_finished = helpers.mkRaw hooks.requestFinished;
|
||||
request_started = hooks.requestStarted;
|
||||
request_finished = hooks.requestFinished;
|
||||
};
|
||||
inherit winhighlight;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue