Improve dictionary handling for en-us
This commit is contained in:
parent
cefdf3bc5d
commit
3646dbaaa7
6 changed files with 63 additions and 23 deletions
2
.envrc
2
.envrc
|
@ -1 +1,3 @@
|
||||||
use flake
|
use flake
|
||||||
|
watch_file ./home
|
||||||
|
watch_file ./languages
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
.direnv
|
.direnv
|
||||||
.helix
|
.helix
|
||||||
|
.vale/styles/config/vocabularies/General
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
Asahi
|
|
||||||
NixOS
|
|
||||||
LLMs
|
|
||||||
LTeX
|
|
|
@ -10,4 +10,4 @@ This repository has the Nix home-manager configuration for my laptop, allowing m
|
||||||
- **`treefmt`** (with Helix integration) - Automatically formats this repository when modifying it, with features to check the flake for formatting consistency
|
- **`treefmt`** (with Helix integration) - Automatically formats this repository when modifying it, with features to check the flake for formatting consistency
|
||||||
- **Language Server Protocol (LSP)** - Has language servers for file formats used in this repository; integrates with Helix text editor and fully managed by Nix with each language's configuration in its own file
|
- **Language Server Protocol (LSP)** - Has language servers for file formats used in this repository; integrates with Helix text editor and fully managed by Nix with each language's configuration in its own file
|
||||||
- **AI** - Uses Nix home-manager integrations for Codex and `aichat` for querying Large Language Models (LLMs) in the CLI and in Git repositories
|
- **AI** - Uses Nix home-manager integrations for Codex and `aichat` for querying Large Language Models (LLMs) in the CLI and in Git repositories
|
||||||
- **Language tools** - Checks for grammatical and styling issues using Vale, Harper, LTeX, and Typos
|
- **Language tools** - Checks for grammatical and styling issues using Vale, Harper, LTeX, and Typos, centralizing the custom dictionary for these tools in the Nix configuration
|
||||||
|
|
22
flake.nix
22
flake.nix
|
@ -41,6 +41,7 @@
|
||||||
# ./home/flake-module.nix
|
# ./home/flake-module.nix
|
||||||
];
|
];
|
||||||
flake = {
|
flake = {
|
||||||
|
# https://nix-community.github.io/home-manager/options.xhtml
|
||||||
homeConfigurations = {
|
homeConfigurations = {
|
||||||
asahi = withSystem "aarch64-linux" (
|
asahi = withSystem "aarch64-linux" (
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
|
@ -82,21 +83,27 @@
|
||||||
};
|
};
|
||||||
treefmtPrograms = builtins.foldl' (acc: cfg: acc // (cfg.treefmt.programs or { })) { } configs;
|
treefmtPrograms = builtins.foldl' (acc: cfg: acc // (cfg.treefmt.programs or { })) { } configs;
|
||||||
preCommitHooks = builtins.foldl' (acc: cfg: acc // (cfg.pre-commit or { })) { } configs;
|
preCommitHooks = builtins.foldl' (acc: cfg: acc // (cfg.pre-commit or { })) { } configs;
|
||||||
devshellCommands = builtins.concatMap (cfg: cfg.devshell.commands) (
|
devshellConfigs = {
|
||||||
|
commands = builtins.concatMap (cfg: cfg.devshell.commands) (
|
||||||
(builtins.filter (cfg: builtins.hasAttr "commands" cfg.devshell) (
|
(builtins.filter (cfg: builtins.hasAttr "commands" cfg.devshell) (
|
||||||
builtins.filter (cfg: builtins.hasAttr "devshell" cfg) configs
|
builtins.filter (cfg: builtins.hasAttr "devshell" cfg) configs
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
devshellPackages = builtins.concatMap (cfg: cfg.devshell.packages) (
|
packages = builtins.concatMap (cfg: cfg.devshell.packages) (
|
||||||
(builtins.filter (cfg: builtins.hasAttr "packages" cfg.devshell) (
|
(builtins.filter (cfg: builtins.hasAttr "packages" cfg.devshell) (
|
||||||
builtins.filter (cfg: builtins.hasAttr "devshell" cfg) configs
|
builtins.filter (cfg: builtins.hasAttr "devshell" cfg) configs
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
|
devshellStartup = builtins.foldl' (
|
||||||
|
acc: cfg: acc // (cfg.devshell.devshellStartup or { })
|
||||||
|
) { } configs;
|
||||||
|
};
|
||||||
helixLanguagesFormat = pkgs.formats.toml { };
|
helixLanguagesFormat = pkgs.formats.toml { };
|
||||||
helixLanguagesFile = helixLanguagesFormat.generate "languages.toml" helixLanguages;
|
helixLanguagesFile = helixLanguagesFormat.generate "languages.toml" helixLanguages;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
_module.args.pkgs = pkgs;
|
_module.args.pkgs = pkgs;
|
||||||
|
# https://flake.parts/options/devshell.html
|
||||||
devshells.default = {
|
devshells.default = {
|
||||||
commands = [
|
commands = [
|
||||||
{
|
{
|
||||||
|
@ -134,7 +141,7 @@
|
||||||
name = "sops-edit";
|
name = "sops-edit";
|
||||||
command = "${pkgs.sops}/bin/sops edit ./home/secrets/secrets.yaml";
|
command = "${pkgs.sops}/bin/sops edit ./home/secrets/secrets.yaml";
|
||||||
}
|
}
|
||||||
] ++ devshellCommands;
|
] ++ devshellConfigs.commands;
|
||||||
packages = [
|
packages = [
|
||||||
pkgs.age
|
pkgs.age
|
||||||
pkgs.forgejo-cli
|
pkgs.forgejo-cli
|
||||||
|
@ -146,14 +153,17 @@
|
||||||
pkgs.man
|
pkgs.man
|
||||||
pkgs.sops
|
pkgs.sops
|
||||||
pkgs.uutils-coreutils-noprefix
|
pkgs.uutils-coreutils-noprefix
|
||||||
] ++ devshellPackages;
|
] ++ devshellConfigs.packages;
|
||||||
devshell = {
|
devshell = {
|
||||||
motd = ''
|
motd = ''
|
||||||
{202}🔨 Nix Laptop Configuration{reset}
|
{202}🔨 Nix Laptop Configuration{reset}
|
||||||
$(type -p menu &>/dev/null && menu)
|
$(type -p menu &>/dev/null && menu)
|
||||||
'';
|
'';
|
||||||
name = "Laptop Configuration";
|
name = "Laptop Configuration";
|
||||||
startup = {
|
startup = devshellConfigs.devshellStartup // {
|
||||||
|
# https://github.com/helix-editor/helix/blob/master/languages.toml
|
||||||
|
# https://helix-editor.vercel.app/reference/formatters
|
||||||
|
# https://docs.helix-editor.com/lang-support.html
|
||||||
helix_config = {
|
helix_config = {
|
||||||
text = ''
|
text = ''
|
||||||
mkdir -p .helix
|
mkdir -p .helix
|
||||||
|
@ -163,9 +173,11 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
# https://flake.parts/options/git-hooks-nix.html
|
||||||
pre-commit.settings = {
|
pre-commit.settings = {
|
||||||
hooks = preCommitHooks;
|
hooks = preCommitHooks;
|
||||||
};
|
};
|
||||||
|
# https://flake.parts/options/treefmt-nix.html
|
||||||
treefmt = {
|
treefmt = {
|
||||||
projectRootFile = "flake.nix";
|
projectRootFile = "flake.nix";
|
||||||
programs = treefmtPrograms;
|
programs = treefmtPrograms;
|
||||||
|
|
|
@ -1,19 +1,42 @@
|
||||||
{ pkgs, treefmt }:
|
{ pkgs, treefmt }:
|
||||||
|
let
|
||||||
|
dictionary = [
|
||||||
|
"Asahi"
|
||||||
|
"LLMs"
|
||||||
|
"LTeX"
|
||||||
|
"NixOS"
|
||||||
|
];
|
||||||
|
tomlFormatter = pkgs.formats.toml { };
|
||||||
|
valeDictionary = {
|
||||||
|
directory = "./.vale/styles/config/vocabularies/General";
|
||||||
|
filename = "accept.txt";
|
||||||
|
content = builtins.concatStringsSep "\n" dictionary;
|
||||||
|
file = builtins.toFile valeDictionary.filename valeDictionary.content;
|
||||||
|
};
|
||||||
|
typosConfig = {
|
||||||
|
default.extendWords =
|
||||||
|
# dictionary:
|
||||||
|
builtins.listToAttrs (
|
||||||
|
builtins.map (x: {
|
||||||
|
name = x;
|
||||||
|
value = x;
|
||||||
|
}) dictionary
|
||||||
|
);
|
||||||
|
};
|
||||||
|
typosConfigFile = tomlFormatter.generate "_typos.toml" typosConfig;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
helix.language-server = {
|
helix.language-server = {
|
||||||
ltex-ls-plus = {
|
ltex-ls-plus = {
|
||||||
command = "${pkgs.ltex-ls-plus}/bin/ltex-ls-plus";
|
command = "${pkgs.ltex-ls-plus}/bin/ltex-ls-plus";
|
||||||
config.ltex.dictionary.en-US = [
|
config.ltex.dictionary.en-US = dictionary;
|
||||||
"Asahi"
|
|
||||||
"LLMs"
|
|
||||||
"LTeX"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
vale-ls.command = "${pkgs.vale-ls}/bin/vale-ls";
|
vale-ls.command = "${pkgs.vale-ls}/bin/vale-ls";
|
||||||
};
|
};
|
||||||
treefmt.programs.typos = {
|
treefmt.programs.typos = {
|
||||||
enable = true;
|
enable = true;
|
||||||
locale = "en-us";
|
locale = "en-us";
|
||||||
|
configFile = typosConfigFile.outPath;
|
||||||
};
|
};
|
||||||
devshell = {
|
devshell = {
|
||||||
commands = [
|
commands = [
|
||||||
|
@ -24,5 +47,11 @@
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
packages = [ pkgs.vale ];
|
packages = [ pkgs.vale ];
|
||||||
|
devshellStartup = {
|
||||||
|
vale_config.text = ''
|
||||||
|
mkdir -p ${valeDictionary.directory}
|
||||||
|
${pkgs.uutils-coreutils-noprefix}/bin/ln -fs ${valeDictionary.file} ${valeDictionary.directory}/${valeDictionary.filename}
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue