mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-01-03 09:27:16 +00:00
Use mkPluginSetupOption for plugin config
This commit is contained in:
parent
a6dc729e90
commit
77436fd51c
2 changed files with 10 additions and 5 deletions
|
|
@ -1,9 +1,14 @@
|
||||||
{lib, ...}: let
|
{
|
||||||
inherit (lib.options) mkEnableOption;
|
lib,
|
||||||
inherit (lib) mkMappingOption;
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
|
inherit (lib) mkMappingOption types;
|
||||||
|
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||||
in {
|
in {
|
||||||
options.vim.assistant.chatgpt = {
|
options.vim.assistant.chatgpt = {
|
||||||
enable = mkEnableOption "ChatGPT AI assistant. Requires the environment variable OPENAI_API_KEY to be set";
|
enable = mkEnableOption "ChatGPT AI assistant. Requires the environment variable OPENAI_API_KEY to be set";
|
||||||
|
setupOpts = mkPluginSetupOption "chatgpt" {};
|
||||||
mappings = {
|
mappings = {
|
||||||
chatGpt = mkMappingOption "ChatGPT" "<leader>ac";
|
chatGpt = mkMappingOption "ChatGPT" "<leader>ac";
|
||||||
editWithInstructions = mkMappingOption "[ChatGPT] Edit with instructions" "<leader>ae";
|
editWithInstructions = mkMappingOption "[ChatGPT] Edit with instructions" "<leader>ae";
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.nvim.dag) entryAnywhere;
|
inherit (lib.nvim.dag) entryAnywhere;
|
||||||
inherit (lib) addDescriptionsToMappings mkSetBinding;
|
inherit (lib) addDescriptionsToMappings mkSetBinding;
|
||||||
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
|
|
||||||
cfg = config.vim.assistant.chatgpt;
|
cfg = config.vim.assistant.chatgpt;
|
||||||
|
|
||||||
|
|
@ -33,8 +34,7 @@ in {
|
||||||
"chatgpt"
|
"chatgpt"
|
||||||
];
|
];
|
||||||
luaConfigRC.chagpt = entryAnywhere ''
|
luaConfigRC.chagpt = entryAnywhere ''
|
||||||
require("chatgpt").setup({
|
require("chatgpt").setup(${toLuaObject cfg.setupOpts})
|
||||||
})
|
|
||||||
'';
|
'';
|
||||||
maps.normal = mkMerge [
|
maps.normal = mkMerge [
|
||||||
(mkSetBinding mappings.chatGpt "<cmd>ChatGPT<CR>")
|
(mkSetBinding mappings.chatGpt "<cmd>ChatGPT<CR>")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue