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 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,
...
}: 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<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"
});
'';
})

View file

@ -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,11 +29,16 @@ in {
options.vim.languages.markdown = {
enable = mkEnableOption "Markdown markup language support";
glow.enable = mkOption {
glow = {
enable = mkOption {
type = types.bool;
default = true;
description = "Enable markdown preview in neovim with glow";
};
mappings = {
openPreview = mkMappingOption "Open preview" "<leader>p";
};
};
treesitter = {
enable = mkOption {