diff --git a/modules/nixvim/default.nix b/modules/nixvim/default.nix index 854954de..38fbe87e 100644 --- a/modules/nixvim/default.nix +++ b/modules/nixvim/default.nix @@ -3,6 +3,7 @@ ./keyunmaps.nix ./plugins/firenvim.nix ./plugins/lush-nvim.nix + ./plugins/legendary-nvim.nix ./plugins/nvim-config-local.nix ./plugins/smart-splits.nix ./tinted-theming.nix diff --git a/modules/nixvim/plugins/legendary-nvim.nix b/modules/nixvim/plugins/legendary-nvim.nix new file mode 100644 index 00000000..b006b0dd --- /dev/null +++ b/modules/nixvim/plugins/legendary-nvim.nix @@ -0,0 +1,68 @@ +{ config, lib, helpers, pkgs, ... }: + +let + cfg = config.plugins.legendary-nvim; + + mkEnableOption' = desc: lib.mkEnableOption desc // { default = true; }; +in +{ + options.plugins.legendary-nvim = { + enable = lib.mkEnableOption "legendary.nvim"; + + package = helpers.mkPackageOption "legendary.nvim" pkgs.vimPlugins.legendary-nvim; + + additionalSetup = mkEnableOption' "dependencies for additional features like frecency sorting"; + + integrations = { + nvim-tree.enable = + mkEnableOption' "integration with nvim-tree (if installed)"; + smart-splits.enable = + mkEnableOption' "integration with smart-splits.nvim (if installed)"; + diffview.enable = + mkEnableOption' "integration with diffview (if installed)"; + }; + + settings = lib.mkOption { + type = lib.types.submodule { + freefromType = with lib.types; attrsOf anything; + + config = lib.mkMerge [ + (lib.mkIf + ( + config.plugins.nvim-tree.enable && cfg.integrations.nvim-tree.enable + ) + { extensions.nvim_tree = true; }) + (lib.mkIf + ( + config.plugins.smart-splits.enable && cfg.integrations.smart-splits.enable + ) + { + extensions.smart_splits = { + directions = [ "h" "j" "k" "l" ]; + mods = { }; + }; + }) + (lib.mkIf + ( + config.plugins.diffview.enable && cfg.integrations.diffview.enable + ) + { extensions.diffview = true; }) + ]; + }; + default = { }; + example = { }; + }; + }; + + config = lib.mkIf cfg.enable { + extraPlugins = + [ cfg.package ] + ++ lib.optional cfg.additionalSetup pkgs.vimPlugins.sqlite-lua; + + extraPackages = lib.optional cfg.additionalSetup pkgs.sqlite; + + extraConfigLua = '' + require('legendary').setup(${helpers.toLuaObject cfg.settings}) + ''; + }; +}