From 77436fd51c50b58b05893577cbd0cab3778d2e3c Mon Sep 17 00:00:00 2001 From: Kalle Jepsen Date: Sun, 24 Mar 2024 14:22:03 +0100 Subject: [PATCH] Use mkPluginSetupOption for plugin config --- modules/assistant/chatgpt/chatgpt.nix | 11 ++++++++--- modules/assistant/chatgpt/config.nix | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/assistant/chatgpt/chatgpt.nix b/modules/assistant/chatgpt/chatgpt.nix index b7491495..69211d5b 100644 --- a/modules/assistant/chatgpt/chatgpt.nix +++ b/modules/assistant/chatgpt/chatgpt.nix @@ -1,9 +1,14 @@ -{lib, ...}: let - inherit (lib.options) mkEnableOption; - inherit (lib) mkMappingOption; +{ + lib, + ... +}: let + inherit (lib.options) mkEnableOption mkOption; + inherit (lib) mkMappingOption types; + inherit (lib.nvim.types) mkPluginSetupOption; in { options.vim.assistant.chatgpt = { enable = mkEnableOption "ChatGPT AI assistant. Requires the environment variable OPENAI_API_KEY to be set"; + setupOpts = mkPluginSetupOption "chatgpt" {}; mappings = { chatGpt = mkMappingOption "ChatGPT" "ac"; editWithInstructions = mkMappingOption "[ChatGPT] Edit with instructions" "ae"; diff --git a/modules/assistant/chatgpt/config.nix b/modules/assistant/chatgpt/config.nix index 49c5b08c..afb96183 100644 --- a/modules/assistant/chatgpt/config.nix +++ b/modules/assistant/chatgpt/config.nix @@ -6,6 +6,7 @@ inherit (lib.modules) mkIf mkMerge; inherit (lib.nvim.dag) entryAnywhere; inherit (lib) addDescriptionsToMappings mkSetBinding; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.assistant.chatgpt; @@ -33,8 +34,7 @@ in { "chatgpt" ]; luaConfigRC.chagpt = entryAnywhere '' - require("chatgpt").setup({ - }) + require("chatgpt").setup(${toLuaObject cfg.setupOpts}) ''; maps.normal = mkMerge [ (mkSetBinding mappings.chatGpt "ChatGPT")