feat(autopairs): custom setup opts

This commit is contained in:
Ching Pei Yang 2024-02-17 14:13:52 +01:00
commit 3d350bcfe4
2 changed files with 9 additions and 11 deletions

View file

@ -3,25 +3,19 @@
lib,
...
}: let
inherit (lib) nvim;
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.strings) optionalString;
inherit (lib.trivial) boolToString;
cfg = config.vim.autopairs;
in {
config = mkIf cfg.enable {
vim.startPlugins = ["nvim-autopairs"];
vim.luaConfigRC.autopairs = entryAnywhere ''
vim.luaConfigRC.autopairs = nvim.dag.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(${nvim.lua.expToLua cfg.setupOpts})
''}
'';
};

View file

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