mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-26 15:06:45 +00:00
feat: enable and remap glow preview
This commit is contained in:
parent
cccc7f5bda
commit
d817b27405
3 changed files with 46 additions and 9 deletions
|
@ -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,
|
||||
})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -107,9 +107,15 @@ in {
|
|||
''
|
||||
else ""
|
||||
}
|
||||
|
||||
${
|
||||
if config.vim.markdown.glow.enable
|
||||
then ''
|
||||
-- Markdown
|
||||
["<leader>pm"] = { name = "+Preview Markdown" },
|
||||
''
|
||||
else ""
|
||||
}
|
||||
})
|
||||
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue