feat(autopairs): custom setup opts

This commit is contained in:
Ching Pei Yang 2024-02-17 14:13:52 +01:00
parent 4db6950558
commit 6fd35972d9
2 changed files with 9 additions and 9 deletions

View file

@ -4,9 +4,9 @@
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.trivial) boolToString; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.autopairs; cfg = config.vim.autopairs;
in { in {
@ -16,12 +16,7 @@ in {
vim.luaConfigRC.autopairs = entryAnywhere '' vim.luaConfigRC.autopairs = entryAnywhere ''
require("nvim-autopairs").setup{} require("nvim-autopairs").setup{}
${optionalString (config.vim.autocomplete.type == "nvim-compe") '' ${optionalString (config.vim.autocomplete.type == "nvim-compe") ''
-- nvim-compe integration require('nvim-autopairs.completion.compe').setup(${toLuaObject cfg.setupOpts})
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},
})
''} ''}
''; '';
}; };

View file

@ -1,7 +1,12 @@
{lib, ...}: let {lib, ...}: let
inherit (lib) mkRenamedOptionModule;
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) enum bool; inherit (lib.types) enum bool;
in { in {
imports = [
# (mkRenamedOptionModule ["vim" "autopairs" "nvim-compe"] ["vim" "autopairs" "nvim-compe" "setupOpts"])
];
options.vim = { options.vim = {
autopairs = { autopairs = {
enable = mkEnableOption "autopairs" // {default = false;}; enable = mkEnableOption "autopairs" // {default = false;};
@ -12,7 +17,7 @@ in {
description = "Set the autopairs type. Options: nvim-autopairs [nvim-autopairs]"; description = "Set the autopairs type. Options: nvim-autopairs [nvim-autopairs]";
}; };
nvim-compe = { nvim-compe.setupOpts = lib.nvim.types.mkPluginSetupOption "nvim-compe" {
map_cr = mkOption { map_cr = mkOption {
type = bool; type = bool;
default = true; default = true;