From 517a6aa06e40a9e66755f348ff15aa9dede822a3 Mon Sep 17 00:00:00 2001 From: Nowaaru Date: Mon, 4 Nov 2024 23:40:44 -0700 Subject: [PATCH 1/3] utility/precognition: convert to setupOpts honestly raf was cooking with this one. it's much nicer to use compared to interpolation lol --- configuration.nix | 28 ++++---- .../utility/motion/precognition/config.nix | 14 +--- .../motion/precognition/precognition.nix | 64 ++++++++++--------- 3 files changed, 51 insertions(+), 55 deletions(-) diff --git a/configuration.nix b/configuration.nix index af5efecb..29179ee9 100644 --- a/configuration.nix +++ b/configuration.nix @@ -168,21 +168,23 @@ isMaximal: { precognition = { enable = true; - startVisible = true; - showBlankVirtLine = true; + setupOpts = { + startVisible = true; + showBlankVirtLine = true; - # highlightColor - automatically set by theme - disabled_fts = ["startify" "alpha" "dashboard"]; - gutterHints = { - gg = { - text = "gg"; - prio = 2; + # highlightColor - automatically set by theme + disabled_fts = ["startify" "alpha" "dashboard"]; + gutterHints = { + gg = { + text = "gg"; + prio = 2; + }; }; - }; - hints = { - Caret = { - text = "^"; - prio = 10; + hints = { + Caret = { + text = "^"; + prio = 10; + }; }; }; }; diff --git a/modules/plugins/utility/motion/precognition/config.nix b/modules/plugins/utility/motion/precognition/config.nix index 25fceda4..6535e33e 100644 --- a/modules/plugins/utility/motion/precognition/config.nix +++ b/modules/plugins/utility/motion/precognition/config.nix @@ -4,9 +4,6 @@ ... }: let inherit (lib.modules) mkIf; - inherit (lib.nvim.dag) entryAnywhere; - inherit (lib.nvim.lua) toLuaObject; - inherit (builtins) toString; cfg = config.vim.utility.motion.precognition; in { @@ -17,15 +14,8 @@ in { "precognition-nvim" ]; - vim.pluginRC.precognition-nvim = entryAnywhere '' - require("precognition").setup({ - startVisible = ${toString cfg.startVisible}, - showBlankVirtLine = ${toString cfg.showBlankVirtLine}, - highlightColor = (${toLuaObject cfg.highlightColor}), --{ link = "Comment" }, - hints = (${toLuaObject cfg.hints}), - gutterHints = (${toLuaObject cfg.gutterHints}), - disabled_fts = (${toLuaObject cfg.disabled_fts}), - }); + vim.luaConfigRC.precognition = lib.nvim.dag.entryAnywhere '' + require('precognition').setup(${lib.nvim.lua.toLuaObject cfg.setupOpts}) ''; }; } diff --git a/modules/plugins/utility/motion/precognition/precognition.nix b/modules/plugins/utility/motion/precognition/precognition.nix index 9c42e0f9..8e60184b 100644 --- a/modules/plugins/utility/motion/precognition/precognition.nix +++ b/modules/plugins/utility/motion/precognition/precognition.nix @@ -1,6 +1,8 @@ -{lib, ...}: let +{lib, ...}: +let inherit (lib.options) mkEnableOption mkOption literalExpression; inherit (lib.types) attrsOf listOf str bool int submodule; + inherit (lib.nvim.types) mkPluginSetupOption; mkHintType = description: mkOption { @@ -25,41 +27,43 @@ in { options.vim.utility.motion.precognition = { enable = mkEnableOption "precognition.nvim plugin"; - startVisible = mkOption { - type = bool; - description = "Whether to start 'precognition' automatically."; - default = true; - }; + setupOpts = mkPluginSetupOption "precognition.nvim" { + startVisible = mkOption { + type = bool; + description = "Whether to start 'precognition' automatically."; + default = true; + }; - showBlankVirtLine = mkOption { - type = bool; - description = "Whether to show a blank virtual line when no movements are shown."; - default = true; - }; + showBlankVirtLine = mkOption { + type = bool; + description = "Whether to show a blank virtual line when no movements are shown."; + default = true; + }; - highlightColor = mkOption { - type = attrsOf str; + highlightColor = mkOption { + type = attrsOf str; - example = literalExpression '' - { link = "Comment"; } - # or - { foreground = "#0000FF"; background = "#000000"; }; - ''; - default = {link = "Comment";}; - description = '' - The highlight for the virtual text. - ''; - }; + example = literalExpression '' + { link = "Comment"; } + # or + { foreground = "#0000FF"; background = "#000000"; }; + ''; + default = {link = "Comment";}; + description = '' + The highlight for the virtual text. + ''; + }; - hints = mkHintType "What motions display and at what priority."; + hints = mkHintType "What motions display and at what priority."; - gutterHints = - mkHintType "What motions display and at what priority. Only appears in gutters."; + gutterHints = + mkHintType "What motions display and at what priority. Only appears in gutters."; - disabled_fts = mkOption { - type = listOf str; - default = ["startify"]; - example = literalExpression ''["startify"]''; + disabled_fts = mkOption { + type = listOf str; + default = ["startify"]; + example = literalExpression ''["startify"]''; + }; }; }; } From b0641a8c0b4e1384af0c2017ca659883befa93d2 Mon Sep 17 00:00:00 2001 From: Nowaaru Date: Tue, 5 Nov 2024 04:13:22 -0700 Subject: [PATCH 2/3] utility/precognition: remove unnecessary function parameter --- modules/plugins/utility/motion/precognition/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/plugins/utility/motion/precognition/default.nix b/modules/plugins/utility/motion/precognition/default.nix index d1327103..85d223cc 100644 --- a/modules/plugins/utility/motion/precognition/default.nix +++ b/modules/plugins/utility/motion/precognition/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./precognition.nix ./config.nix From e43b18cb9f3bd41fa1edf9823493073ddc859d7b Mon Sep 17 00:00:00 2001 From: Nowaaru Date: Tue, 5 Nov 2024 04:15:03 -0700 Subject: [PATCH 3/3] utility/precognition: format --- .../plugins/utility/motion/precognition/precognition.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/plugins/utility/motion/precognition/precognition.nix b/modules/plugins/utility/motion/precognition/precognition.nix index 8e60184b..b387d7f9 100644 --- a/modules/plugins/utility/motion/precognition/precognition.nix +++ b/modules/plugins/utility/motion/precognition/precognition.nix @@ -1,5 +1,4 @@ -{lib, ...}: -let +{lib, ...}: let inherit (lib.options) mkEnableOption mkOption literalExpression; inherit (lib.types) attrsOf listOf str bool int submodule; inherit (lib.nvim.types) mkPluginSetupOption; @@ -42,13 +41,12 @@ in { highlightColor = mkOption { type = attrsOf str; - + default = {link = "Comment";}; example = literalExpression '' { link = "Comment"; } # or { foreground = "#0000FF"; background = "#000000"; }; ''; - default = {link = "Comment";}; description = '' The highlight for the virtual text. '';