neovim-flake/modules/languages/markdown/markdown.nix

64 lines
1.8 KiB
Nix
Raw Normal View History

{
config,
pkgs,
lib,
...
}: let
2024-01-18 17:28:46 +01:00
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.lists) isList;
inherit (lib.types) bool enum either package listOf str;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption;
cfg = config.vim.languages.markdown;
2024-01-18 17:28:46 +01: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 expToLua cfg.lsp.package
2024-01-18 17:28:46 +01:00
else ''{"${cfg.lsp.package}/bin/marksman", "server"}''
},
}
'';
};
};
in {
options.vim.languages.markdown = {
enable = mkEnableOption "Markdown markup language support";
2023-04-17 23:55:27 +02:00
treesitter = {
enable = mkOption {
description = "Enable Markdown treesitter";
type = bool;
2023-04-17 23:55:27 +02:00
default = config.vim.languages.enableTreesitter;
};
mdPackage = mkGrammarOption pkgs "markdown";
mdInlinePackage = mkGrammarOption pkgs "markdown-inline";
2023-04-17 23:55:27 +02:00
};
2024-01-18 17:28:46 +01:00
lsp = {
enable = mkEnableOption "Enable Markdown LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "Markdown LSP server to use";
type = enum (attrNames servers);
2024-01-18 17:28:46 +01:00
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 = either package (listOf str);
2024-01-18 17:28:46 +01:00
default = servers.${cfg.lsp.server}.package;
};
};
};
}