1
0
Fork 0

Add configuration options for languages

This commit is contained in:
Ethan Reece 2025-07-14 09:30:37 -05:00
parent 461763d132
commit e159b135ff
Signed by: me
GPG key ID: DD8CE04D5D8FF832
10 changed files with 296 additions and 270 deletions

View file

@ -1,35 +1,33 @@
{ flake-parts-lib, lib, ... }: { flake-parts-lib, lib, ... }:
let
inherit (lib) mkOption types;
in
{ {
imports = [ ../base ]; imports = [ ../base ];
options.perSystem = flake-parts-lib.mkPerSystemOption ( options.perSystem = flake-parts-lib.mkPerSystemOption (
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
options.helix = { options.editors.helix = {
enable = lib.mkEnableOption "Helix";
# https://github.com/helix-editor/helix/blob/master/languages.toml # https://github.com/helix-editor/helix/blob/master/languages.toml
# https://helix-editor.vercel.app/reference/formatters # https://helix-editor.vercel.app/reference/formatters
# https://docs.helix-editor.com/lang-support.html # https://docs.helix-editor.com/lang-support.html
languages = mkOption { languages = lib.mkOption {
description = '' description = ''
Configuration for Helix `languages.toml`. Configuration for Helix `languages.toml`.
''; '';
# type = types.attrs; # type = types.attrs;
type = types.submodule { type = lib.types.submodule {
options = { options = {
language = mkOption { language = lib.mkOption {
description = '' description = ''
`language` in `languages.toml`. `language` in `languages.toml`.
''; '';
type = types.listOf types.attrs; type = lib.types.listOf lib.types.attrs;
default = [ ]; default = [ ];
}; };
language-server = mkOption { language-server = lib.mkOption {
description = '' description = ''
`language-server` in `languages.toml`. `language-server` in `languages.toml`.
''; '';
type = types.attrs; type = lib.types.attrs;
default = { }; default = { };
}; };
}; };
@ -37,13 +35,13 @@ in
default = { }; default = { };
}; };
}; };
config.devshells.default = config.devshells.default = lib.mkIf config.editors.helix.enable (
let let
tomlFormatter = pkgs.formats.toml { }; tomlFormatter = pkgs.formats.toml { };
helix = { helix = {
languages = { languages = {
name = "languages.toml"; name = "languages.toml";
text = config.helix.languages; text = config.editors.helix.languages;
path = tomlFormatter.generate "languages.toml" helix.languages.text; path = tomlFormatter.generate "languages.toml" helix.languages.text;
}; };
directory = { directory = {
@ -72,7 +70,8 @@ in
${pkgs.uutils-coreutils-noprefix}/bin/rm -rf ./${helix.directory.name} ${pkgs.uutils-coreutils-noprefix}/bin/rm -rf ./${helix.directory.name}
${pkgs.uutils-coreutils-noprefix}/bin/ln -fsn ${helix.directory.path} ./${helix.directory.name} ${pkgs.uutils-coreutils-noprefix}/bin/ln -fsn ${helix.directory.path} ./${helix.directory.name}
''; '';
}; }
);
} }
); );
} }

View file

@ -1,11 +1,8 @@
{ ... }: { ... }:
let let
entries = builtins.attrNames (builtins.readDir ./.); entries = builtins.attrNames (builtins.readDir ./.);
configs = builtins.filter (dir: builtins.pathExists (./. + "/${dir}/default.nix")) entries; modules = builtins.filter (dir: builtins.pathExists (./. + "/${dir}/default.nix")) entries;
in in
{ {
imports = [ imports = builtins.map (name: (./. + "/${name}")) modules;
../base
../helix
] ++ builtins.map (name: (./. + "/${name}")) configs;
} }

View file

@ -1,4 +1,4 @@
{ ... }: { flake-parts-lib, lib, ... }:
let let
dictionary = [ dictionary = [
"Asahi" "Asahi"
@ -14,138 +14,145 @@ let
]; ];
in in
{ {
perSystem = options.perSystem = flake-parts-lib.mkPerSystemOption (
{ pkgs, ... }: { pkgs, ... }:
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
{ {
helix.languages.language-server = { options.languages.en-us = {
# https://ltex-plus.github.io/ltex-plus/supported-languages.html enable = lib.mkEnableOption "en_US";
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 = { config =
hooks = { 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 = { typos = {
enable = true; content = {
settings = { default.extendWords = builtins.listToAttrs (
configPath = typos.file.outPath; 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"; locale = "en-us";
}; };
settings.global.excludes = [ "base/languages/en-us/.vale/*" ];
}; };
vale = { devshells.default = {
enable = true; # commands = [
settings.configPath = "${vale.directory.path}/${vale.config.name}"; # {
# 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}
# '';
}; };
}; };
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}
# '';
};
};
} }

View file

@ -1,43 +1,47 @@
{ ... }: { flake-parts-lib, lib, ... }:
{ {
imports = [ ../en-us ]; imports = [ ../en-us ];
perSystem = options.perSystem = flake-parts-lib.mkPerSystemOption (
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
helix.languages = { options.languages.markdown.enable = lib.mkEnableOption "Markdown";
language = [ config = {
{ editors.helix.languages = {
name = "markdown"; language = [
language-servers = [ {
"marksman" name = "markdown";
"ltex-ls-plus" language-servers = [
"vale-ls" "marksman"
"typos" "ltex-ls-plus"
]; "vale-ls"
formatter = { "typos"
command = "${config.treefmt.build.wrapper}/bin/treefmt";
args = [
"--stdin"
".md"
"--quiet"
]; ];
}; formatter = {
auto-format = true; command = "${config.treefmt.build.wrapper}/bin/treefmt";
} args = [
]; "--stdin"
language-server.marksman.command = "${pkgs.marksman}/bin/marksman"; ".md"
}; "--quiet"
treefmt.programs.dprint = { ];
enable = true; };
settings = { auto-format = true;
plugins = (pkgs.dprint-plugins.getPluginList (plugins: with plugins; [ dprint-plugin-markdown ])); }
markdown = { ];
lineWidth = 80; language-server.marksman.command = "${pkgs.marksman}/bin/marksman";
textWrap = "always";
};
}; };
includes = [ "*.md" ]; treefmt.programs.dprint = {
enable = true;
settings = {
plugins = (pkgs.dprint-plugins.getPluginList (plugins: with plugins; [ dprint-plugin-markdown ]));
markdown = {
lineWidth = 80;
textWrap = "always";
};
};
includes = [ "*.md" ];
};
pre-commit.settings.hooks.markdownlint.enable = true;
}; };
pre-commit.settings.hooks.markdownlint.enable = true; }
}; );
} }

View file

@ -1,34 +1,38 @@
{ ... }: { flake-parts-lib, lib, ... }:
{ {
imports = [ ../en-us ]; imports = [ ../en-us ];
perSystem = options.perSystem = flake-parts-lib.mkPerSystemOption (
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
helix.languages = { options.languages.nix.enable = lib.mkEnableOption "Nix";
language = [ config = lib.mkIf config.languages.nix.enable {
{ editors.helix.languages = {
name = "nix"; language = [
language-servers = [ {
"nil" name = "nix";
"harper-ls" language-servers = [
"typos" "nil"
]; "harper-ls"
formatter = { "typos"
command = "${config.treefmt.build.wrapper}/bin/treefmt";
args = [
"--stdin"
".nix"
"--quiet"
]; ];
}; formatter = {
auto-format = true; command = "${config.treefmt.build.wrapper}/bin/treefmt";
} args = [
]; "--stdin"
language-server.nil.command = "${pkgs.nil}/bin/nil"; ".nix"
"--quiet"
];
};
auto-format = true;
}
];
language-server.nil.command = "${pkgs.nil}/bin/nil";
};
treefmt.programs.nixfmt = {
enable = true;
strict = true;
};
}; };
treefmt.programs.nixfmt = { }
enable = true; );
strict = true;
};
};
} }

View file

@ -1,32 +1,36 @@
{ ... }: { flake-parts-lib, lib, ... }:
{ {
imports = [ ../en-us ]; imports = [ ../en-us ];
perSystem = options.perSystem = flake-parts-lib.mkPerSystemOption (
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
helix.languages = { options.languages.toml.enable = lib.mkEnableOption "TOML";
language = [ config = {
{ editors.helix.languages = {
name = "toml"; language = [
language-servers = [ {
"taplo" name = "toml";
"harper-ls" language-servers = [
"typos" "taplo"
]; "harper-ls"
formatter = { "typos"
command = "${config.treefmt.build.wrapper}/bin/treefmt";
args = [
"--stdin"
".toml"
"--quiet"
]; ];
}; formatter = {
auto-format = true; command = "${config.treefmt.build.wrapper}/bin/treefmt";
} args = [
]; "--stdin"
language-server.taplo.command = "${pkgs.taplo}/bin/taplo"; ".toml"
"--quiet"
];
};
auto-format = true;
}
];
language-server.taplo.command = "${pkgs.taplo}/bin/taplo";
};
treefmt.programs.taplo.enable = true;
pre-commit.settings.hooks.check-toml.enable = true;
}; };
treefmt.programs.taplo.enable = true; }
pre-commit.settings.hooks.check-toml.enable = true; );
};
} }

