configuration/common/components/spelling.user.nix
2023-11-28 09:46:03 -08:00

53 lines
1.7 KiB
Nix

{ config, ... }:
let
inherit (builtins) hashString readFile toFile toJSON;
inherit (config) host;
words =
(readFile ../resources/words.txt) +
(readFile (host.local + "/resources/words.txt"));
formats = {
chromium = toFile "words-chromium" (words + "checksum_v1 = ${hashString "md5" words}");
plaintext = toFile "words-plaintext" words;
};
in
{
# Chromium
xdg.configFile."chromium/Default/Custom Dictionary.txt".source = formats.chromium;
# CSpell
home.file.".cspell.json".text = toJSON {
dictionaries = [ "custom" ];
dictionaryDefinitions = [{ name = "custom"; path = formats.plaintext; }];
enableFiletypes = [ "haml" "liquid" "nix" "ruby" "shellscript" ];
};
# Firefox
home.file.".mozilla/firefox/${host.firefoxProfile}/persdict.dat".source = formats.plaintext;
# Obsidian
xdg.configFile."obsidian/Custom Dictionary.txt".source = formats.chromium;
# QOwnNotes
home.file.".hunspell_en_US".source = formats.plaintext;
# VSCodium
programs.vscode.userSettings = {
"cSpell.minWordLength" = 2;
"cSpell.customDictionaries" = {
custom = { path = formats.plaintext; };
custom-css = { path = ../resources/words-css.txt; };
custom-nix = { path = ../resources/words-nix.txt; };
custom-rust = { path = ../resources/words-rust.txt; };
custom-shellscript = { path = ../resources/words-shellscript.txt; };
};
"cSpell.languageSettings" = [
{ languageId = "css"; dictionaries = [ "custom-css" ]; }
{ languageId = "nix"; dictionaries = [ "custom-nix" ]; }
{ languageId = "rust"; dictionaries = [ "custom-rust" ]; }
{ languageId = "shellscript"; dictionaries = [ "custom-shellscript" ]; }
];
};
}