From 2cda50d530bdefde477a4eaf65df7f7b3054d52e Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Sun, 29 Sep 2024 15:13:49 +0100 Subject: [PATCH] plugins: remove redundant `mkRaw` `apply` functions `strLua` now does this coercion internally. --- plugins/by-name/conform-nvim/default.nix | 2 -- plugins/by-name/edgy/default.nix | 2 -- plugins/by-name/hydra/settings-options.nix | 1 - plugins/by-name/lint/default.nix | 1 - plugins/by-name/neotest/default.nix | 1 - plugins/by-name/nvim-surround/default.nix | 1 - plugins/by-name/obsidian/options.nix | 1 - plugins/by-name/startify/options.nix | 1 - plugins/by-name/statuscol/default.nix | 1 - plugins/by-name/telescope/extensions/_helpers.nix | 1 - plugins/by-name/trim/default.nix | 1 - plugins/by-name/typescript-tools/default.nix | 1 - plugins/cmp/options/settings-options.nix | 10 ---------- plugins/cmp/sources/cmp-git.nix | 1 - plugins/utils/rest.nix | 1 - 15 files changed, 26 deletions(-) diff --git a/plugins/by-name/conform-nvim/default.nix b/plugins/by-name/conform-nvim/default.nix index 7955a05a..069c5e53 100644 --- a/plugins/by-name/conform-nvim/default.nix +++ b/plugins/by-name/conform-nvim/default.nix @@ -125,7 +125,6 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin { See `:help conform.format` for details. ''; - apply = v: if lib.isString v then mkRaw v else v; }; default_format_opts = defaultNullOpts.mkNullable defaultFormatSubmodule { } '' @@ -143,7 +142,6 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin { See `:help conform.format` for details. ''; - apply = v: if lib.isString v then mkRaw v else v; }; log_level = defaultNullOpts.mkLogLevel "error" '' diff --git a/plugins/by-name/edgy/default.nix b/plugins/by-name/edgy/default.nix index 7cf82b34..9fe910bb 100644 --- a/plugins/by-name/edgy/default.nix +++ b/plugins/by-name/edgy/default.nix @@ -151,7 +151,6 @@ helpers.neovim-plugin.mkNeovimPlugin { }); default = null; example = "require('noice.util.spinners').spinners.circleFull"; - apply = v: if isString v then helpers.mkRaw v else v; description = "Spinner for pinned views that are loading."; pluginDefault = { frames = defaultFrames; @@ -182,7 +181,6 @@ helpers.neovim-plugin.mkNeovimPlugin { # Hence, we convert the string to raw lua in `apply`. keys = helpers.defaultNullOpts.mkAttrsOf' { type = with lib.types; either strLuaFn (enum [ false ]); - apply = x: if x == null then null else mapAttrs (_: v: if isString v then helpers.mkRaw v else v) x; description = '' Buffer-local keymaps to be added to edgebar buffers. Existing buffer-local keymaps will never be overridden. diff --git a/plugins/by-name/hydra/settings-options.nix b/plugins/by-name/hydra/settings-options.nix index 9a8c746e..d4b6a2ea 100644 --- a/plugins/by-name/hydra/settings-options.nix +++ b/plugins/by-name/hydra/settings-options.nix @@ -156,7 +156,6 @@ with lib; end ''; }; - apply = mapAttrs (_: helpers.mkRaw); }; }; }; diff --git a/plugins/by-name/lint/default.nix b/plugins/by-name/lint/default.nix index 498c868d..0da78f1a 100644 --- a/plugins/by-name/lint/default.nix +++ b/plugins/by-name/lint/default.nix @@ -91,7 +91,6 @@ let example = '' require('lint.parser').from_pattern(pattern, groups, severity_map, defaults, opts) ''; - apply = helpers.mkRaw; mandatory = true; }; }; diff --git a/plugins/by-name/neotest/default.nix b/plugins/by-name/neotest/default.nix index 931f4c3b..12fb0a0f 100644 --- a/plugins/by-name/neotest/default.nix +++ b/plugins/by-name/neotest/default.nix @@ -17,7 +17,6 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin { adapters = mkOption { type = with types; listOf strLua; default = [ ]; - apply = map mkRaw; # NOTE: We hide this option from the documentation as users should use the top-level # `adapters` option. # They can still directly append raw lua code to this `settings.adapters` option. diff --git a/plugins/by-name/nvim-surround/default.nix b/plugins/by-name/nvim-surround/default.nix index 6445a481..40bed950 100644 --- a/plugins/by-name/nvim-surround/default.nix +++ b/plugins/by-name/nvim-surround/default.nix @@ -55,7 +55,6 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin { For "static" delimiter pairs it can be a list of strings representing the value of the delimiter pair. ''; - apply = v: if lib.isString v then lib.nixvim.mkRaw v else v; example = [ "( " " )" diff --git a/plugins/by-name/obsidian/options.nix b/plugins/by-name/obsidian/options.nix index 5507baa6..8401f63e 100644 --- a/plugins/by-name/obsidian/options.nix +++ b/plugins/by-name/obsidian/options.nix @@ -226,7 +226,6 @@ with lib; action = mkOption { type = lib.types.strLua; description = "The lua code for this keymap action."; - apply = helpers.mkRaw; }; opts = helpers.keymaps.mapConfigOptions // { buffer = helpers.defaultNullOpts.mkBool false '' diff --git a/plugins/by-name/startify/options.nix b/plugins/by-name/startify/options.nix index d0a75f38..cb83f0f1 100644 --- a/plugins/by-name/startify/options.nix +++ b/plugins/by-name/startify/options.nix @@ -30,7 +30,6 @@ with lib; }; }) ); - apply = v: map (listElem: if isString listElem then helpers.mkRaw listElem else listElem) v; default = [ ]; description = '' Startify displays lists. Each list consists of a `type` and optionally a `header` and diff --git a/plugins/by-name/statuscol/default.nix b/plugins/by-name/statuscol/default.nix index 3f53410c..7d407562 100644 --- a/plugins/by-name/statuscol/default.nix +++ b/plugins/by-name/statuscol/default.nix @@ -129,7 +129,6 @@ helpers.neovim-plugin.mkNeovimPlugin { description = '' Builtin click handlers. ''; - apply = mapAttrs (_: helpers.mkRaw); example = { Lnum = "require('statuscol.builtin').lnum_click"; FoldClose = "require('statuscol.builtin').foldclose_click"; diff --git a/plugins/by-name/telescope/extensions/_helpers.nix b/plugins/by-name/telescope/extensions/_helpers.nix index cb6a077b..75f66dc9 100644 --- a/plugins/by-name/telescope/extensions/_helpers.nix +++ b/plugins/by-name/telescope/extensions/_helpers.nix @@ -95,7 +95,6 @@ rec { ${defaults} ``` ''; - apply = lib.mapAttrs (_: lib.nixvim.mkRaw); }; mkMappingsOption = diff --git a/plugins/by-name/trim/default.nix b/plugins/by-name/trim/default.nix index d050b653..fb560540 100644 --- a/plugins/by-name/trim/default.nix +++ b/plugins/by-name/trim/default.nix @@ -18,7 +18,6 @@ helpers.neovim-plugin.mkNeovimPlugin { patterns = mkOption { type = with lib.types; listOf strLua; - apply = map helpers.mkRaw; default = [ ]; example = [ "[[%s/\(\n\n\)\n\+/\1/]]" ]; description = '' diff --git a/plugins/by-name/typescript-tools/default.nix b/plugins/by-name/typescript-tools/default.nix index 64974e97..eddc3d5a 100644 --- a/plugins/by-name/typescript-tools/default.nix +++ b/plugins/by-name/typescript-tools/default.nix @@ -22,7 +22,6 @@ in onAttach = helpers.defaultNullOpts.mkLuaFn "__lspOnAttach" "Lua code to run when tsserver attaches to a buffer."; handlers = mkOption { type = with lib.types; nullOr (attrsOf strLuaFn); - apply = v: helpers.ifNonNull' v (mapAttrs (_: helpers.mkRaw) v); default = null; description = "How tsserver should respond to LSP requests"; example = { diff --git a/plugins/cmp/options/settings-options.nix b/plugins/cmp/options/settings-options.nix index 5dd950f5..e4c8cd26 100644 --- a/plugins/cmp/options/settings-options.nix +++ b/plugins/cmp/options/settings-options.nix @@ -43,14 +43,6 @@ with lib; cmp mappings declaration. See `:h cmp-mapping` for more information. ''; - apply = - v: - # Handle the raw case first - if lib.types.isRawType v then - v - # When v is an attrs **but not {__raw = ...}** - else - mapAttrs (_: helpers.mkRaw) v; example = { "" = "cmp.mapping.scroll_docs(-4)"; "" = "cmp.mapping.scroll_docs(4)"; @@ -98,7 +90,6 @@ with lib; end ``` ''; - apply = helpers.mkRaw; example = '' function(args) require('luasnip').lsp_expand(args.body) @@ -210,7 +201,6 @@ with lib; comparators = mkOption { type = with lib.types; nullOr (listOf strLuaFn); - apply = v: helpers.ifNonNull' v (map helpers.mkRaw v); default = null; description = '' The function to customize the sorting behavior. diff --git a/plugins/cmp/sources/cmp-git.nix b/plugins/cmp/sources/cmp-git.nix index 36d738ba..9863835a 100644 --- a/plugins/cmp/sources/cmp-git.nix +++ b/plugins/cmp/sources/cmp-git.nix @@ -162,7 +162,6 @@ in action = mkOption { type = lib.types.strLuaFn; - apply = helpers.mkRaw; description = '' The parameters to the action function are the different sources (currently `git`, `gitlab` and `github`), the completion callback, the trigger character, the diff --git a/plugins/utils/rest.nix b/plugins/utils/rest.nix index 4a7ccadc..960d5913 100644 --- a/plugins/utils/rest.nix +++ b/plugins/utils/rest.nix @@ -207,7 +207,6 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin { default: `{}` ''; - apply = v: if lib.isAttrs v then lib.mapAttrs (_: lib.nixvim.mkRaw) v else v; }; request = {