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

View file

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

View file

@ -4,7 +4,7 @@
lib, lib,
... ...
}: let }: let
inherit (builtins) attrNames; inherit (builtins) attrNames concatLists;
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.lists) isList; inherit (lib.lists) isList;
inherit (lib.types) bool enum either package listOf str; 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 { in {
options.vim.languages.markdown = { options.vim.languages.markdown = {
enable = mkEnableOption "Markdown markup language support"; enable = mkEnableOption "Markdown markup language support";
@ -59,5 +75,27 @@ in {
default = servers.${cfg.lsp.server}.package; 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
];
}