From d40563ea9fabe891f14bbced9f749977a415b771 Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Wed, 15 May 2024 18:37:05 +0200 Subject: [PATCH] add Vale for prose linting --- formatter.nix | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/formatter.nix b/formatter.nix index 12853b5a..1bd494ca 100644 --- a/formatter.nix +++ b/formatter.nix @@ -45,5 +45,55 @@ ]; includes = [ "*.py" ]; }; + treefmt.settings.formatter.vale = + with pkgs; + let + vocab = "cLAN"; + style = "Docs"; + config = writeText "vale.ini" '' + StylesPath = ${styles} + Vocab = ${vocab} + + [*.md] + BasedOnStyles = Vale, ${style} + Vale.Terms = No + ''; + styles = symlinkJoin { + name = "vale-style"; + paths = [ + accept + headings + ]; + }; + accept = writeTextDir "config/vocabularies/${vocab}/accept.txt" '' + cLAN + Nix + NixOS + Nixpkgs + clan.lol + Clan + monorepo + ''; + headings = writeTextDir "${style}/headings.yml" '' + extends: capitalization + message: "'%s' should be in sentence case" + level: error + scope: heading + # $title, $sentence, $lower, $upper, or a pattern. + match: $sentence + ''; + in + { + command = "${vale}/bin/vale"; + options = [ "--config=${config}" ]; + includes = [ "*.md" ]; + # TODO: too much at once, fix piecemeal + excludes = [ + "README.md" + "docs/*" + "clanModules/*" + "pkgs/*" + ]; + }; }; }