From 895998b5a74c6123c26ea6e2c6af766057428551 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sun, 11 Jun 2023 12:25:42 +0200 Subject: [PATCH] plugins/mini: init + test --- plugins/default.nix | 1 + plugins/utils/mini.nix | 48 ++++++++++++++ tests/test-sources/plugins/utils/mini.nix | 80 +++++++++++++++++++++++ 3 files changed, 129 insertions(+) create mode 100644 plugins/utils/mini.nix create mode 100644 tests/test-sources/plugins/utils/mini.nix diff --git a/plugins/default.nix b/plugins/default.nix index 899e8ff3..b4be2a5a 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -87,6 +87,7 @@ ./utils/intellitab.nix ./utils/lastplace.nix ./utils/mark-radar.nix + ./utils/mini.nix ./utils/neorg.nix ./utils/notify.nix ./utils/netman.nix diff --git a/plugins/utils/mini.nix b/plugins/utils/mini.nix new file mode 100644 index 00000000..1e0dabe1 --- /dev/null +++ b/plugins/utils/mini.nix @@ -0,0 +1,48 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; let + cfg = config.plugins.mini; + helpers = import ../helpers.nix {inherit lib;}; +in { + options.plugins.mini = { + enable = mkEnableOption "mini.nvim"; + + package = helpers.mkPackageOption "mini.nvim" pkgs.vimPlugins.mini-nvim; + + modules = mkOption { + type = with types; attrsOf attrs; + default = {}; + description = '' + Enable and configure the mini modules. + The keys are the names of the modules (without the `mini.` prefix). + The value is an attrs of configuration options for the module. + Leave the attrs empty to use the module's default configuration. + ''; + example = { + ai = { + n_lines = 50; + search_method = "cover_or_next"; + }; + surrounds = {}; + }; + }; + }; + + config = mkIf cfg.enable { + extraPlugins = [cfg.package]; + + extraConfigLua = + concatLines + ( + mapAttrsToList + ( + name: config: "require('mini.${name}').setup(${helpers.toLuaObject config})" + ) + cfg.modules + ); + }; +} diff --git a/tests/test-sources/plugins/utils/mini.nix b/tests/test-sources/plugins/utils/mini.nix new file mode 100644 index 00000000..3dbafd35 --- /dev/null +++ b/tests/test-sources/plugins/utils/mini.nix @@ -0,0 +1,80 @@ +{ + empty = { + plugins.mini.enable = true; + }; + + allOfficialModules = { + plugins.mini = { + enable = true; + + modules = { + ai = { + custom_textobjects = null; + mappings = { + around = "a"; + inside = "i"; + around_next = "an"; + inside_next = "in"; + around_last = "al"; + inside_last = "il"; + goto_left = "g["; + goto_right = "g]"; + }; + n_lines = 50; + search_method = "cover_or_next"; + silent = false; + }; + animate = {}; + base16 = { + palette = { + base00 = "#123456"; + base01 = "#123456"; + base02 = "#123456"; + base03 = "#123456"; + base04 = "#123456"; + base05 = "#123456"; + base06 = "#123456"; + base07 = "#123456"; + base08 = "#123456"; + base09 = "#123456"; + base0A = "#123456"; + base0B = "#123456"; + base0C = "#123456"; + base0D = "#123456"; + base0E = "#123456"; + base0F = "#123456"; + }; + }; + basics = {}; + bracketed = {}; + bufremove = {}; + colors = {}; + comment = {}; + completion = {}; + cursorword = {}; + doc = {}; + fuzzy = {}; + hipatterns = {}; + hues = { + background = "#351721"; + foreground = "#cdc4c6"; + }; + indentscope = {}; + jump = {}; + jump2d = {}; + map = {}; + misc = {}; + move = {}; + pairs = {}; + sessions = {}; + splitjoin = {}; + starter = {}; + statusline = {}; + surround = {}; + tabline = {}; + test = {}; + trailspace = {}; + }; + }; + }; +}