feat: enable and remap glow preview

This commit is contained in:
NotAShelf 2023-03-01 14:00:26 +03:00
parent cccc7f5bda
commit d817b27405
No known key found for this signature in database
GPG key ID: 5B5C8895F28445F1
3 changed files with 46 additions and 9 deletions

View file

@ -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 <leader>p :Glow<CR>
vim.configRC.glow-nvim = nvim.dag.entryAnywhere ''
autocmd FileType markdown noremap <leader>pm :Glow<CR>
'';
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,
})
'';
};
}

View file

@ -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";
};
};
}

View file

@ -107,9 +107,15 @@ in {
''
else ""
}
${
if config.vim.markdown.glow.enable
then ''
-- Markdown
["<leader>pm"] = { name = "+Preview Markdown" },
''
else ""
}
})
'';
};
}