From fd987fc50ad4262579b73cf5ce2a1e3f980774b7 Mon Sep 17 00:00:00 2001 From: Ethan Reece Date: Mon, 14 Jul 2025 00:37:48 -0500 Subject: [PATCH] Tidy Vale configuration --- .gitignore | 1 - base/helix/default.nix | 4 +- base/languages/en-us/default.nix | 64 +++++++++++++++++++------------- 3 files changed, 41 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index 3336057..9dac504 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ .direnv .helix .pre-commit-config.yaml -.vale/.vale.ini diff --git a/base/helix/default.nix b/base/helix/default.nix index c8d8c67..f5132a7 100644 --- a/base/helix/default.nix +++ b/base/helix/default.nix @@ -43,8 +43,8 @@ in helix = { languages = { name = "languages.toml"; - content = config.helix.languages; - path = tomlFormatter.generate "languages.toml" helix.languages.content; + text = config.helix.languages; + path = tomlFormatter.generate "languages.toml" helix.languages.text; }; directory = { name = ".helix"; diff --git a/base/languages/en-us/default.nix b/base/languages/en-us/default.nix index 4bb302a..990bf38 100644 --- a/base/languages/en-us/default.nix +++ b/base/languages/en-us/default.nix @@ -16,21 +16,32 @@ in let tomlFormatter = pkgs.formats.toml { }; vale = { - valeDirectory = ".vale"; - stylesDirectory = "styles"; - dictionary = { - directory = "config/vocabularies/General"; - filename = "accept.txt"; - content = builtins.concatStringsSep "\n" dictionary; - file = pkgs.writeTextFile { - name = vale.dictionary.filename; - text = vale.dictionary.content; + styles = { + directory = { + name = "styles"; + base = .vale/styles; }; + dictionary = { + directory = { + name = "config/vocabularies/General"; + }; + name = "accept.txt"; + text = builtins.concatStringsSep "\n" dictionary; + path = pkgs.writeTextFile { + name = vale.styles.dictionary.name; + text = vale.styles.dictionary.text; + }; + }; + path = pkgs.runCommand vale.styles.directory.name { } '' + ${pkgs.uutils-coreutils-noprefix}/bin/mkdir -p $out/${vale.styles.dictionary.directory.name} + ${pkgs.uutils-coreutils-noprefix}/bin/cp -r ${vale.styles.directory.base}/* $out + ${pkgs.uutils-coreutils-noprefix}/bin/ln -fs ${vale.styles.dictionary.path} $out/${vale.styles.dictionary.directory.name}/${vale.styles.dictionary.name} + ''; }; config = { - filename = ".vale.ini"; - content = '' - StylesPath = styles + name = ".vale.ini"; + text = '' + StylesPath = ${vale.styles.directory.name} MinAlertLevel = suggestion @@ -42,20 +53,23 @@ in [*.{md}] BasedOnStyles = Vale, RedHat, proselint, write-good, alex ''; - file = pkgs.writeTextFile { - name = vale.config.filename; - text = vale.config.content; + path = pkgs.writeTextFile { + name = vale.config.name; + text = vale.config.text; }; }; directory = { - base = .vale/styles; - full = pkgs.runCommand vale.valeDirectory { } '' - ${pkgs.uutils-coreutils-noprefix}/bin/mkdir -p $out/${vale.stylesDirectory}/${vale.dictionary.directory} - ${pkgs.uutils-coreutils-noprefix}/bin/cp -r ${vale.directory.base}/* $out/${vale.stylesDirectory} - ${pkgs.uutils-coreutils-noprefix}/bin/ln -fs ${vale.dictionary.file} $out/${vale.stylesDirectory}/${vale.dictionary.directory}/${vale.dictionary.filename} - ${pkgs.uutils-coreutils-noprefix}/bin/ln -fs ${vale.config.file} $out/${vale.config.filename}; - ''; - configFile = "${vale.directory.full}/${vale.config.filename}"; + name = ".vale"; + path = pkgs.linkFarm vale.directory.name [ + { + name = vale.config.name; + path = vale.config.path; + } + { + name = vale.styles.directory.name; + path = vale.styles.path; + } + ]; }; }; typos = { @@ -84,7 +98,7 @@ in # https://vale.sh/docs/formats/code vale-ls = { command = "${pkgs.vale-ls}/bin/vale-ls"; - config.configPath = vale.directory.configFile; + config.configPath = "${vale.directory.path}/${vale.config.name}"; }; # https://writewithharper.com/docs/integrations/language-server#Supported-Languages harper-ls.command = "${pkgs.harper}/bin/harper-ls"; @@ -104,7 +118,7 @@ in }; vale = { enable = true; - settings.configPath = vale.directory.configFile; + settings.configPath = "${vale.directory.path}/${vale.config.name}"; }; }; excludes = [ "base/languages/en-us/.vale" ];