From 6fd35972d9bb0e53dadd2d463f8ebe6f4537720f Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 17 Feb 2024 14:13:52 +0100 Subject: [PATCH] feat(autopairs): custom setup opts --- modules/autopairs/nvim-autopairs/config.nix | 11 +++-------- modules/autopairs/nvim-autopairs/nvim-autopairs.nix | 7 ++++++- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/autopairs/nvim-autopairs/config.nix b/modules/autopairs/nvim-autopairs/config.nix index 1502db8..5cd18eb 100644 --- a/modules/autopairs/nvim-autopairs/config.nix +++ b/modules/autopairs/nvim-autopairs/config.nix @@ -4,9 +4,9 @@ ... }: let inherit (lib.modules) mkIf; - inherit (lib.nvim.dag) entryAnywhere; inherit (lib.strings) optionalString; - inherit (lib.trivial) boolToString; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.autopairs; in { @@ -16,12 +16,7 @@ in { vim.luaConfigRC.autopairs = entryAnywhere '' require("nvim-autopairs").setup{} ${optionalString (config.vim.autocomplete.type == "nvim-compe") '' - -- nvim-compe integration - require('nvim-autopairs.completion.compe').setup({ - map_cr = ${boolToString cfg.nvim-compe.map_cr}, - map_complete = ${boolToString cfg.nvim-compe.map_complete}, - auto_select = ${boolToString cfg.nvim-compe.auto_select}, - }) + require('nvim-autopairs.completion.compe').setup(${toLuaObject cfg.setupOpts}) ''} ''; }; diff --git a/modules/autopairs/nvim-autopairs/nvim-autopairs.nix b/modules/autopairs/nvim-autopairs/nvim-autopairs.nix index 940a60c..73b6bed 100644 --- a/modules/autopairs/nvim-autopairs/nvim-autopairs.nix +++ b/modules/autopairs/nvim-autopairs/nvim-autopairs.nix @@ -1,7 +1,12 @@ {lib, ...}: let + inherit (lib) mkRenamedOptionModule; inherit (lib.options) mkEnableOption mkOption; inherit (lib.types) enum bool; in { + imports = [ + # (mkRenamedOptionModule ["vim" "autopairs" "nvim-compe"] ["vim" "autopairs" "nvim-compe" "setupOpts"]) + ]; + options.vim = { autopairs = { enable = mkEnableOption "autopairs" // {default = false;}; @@ -12,7 +17,7 @@ in { description = "Set the autopairs type. Options: nvim-autopairs [nvim-autopairs]"; }; - nvim-compe = { + nvim-compe.setupOpts = lib.nvim.types.mkPluginSetupOption "nvim-compe" { map_cr = mkOption { type = bool; default = true;