languages/markdown: move to standalone file; add deno formatter

This commit is contained in:
NotAShelf 2024-05-06 22:22:43 +03:00
parent efd8b44ce1
commit 3045247e0a
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
5 changed files with 45 additions and 51 deletions

View file

@ -58,7 +58,12 @@ inputs: let
enableTreesitter = true;
enableExtraDiagnostics = true;
nim.enable = false;
elixir.enable = false;
nix.enable = true;
markdown.enable = true;
html.enable = isMaximal;
css.enable = isMaximal;
sql.enable = isMaximal;
@ -69,10 +74,7 @@ inputs: let
zig.enable = isMaximal;
python.enable = isMaximal;
dart.enable = isMaximal;
elixir.enable = isMaximal;
bash.enable = isMaximal;
terraform.enable = isMaximal;
nim.enable = false;
tailwind.enable = isMaximal;
typst.enable = isMaximal;
clang = {

View file

@ -5,7 +5,6 @@ in {
./bash
./dart
./elixir
./markdown
./tidal
./clang.nix
@ -14,6 +13,7 @@ in {
./html.nix
./java.nix
./lua.nix
./markdown.nix
./nim.nix
./nix.nix
./php.nix

View file

@ -4,7 +4,7 @@
lib,
...
}: let
inherit (builtins) attrNames;
inherit (builtins) attrNames concatLists;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.lists) isList;
inherit (lib.types) bool enum either package listOf str;
@ -29,6 +29,22 @@
'';
};
};
defaultFormat = "denofmt";
formats = {
denofmt = {
package = pkgs.deno;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.deno_fmt.with({
filetypes = ${concatLists cfg.format.extraFiletypes ["markdown"]},
command = "${cfg.format.package}/bin/deno",
})
)
'';
};
};
in {
options.vim.languages.markdown = {
enable = mkEnableOption "Markdown markup language support";
@ -59,5 +75,27 @@ in {
default = servers.${cfg.lsp.server}.package;
};
};
format = {
enable = mkEnableOption "Markdown formatting" // {default = config.vim.languages.enableFormat;};
type = mkOption {
description = "Markdown formatter to use";
type = enum (attrNames formats);
default = defaultFormat;
};
package = mkOption {
description = "Markdown formatter package";
type = package;
default = formats.${cfg.format.type}.package;
};
extraFiletypes = mkOption {
description = "Extra filetypes to format with the Markdown formatter";
type = listOf str;
default = [];
};
};
};
}

View file

@ -1,40 +0,0 @@
{
pkgs,
config,
lib,
...
}: let
inherit (lib.nvim.lua) expToLua;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
cfg = config.vim.languages.markdown;
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
else ''{"${cfg.lsp.package}/bin/marksman", "server"}''
},
}
'';
};
};
in {
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.mdPackage cfg.treesitter.mdInlinePackage];
})
(mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.markdown-lsp = servers.${cfg.lsp.server}.lspConfig;
})
]);
}

View file

@ -1,6 +0,0 @@
{...}: {
imports = [
./config.nix
./markdown.nix
];
}