Skip to content

Commit

Permalink
languages/markdown: fixed glow not working and added option for chang…
Browse files Browse the repository at this point in the history
…ing keybind
  • Loading branch information
Donnerinoern committed Jan 18, 2024
1 parent 75d553b commit 0bfefe9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
2 changes: 2 additions & 0 deletions docs/release-notes/rl-0.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 12 additions & 6 deletions modules/languages/markdown/config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<CR>" mappings.openPreview.description)
];

vim.configRC.glow = nvim.dag.entryAnywhere ''
autocmd FileType markdown noremap <leader>p :Glow<CR>
vim.luaConfigRC.glow = nvim.dag.entryAnywhere ''
require('glow').setup({
glow_path = "${pkgs.glow}/bin/glow"
});
'';
})

Expand Down
15 changes: 10 additions & 5 deletions modules/languages/markdown/markdown.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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" "<leader>p";
};
};

treesitter = {
Expand Down

0 comments on commit 0bfefe9

Please sign in to comment.