120 lines
3.4 KiB
Nix
120 lines
3.4 KiB
Nix
{ pkgs, treefmt }:
|
|
let
|
|
dictionary = [
|
|
"Asahi"
|
|
"LLMs"
|
|
"LTeX"
|
|
"NixOS"
|
|
];
|
|
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;
|
|
};
|
|
};
|
|
config = {
|
|
filename = ".vale.ini";
|
|
content = ''
|
|
StylesPath = styles
|
|
|
|
MinAlertLevel = suggestion
|
|
|
|
Vocab = General
|
|
|
|
# https://vale.sh/explorer
|
|
Packages = RedHat, proselint, write-good, alex
|
|
|
|
[*.{md}]
|
|
BasedOnStyles = Vale, RedHat, proselint, write-good, alex
|
|
'';
|
|
file = pkgs.writeTextFile {
|
|
name = vale.config.filename;
|
|
text = vale.config.content;
|
|
};
|
|
};
|
|
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}";
|
|
};
|
|
};
|
|
typos = {
|
|
content = {
|
|
default.extendWords = builtins.listToAttrs (
|
|
builtins.map (x: {
|
|
name = x;
|
|
value = x;
|
|
}) dictionary
|
|
);
|
|
};
|
|
file = tomlFormatter.generate "typos.toml" typos.content;
|
|
};
|
|
in
|
|
{
|
|
helix.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.configFile;
|
|
};
|
|
# 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 = {
|
|
typos = {
|
|
enable = true;
|
|
settings = {
|
|
configPath = typos.file.outPath;
|
|
locale = "en-us";
|
|
};
|
|
};
|
|
vale = {
|
|
enable = true;
|
|
settings.configPath = vale.directory.configFile;
|
|
};
|
|
};
|
|
treefmt.programs.typos = {
|
|
enable = true;
|
|
configFile = typos.file.outPath;
|
|
locale = "en-us";
|
|
};
|
|
devshell = {
|
|
commands = [
|
|
{
|
|
help = "sync vale configuration";
|
|
name = "vale-sync";
|
|
command = "${pkgs.vale}/bin/vale sync --config ${vale.valeDirectory}/${vale.config.filename}";
|
|
}
|
|
];
|
|
packages = [ pkgs.vale ];
|
|
devshellStartup = {
|
|
vale_config.text = ''
|
|
${pkgs.uutils-coreutils-noprefix}/bin/ln -fs ${vale.config.file} ${vale.valeDirectory}/${vale.config.filename}
|
|
'';
|
|
};
|
|
};
|
|
}
|