languages/markdown: fixed glow not working and added option for changing keybind

This commit is contained in:
Donnerinoern 2024-01-18 19:40:27 +01:00
parent 75d553bf64
commit 0bfefe9779
3 changed files with 24 additions and 11 deletions

View file

@ -27,3 +27,5 @@ Release notes for release 0.6
- Added Gruvbox theme - Added Gruvbox theme
- Added marksman LSP for Markdown - Added marksman LSP for Markdown
- Fixed Markdown-previewer Glow not working and added an option for changing the preview keybind

View file

@ -4,9 +4,13 @@
lib, lib,
... ...
}: let }: let
inherit (lib) nvim mkIf mkMerge isList; inherit (lib) nvim mkIf mkMerge mkBinding isList;
cfg = config.vim.languages.markdown; cfg = config.vim.languages.markdown;
self = import ./markdown.nix {
inherit lib config pkgs;
};
mappings = self.options.vim.languages.markdown.glow.mappings;
servers = { servers = {
marksman = { marksman = {
package = pkgs.marksman; package = pkgs.marksman;
@ -34,12 +38,14 @@ in {
(mkIf cfg.glow.enable { (mkIf cfg.glow.enable {
vim.startPlugins = ["glow-nvim"]; vim.startPlugins = ["glow-nvim"];
vim.globals = { vim.maps.normal = mkMerge [
"glow_binary_path" = "${pkgs.glow}/bin"; (mkBinding cfg.glow.mappings.openPreview ":Glow<CR>" mappings.openPreview.description)
}; ];
vim.configRC.glow = nvim.dag.entryAnywhere '' vim.luaConfigRC.glow = nvim.dag.entryAnywhere ''
autocmd FileType markdown noremap <leader>p :Glow<CR> require('glow').setup({
glow_path = "${pkgs.glow}/bin/glow"
});
''; '';
}) })

View file

@ -5,7 +5,7 @@
... ...
}: let }: let
inherit (builtins) attrNames; inherit (builtins) attrNames;
inherit (lib) mkEnableOption mkOption types nvim isList; inherit (lib) mkEnableOption mkMappingOption mkOption types nvim isList;
cfg = config.vim.languages.markdown; cfg = config.vim.languages.markdown;
defaultServer = "marksman"; defaultServer = "marksman";
@ -29,10 +29,15 @@ in {
options.vim.languages.markdown = { options.vim.languages.markdown = {
enable = mkEnableOption "Markdown markup language support"; enable = mkEnableOption "Markdown markup language support";
glow.enable = mkOption { glow = {
type = types.bool; enable = mkOption {
default = true; type = types.bool;
description = "Enable markdown preview in neovim with glow"; default = true;
description = "Enable markdown preview in neovim with glow";
};
mappings = {
openPreview = mkMappingOption "Open preview" "<leader>p";
};
}; };
treesitter = { treesitter = {