View file

@ -1,44 +1,48 @@
{ ... }: { flake-parts-lib, lib, ... }:
{ {
imports = [ ../en-us ]; imports = [ ../en-us ];
perSystem = options.perSystem = flake-parts-lib.mkPerSystemOption (
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
helix.languages = { options.languages.yaml.enable = lib.mkEnableOption "YAML";
language = [ config = {
{ editors.helix.languages = {
name = "yaml"; language = [
language-servers = [ {
"yaml-language-server" name = "yaml";
"harper-ls" language-servers = [
"typos" "yaml-language-server"
]; "harper-ls"
formatter = { "typos"
command = "${config.treefmt.build.wrapper}/bin/treefmt";
args = [
"--stdin"
".yaml"
"--quiet"
]; ];
}; formatter = {
auto-format = true; command = "${config.treefmt.build.wrapper}/bin/treefmt";
} args = [
]; "--stdin"
language-server.yaml-language-server.command = "${pkgs.yaml-language-server}/bin/yaml-language-server"; ".yaml"
"--quiet"
];
};
auto-format = true;
}
];
language-server.yaml-language-server.command = "${pkgs.yaml-language-server}/bin/yaml-language-server";
};
treefmt.programs.dprint = {
enable = true;
settings.plugins = (
pkgs.dprint-plugins.getPluginList (plugins: with plugins; [ g-plane-pretty_yaml ])
);
includes = [
"*.yaml"
"*.yml"
];
};
pre-commit.settings.hooks = {
check-yaml.enable = true;
sort-simple-yaml.enable = true;
};
}; };
treefmt.programs.dprint = { }
enable = true; );
settings.plugins = (
pkgs.dprint-plugins.getPluginList (plugins: with plugins; [ g-plane-pretty_yaml ])
);
includes = [
"*.yaml"
"*.yml"
];
};
pre-commit.settings.hooks = {
check-yaml.enable = true;
sort-simple-yaml.enable = true;
};
};
} }

View file

@ -47,6 +47,14 @@
perSystem = perSystem =
{ pkgs, system, ... }: { pkgs, system, ... }:
{ {
editors.helix.enable = true;
languages = {
en-us.enable = true;
markdown.enable = true;
nix.enable = true;
toml.enable = true;
yaml.enable = true;
};
# https://flake.parts/options/devshell.html # https://flake.parts/options/devshell.html
devshells.default = { devshells.default = {
packages = [ pkgs.forgejo-cli ]; packages = [ pkgs.forgejo-cli ];

View file

@ -567,7 +567,7 @@ in
"en-US" "en-US"
"en" "en"
]; ];
vencord = ./vencord.nix; # TODO: Fix this vencord = ./vencord.nix; # TODO: Make this a home-manager module
}; };
}; };
floorp = { floorp = {

View file

@ -12,7 +12,6 @@
disableMinSize = false; disableMinSize = false;
eagerPatches = false; eagerPatches = false;
enableReactDevtools = false; enableReactDevtools = false;
enabledThemes = [ ];
frameless = false; frameless = false;
macosTranslucency = false; macosTranslucency = false;
notifications = { notifications = {