From 26822d655dcfe4642dcab5f6361be589f1e1bf33 Mon Sep 17 00:00:00 2001
From: Gabriel Arazas <foodogsquared@foodogsquared.one>
Date: Fri, 26 Jan 2024 16:47:30 +0800
Subject: [PATCH] nixvim/plugins/firenvim: init

---
 modules/nixvim/default.nix          |  5 ++++
 modules/nixvim/plugins/firenvim.nix | 36 +++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)
 create mode 100644 modules/nixvim/default.nix
 create mode 100644 modules/nixvim/plugins/firenvim.nix

diff --git a/modules/nixvim/default.nix b/modules/nixvim/default.nix
new file mode 100644
index 00000000..fa4fbcbb
--- /dev/null
+++ b/modules/nixvim/default.nix
@@ -0,0 +1,5 @@
+{
+  imports = [
+    ./plugins/firenvim.nix
+  ];
+}
diff --git a/modules/nixvim/plugins/firenvim.nix b/modules/nixvim/plugins/firenvim.nix
new file mode 100644
index 00000000..9326a81e
--- /dev/null
+++ b/modules/nixvim/plugins/firenvim.nix
@@ -0,0 +1,36 @@
+{ config, lib, pkgs, helpers, ... }:
+
+let
+  cfg = config.plugins.firenvim;
+in
+{
+  options.plugins.firenvim = {
+    enable = lib.mkEnableOption "Firenvim";
+    package = helpers.mkPackageOption "firenvim" pkgs.vimPlugins.firenvim;
+    extraConfig = lib.mkOption {
+      type = with lib.types; attrsOf anything;
+      default = {};
+      example = {
+        globalSettings = { alt = "all"; };
+        localSettings = {
+          "\".*\"" = {
+            cmdline = "nvim";
+            content = "text";
+            priority = 0;
+            selector = "textarea";
+            takeover = "always";
+          };
+        };
+      };
+      description = ''
+        Extra configuration options for Firenvim.
+      '';
+    };
+  };
+
+  config = lib.mkIf cfg.enable {
+    extraPlugins = [ cfg.package ];
+
+    globals.firenvim_config = cfg.extraConfig;
+  };
+}