{ flake-parts-lib, lib, ... }: let dictionary = [ "Asahi" "Catppuccin" "Devshell" "LanguageTool" "LLMs" "LTeX" "NixOS" "Nushell" "SOPS" "Stylix" ]; in { options.perSystem = flake-parts-lib.mkPerSystemOption ( { pkgs, ... }: { options.languages.en-us = { enable = lib.mkEnableOption "en_US"; }; config = let tomlFormatter = pkgs.formats.toml { }; vale = { 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 = { name = ".vale.ini"; text = '' StylesPath = ${vale.styles.directory.name} MinAlertLevel = suggestion Vocab = General # https://vale.sh/explorer Packages = RedHat, proselint, write-good, alex [*.{md}] BasedOnStyles = Vale, RedHat, proselint, write-good, alex ''; path = pkgs.writeTextFile { name = vale.config.name; text = vale.config.text; }; }; directory = { 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 = { content = { default.extendWords = builtins.listToAttrs ( builtins.map (x: { name = x; value = x; }) dictionary ); }; file = tomlFormatter.generate "typos.toml" typos.content; }; in { editors.helix.languages.language-server = { # https://ltex-plus.github.io/ltex-plus/supported-languages.html ltex-ls-plus = { command = "${pkgs.ltex-ls-plus}/bin/ltex-ls-plus"; config.ltex = { dictionary.en-US = dictionary; additionalRules.enablePickyRules = true; }; }; # https://vale.sh/docs/formats/code vale-ls = { command = "${pkgs.vale-ls}/bin/vale-ls"; 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"; typos = { command = "${pkgs.typos-lsp}/bin/typos-lsp"; config.config = typos.file.outPath; }; }; pre-commit.settings = { hooks = { typos = { enable = true; settings = { configPath = typos.file.outPath; locale = "en-us"; }; }; vale = { enable = true; settings.configPath = "${vale.directory.path}/${vale.config.name}"; }; }; excludes = [ "base/languages/en-us/.vale" ]; }; treefmt = { programs.typos = { enable = true; configFile = typos.file.outPath; locale = "en-us"; }; settings.global.excludes = [ "base/languages/en-us/.vale/*" ]; }; devshells.default = { # commands = [ # { # help = " sync vale configuration"; # name = "vale-sync"; # command = "${pkgs.vale}/bin/vale sync --config ${vale.valeDirectory}/${vale.config.filename}"; # category = " Languages (en_US)"; # } # ]; # packages = [ pkgs.vale ]; # devshell.startup.vale_config.text = '' # ${pkgs.uutils-coreutils-noprefix}/bin/ln -fs ${vale.config.file} ${vale.valeDirectory}/${vale.config.filename} # ''; }; }; } ); }