1
0
Fork 0
nix-flake-base/languages/markdown/default.nix

64 lines
1.9 KiB
Nix

# SPDX-FileCopyrightText: 2025 Ethan Reece <contact@ethanreece.com>
#
# SPDX-License-Identifier: LGPL-3.0-or-later
{ module-name, ... }:
{ flake-parts-lib, lib, ... }:
{
options.perSystem = flake-parts-lib.mkPerSystemOption (
{ config, pkgs, ... }:
{
options.languages.${module-name} = {
enable = lib.mkEnableOption "Markdown";
text-wrap = lib.mkOption {
description = ''
Wrap lines.
'';
default = true;
type = lib.types.bool;
};
};
config = lib.mkIf config.languages.${module-name}.enable {
editors.helix.languages = {
language = [
{
name = "markdown";
language-servers =
[ "marksman" ]
++ (lib.optionals config.languages.en-us.enable [
"ltex-ls-plus"
"vale-ls"
"typos"
]);
formatter = {
command = "${config.treefmt.build.wrapper}/bin/treefmt";
args = [
"--stdin"
"%{buffer_name}"
"--quiet"
];
};
auto-format = true;
}
];
language-server.marksman.command = "${pkgs.marksman}/bin/marksman";
};
treefmt.programs.dprint = {
enable = true;
settings = {
plugins = (pkgs.dprint-plugins.getPluginList (plugins: with plugins; [ dprint-plugin-markdown ]));
markdown = {
lineWidth = 80;
textWrap = if config.languages.markdown.text-wrap then "always" else "maintain";
};
};
includes = [ "*.md" ];
};
pre-commit.settings.hooks.markdownlint = {
enable = true;
settings.configuration.MD013 = lib.mkIf (config.languages.markdown.text-wrap == false) false;
};
};
}
);
}