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) { + /* + ... + */ + }; +}