2023-04-17 21:38:57 +00:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
2023-11-08 02:16:46 +00:00
|
|
|
}: let
|
2024-01-18 18:40:27 +00:00
|
|
|
inherit (lib) nvim mkIf mkMerge mkBinding isList;
|
2023-11-08 02:16:46 +00:00
|
|
|
|
2023-04-17 21:38:57 +00:00
|
|
|
cfg = config.vim.languages.markdown;
|
2024-01-18 18:40:27 +00:00
|
|
|
self = import ./markdown.nix {
|
|
|
|
inherit lib config pkgs;
|
|
|
|
};
|
|
|
|
mappings = self.options.vim.languages.markdown.glow.mappings;
|
2024-01-18 16:28:46 +00:00
|
|
|
servers = {
|
|
|
|
marksman = {
|
|
|
|
package = pkgs.marksman;
|
|
|
|
lspConfig = ''
|
|
|
|
lspconfig.marksman.setup{
|
|
|
|
capabilities = capabilities;
|
|
|
|
on_attach = default_on_attach;
|
|
|
|
cmd = ${
|
|
|
|
if isList cfg.lsp.package
|
|
|
|
then nvim.lua.expToLua cfg.lsp.package
|
|
|
|
else ''{"${cfg.lsp.package}/bin/marksman", "server"}''
|
|
|
|
},
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2023-04-17 21:38:57 +00:00
|
|
|
in {
|
|
|
|
config = mkIf cfg.enable (mkMerge [
|
2023-04-17 21:55:27 +00:00
|
|
|
(mkIf cfg.treesitter.enable {
|
|
|
|
vim.treesitter.enable = true;
|
2023-04-17 22:36:14 +00:00
|
|
|
|
|
|
|
vim.treesitter.grammars = [cfg.treesitter.mdPackage cfg.treesitter.mdInlinePackage];
|
2023-04-17 21:55:27 +00:00
|
|
|
})
|
|
|
|
|
2023-04-17 21:38:57 +00:00
|
|
|
(mkIf cfg.glow.enable {
|
|
|
|
vim.startPlugins = ["glow-nvim"];
|
|
|
|
|
2024-01-18 18:40:27 +00:00
|
|
|
vim.maps.normal = mkMerge [
|
|
|
|
(mkBinding cfg.glow.mappings.openPreview ":Glow<CR>" mappings.openPreview.description)
|
|
|
|
];
|
2023-04-17 21:38:57 +00:00
|
|
|
|
2024-01-18 18:40:27 +00:00
|
|
|
vim.luaConfigRC.glow = nvim.dag.entryAnywhere ''
|
|
|
|
require('glow').setup({
|
|
|
|
glow_path = "${pkgs.glow}/bin/glow"
|
|
|
|
});
|
2023-04-17 21:38:57 +00:00
|
|
|
'';
|
|
|
|
})
|
2024-01-18 16:28:46 +00:00
|
|
|
|
|
|
|
(mkIf cfg.lsp.enable {
|
|
|
|
vim.lsp.lspconfig.enable = true;
|
|
|
|
|
|
|
|
vim.lsp.lspconfig.sources.markdown-lsp = servers.${cfg.lsp.server}.lspConfig;
|
|
|
|
})
|
2023-04-17 21:38:57 +00:00
|
|
|
]);
|
|
|
|
}
|