diff --git a/modules/markdown/glow/config.nix b/modules/markdown/glow/config.nix index 4ad906b..f0019f2 100644 --- a/modules/markdown/glow/config.nix +++ b/modules/markdown/glow/config.nix @@ -8,13 +8,26 @@ with lib; let cfg = config.vim.markdown.glow; in { config = (mkIf cfg.enable) { - vim.startPlugins = ["glow-nvim"]; + vim.startPlugins = [ + "glow-nvim" + ]; + vim.globals = { "glow_binary_path" = "${pkgs.glow}/bin"; }; - vim.configRC.glow = nvim.dag.entryAnywhere '' - autocmd FileType markdown noremap p :Glow + vim.configRC.glow-nvim = nvim.dag.entryAnywhere '' + autocmd FileType markdown noremap pm :Glow + ''; + + vim.luaConfigRC.glow-nvim = nvim.dag.entryAnywhere '' + require('glow').setup({ + -- use glow path from vim.globals + path = vim.g.glow_binary_path, + border = "${toString cfg.border}", + pager = ${boolToString cfg.pager}, + width = 120, + }) ''; }; } diff --git a/modules/markdown/glow/glow.nix b/modules/markdown/glow/glow.nix index be1c0c3..48e4440 100644 --- a/modules/markdown/glow/glow.nix +++ b/modules/markdown/glow/glow.nix @@ -6,13 +6,31 @@ }: with lib; with builtins; let - cfg = config.vim.markdown; + cfg = config.vim.markdown.glow; in { - options.vim.markdown = { - glow.enable = mkOption { + options.vim.markdown.glow = { + enable = mkOption { type = types.bool; default = false; description = "Enable markdown preview in neovim with glow"; }; + border = mkOption { + type = types.enum ["shadow" "rounded" "single" "double" "none"]; + default = "double"; + description = "Border style for glow preview"; + }; + + # style should be either light or dark + style = mkOption { + type = types.enum ["light" "dark"]; + default = "dark"; + description = "Style for glow preview"; + }; + + pager = mkOption { + type = types.bool; + default = false; + description = "Enable pager for glow preview"; + }; }; } diff --git a/modules/utility/binds/which-key/config.nix b/modules/utility/binds/which-key/config.nix index 2ff37d8..8ce9c02 100644 --- a/modules/utility/binds/which-key/config.nix +++ b/modules/utility/binds/which-key/config.nix @@ -107,9 +107,15 @@ in { '' else "" } - - }) - + ${ + if config.vim.markdown.glow.enable + then '' + -- Markdown + ["pm"] = { name = "+Preview Markdown" }, + '' + else "" + } + }) ''; }; }