From 4434d9e05388fb62b80876bc6a5254495900c180 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 22:26:00 +0300 Subject: [PATCH] feat: apply new module format to markdown plugins --- modules/markdown/config.nix | 13 ++++++++++ modules/markdown/default.nix | 2 ++ modules/markdown/glow/config.nix | 16 ++++++++---- modules/markdown/glow/default.nix | 42 ++++--------------------------- modules/markdown/glow/glow.nix | 18 +++++++++++++ modules/markdown/module.nix | 20 +++++++++++++++ 6 files changed, 69 insertions(+), 42 deletions(-) create mode 100644 modules/markdown/config.nix create mode 100644 modules/markdown/glow/glow.nix create mode 100644 modules/markdown/module.nix diff --git a/modules/markdown/config.nix b/modules/markdown/config.nix new file mode 100644 index 0000000..ace4eaf --- /dev/null +++ b/modules/markdown/config.nix @@ -0,0 +1,13 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; { + config = { + vim.markdown = { + enable = mkDefault false; + }; + }; +} diff --git a/modules/markdown/default.nix b/modules/markdown/default.nix index 8b7e31e..2a0a1e5 100644 --- a/modules/markdown/default.nix +++ b/modules/markdown/default.nix @@ -6,5 +6,7 @@ }: { imports = [ ./glow + ./config.nix + ./module.nix ]; } diff --git a/modules/markdown/glow/config.nix b/modules/markdown/glow/config.nix index 72b0007..4ad906b 100644 --- a/modules/markdown/glow/config.nix +++ b/modules/markdown/glow/config.nix @@ -4,11 +4,17 @@ lib, ... }: -with lib; { - config = { - vim.markdown = { - enable = mkDefault false; - glow.enable = mkDefault false; +with lib; let + cfg = config.vim.markdown.glow; +in { + config = (mkIf cfg.enable) { + vim.startPlugins = ["glow-nvim"]; + vim.globals = { + "glow_binary_path" = "${pkgs.glow}/bin"; }; + + vim.configRC.glow = nvim.dag.entryAnywhere '' + autocmd FileType markdown noremap p :Glow + ''; }; } diff --git a/modules/markdown/glow/default.nix b/modules/markdown/glow/default.nix index e658446..9b128a3 100644 --- a/modules/markdown/glow/default.nix +++ b/modules/markdown/glow/default.nix @@ -1,38 +1,6 @@ -{ - pkgs, - config, - lib, - ... -}: -with lib; -with builtins; let - cfg = config.vim.markdown; -in { - options.vim.markdown = { - enable = mkEnableOption "markdown tools and plugins"; - - glow.enable = mkOption { - type = types.bool; - default = true; - description = "Enable markdown preview in neovim with glow"; - }; - }; - - config = mkIf (cfg.enable) { - vim.startPlugins = [ - ( - if cfg.glow.enable - then "glow-nvim" - else null - ) - ]; - - vim.globals = mkIf (cfg.glow.enable) { - "glow_binary_path" = "${pkgs.glow}/bin"; - }; - - vim.configRC.glow = mkIf (cfg.glow.enable) (nvim.dag.entryAnywhere '' - autocmd FileType markdown noremap p :Glow - ''); - }; +_: { + imports = [ + ./glow.nix + ./config.nix + ]; } diff --git a/modules/markdown/glow/glow.nix b/modules/markdown/glow/glow.nix new file mode 100644 index 0000000..be1c0c3 --- /dev/null +++ b/modules/markdown/glow/glow.nix @@ -0,0 +1,18 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.markdown; +in { + options.vim.markdown = { + glow.enable = mkOption { + type = types.bool; + default = false; + description = "Enable markdown preview in neovim with glow"; + }; + }; +} diff --git a/modules/markdown/module.nix b/modules/markdown/module.nix new file mode 100644 index 0000000..4292173 --- /dev/null +++ b/modules/markdown/module.nix @@ -0,0 +1,20 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.markdown; +in { + options.vim.markdown = { + enable = mkEnableOption "markdown tools and plugins"; + }; + + config = mkIf (cfg.enable) { + /* + ... + */ + }; +}