diff --git a/docs/release-notes/rl-0.6.md b/docs/release-notes/rl-0.6.md index f1ef364..de68373 100644 --- a/docs/release-notes/rl-0.6.md +++ b/docs/release-notes/rl-0.6.md @@ -27,3 +27,5 @@ Release notes for release 0.6 - Added Gruvbox theme - Added marksman LSP for Markdown + +- Fixed Markdown-previewer Glow not working and added an option for changing the preview keybind diff --git a/modules/languages/markdown/config.nix b/modules/languages/markdown/config.nix index 8a9e7eb..7084314 100644 --- a/modules/languages/markdown/config.nix +++ b/modules/languages/markdown/config.nix @@ -4,9 +4,13 @@ lib, ... }: let - inherit (lib) nvim mkIf mkMerge isList; + inherit (lib) nvim mkIf mkMerge mkBinding isList; cfg = config.vim.languages.markdown; + self = import ./markdown.nix { + inherit lib config pkgs; + }; + mappings = self.options.vim.languages.markdown.glow.mappings; servers = { marksman = { package = pkgs.marksman; @@ -34,12 +38,14 @@ in { (mkIf cfg.glow.enable { vim.startPlugins = ["glow-nvim"]; - vim.globals = { - "glow_binary_path" = "${pkgs.glow}/bin"; - }; + vim.maps.normal = mkMerge [ + (mkBinding cfg.glow.mappings.openPreview ":Glow" mappings.openPreview.description) + ]; - vim.configRC.glow = nvim.dag.entryAnywhere '' - autocmd FileType markdown noremap p :Glow + vim.luaConfigRC.glow = nvim.dag.entryAnywhere '' + require('glow').setup({ + glow_path = "${pkgs.glow}/bin/glow" + }); ''; }) diff --git a/modules/languages/markdown/markdown.nix b/modules/languages/markdown/markdown.nix index 9ff06f8..7c07667 100644 --- a/modules/languages/markdown/markdown.nix +++ b/modules/languages/markdown/markdown.nix @@ -5,7 +5,7 @@ ... }: let inherit (builtins) attrNames; - inherit (lib) mkEnableOption mkOption types nvim isList; + inherit (lib) mkEnableOption mkMappingOption mkOption types nvim isList; cfg = config.vim.languages.markdown; defaultServer = "marksman"; @@ -29,10 +29,15 @@ in { options.vim.languages.markdown = { enable = mkEnableOption "Markdown markup language support"; - glow.enable = mkOption { - type = types.bool; - default = true; - description = "Enable markdown preview in neovim with glow"; + glow = { + enable = mkOption { + type = types.bool; + default = true; + description = "Enable markdown preview in neovim with glow"; + }; + mappings = { + openPreview = mkMappingOption "Open preview" "p"; + }; }; treesitter = {