2023-04-17 21:38:57 +00:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
2023-11-08 02:16:46 +00:00
|
|
|
}: let
|
2024-01-18 16:28:46 +00:00
|
|
|
inherit (builtins) attrNames;
|
2024-01-18 18:40:27 +00:00
|
|
|
inherit (lib) mkEnableOption mkMappingOption mkOption types nvim 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 16:28:46 +00:00
|
|
|
defaultServer = "marksman";
|
|
|
|
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 {
|
|
|
|
options.vim.languages.markdown = {
|
2023-06-05 20:10:25 +00:00
|
|
|
enable = mkEnableOption "Markdown markup language support";
|
2023-04-17 21:38:57 +00:00
|
|
|
|
2024-01-18 18:40:27 +00:00
|
|
|
glow = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "Enable markdown preview in neovim with glow";
|
|
|
|
};
|
|
|
|
mappings = {
|
|
|
|
openPreview = mkMappingOption "Open preview" "<leader>p";
|
|
|
|
};
|
2023-04-17 21:38:57 +00:00
|
|
|
};
|
2023-04-17 21:55:27 +00:00
|
|
|
|
2024-02-12 13:19:27 +00:00
|
|
|
markdownPreview = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Enable markdown preview in neovim with markdown-preview.nvim";
|
|
|
|
};
|
|
|
|
|
|
|
|
autoStart = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Automatically open the preview window after entering a Markdown buffer";
|
|
|
|
};
|
|
|
|
|
|
|
|
autoClose = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "Automatically close the preview window after leaving a Markdown buffer";
|
|
|
|
};
|
|
|
|
|
|
|
|
lazyRefresh = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Only update preview when saving or leaving insert mode";
|
|
|
|
};
|
|
|
|
|
|
|
|
filetypes = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = ["markdown"];
|
|
|
|
description = "Allowed filetypes";
|
|
|
|
};
|
|
|
|
|
|
|
|
alwaysAllowPreview = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Allow preview on all filetypes";
|
|
|
|
};
|
|
|
|
|
|
|
|
broadcastServer = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Allow for outside and network wide connections";
|
|
|
|
};
|
|
|
|
|
|
|
|
customIP = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
description = "IP-address to use";
|
|
|
|
};
|
|
|
|
|
|
|
|
customPort = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
description = "Port to use";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-04-17 21:55:27 +00:00
|
|
|
treesitter = {
|
|
|
|
enable = mkOption {
|
|
|
|
description = "Enable Markdown treesitter";
|
|
|
|
type = types.bool;
|
|
|
|
default = config.vim.languages.enableTreesitter;
|
|
|
|
};
|
2023-04-17 22:36:14 +00:00
|
|
|
mdPackage = nvim.types.mkGrammarOption pkgs "markdown";
|
|
|
|
mdInlinePackage = nvim.types.mkGrammarOption pkgs "markdown-inline";
|
2023-04-17 21:55:27 +00:00
|
|
|
};
|
2024-01-18 16:28:46 +00:00
|
|
|
|
|
|
|
lsp = {
|
|
|
|
enable = mkEnableOption "Enable Markdown LSP support" // {default = config.vim.languages.enableLSP;};
|
|
|
|
|
|
|
|
server = mkOption {
|
|
|
|
description = "Markdown LSP server to use";
|
|
|
|
type = with types; enum (attrNames servers);
|
|
|
|
default = defaultServer;
|
|
|
|
};
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
description = "Markdown LSP server package, or the command to run as a list of strings";
|
|
|
|
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
|
|
|
|
type = with types; either package (listOf str);
|
|
|
|
default = servers.${cfg.lsp.server}.package;
|
|
|
|
};
|
|
|
|
};
|
2023-04-17 21:38:57 +00:00
|
|
|
};
|
|
|
|
}
|