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, ... }:
let
inherit (lib) mkOption types;
in
{
imports = [ ../base ];
options.perSystem = flake-parts-lib.mkPerSystemOption (
{ config, pkgs, ... }:
{
options.helix = {
options.editors.helix = {
enable = lib.mkEnableOption "Helix";
# 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
languages = mkOption {
languages = lib.mkOption {
description = ''
Configuration for Helix `languages.toml`.
'';
# type = types.attrs;
type = types.submodule {
type = lib.types.submodule {
options = {
language = mkOption {
language = lib.mkOption {
description = ''
`language` in `languages.toml`.
'';
type = types.listOf types.attrs;
type = lib.types.listOf lib.types.attrs;
default = [ ];
};
language-server = mkOption {
language-server = lib.mkOption {
description = ''
`language-server` in `languages.toml`.
'';
type = types.attrs;
type = lib.types.attrs;
default = { };
};
};
@ -37,13 +35,13 @@ in
default = { };
};
};
config.devshells.default =
config.devshells.default = lib.mkIf config.editors.helix.enable (
let
tomlFormatter = pkgs.formats.toml { };
helix = {
languages = {
name = "languages.toml";
text = config.helix.languages;
text = config.editors.helix.languages;
path = tomlFormatter.generate "languages.toml" helix.languages.text;
};
directory = {
@ -72,7 +70,8 @@ in
${pkgs.uutils-coreutils-noprefix}/bin/rm -rf ./${helix.directory.name}
${pkgs.uutils-coreutils-noprefix}/bin/ln -fsn ${helix.directory.path} ./${helix.directory.name}
'';
};
}
);
}
);
}

View file

@ -1,11 +1,8 @@
{ ... }:
let
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
{
imports = [
../base
../helix
] ++ builtins.map (name: (./. + "/${name}")) configs;
imports = builtins.map (name: (./. + "/${name}")) modules;
}

View file

@ -1,4 +1,4 @@
{ ... }:
{ flake-parts-lib, lib, ... }:
let
dictionary = [
"Asahi"
@ -14,138 +14,145 @@ let
];
in
{
perSystem =
options.perSystem = flake-parts-lib.mkPerSystemOption (
{ 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 = {
# 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;
};
options.languages.en-us = {
enable = lib.mkEnableOption "en_US";
};
pre-commit.settings = {
hooks = {
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 = {
enable = true;
settings = {
configPath = typos.file.outPath;
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/*" ];
};
vale = {
enable = true;
settings.configPath = "${vale.directory.path}/${vale.config.name}";
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}
# '';
};
};
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 ];
perSystem =
options.perSystem = flake-parts-lib.mkPerSystemOption (
{ config, pkgs, ... }:
{
helix.languages = {
language = [
{
name = "markdown";
language-servers = [
"marksman"
"ltex-ls-plus"
"vale-ls"
"typos"
];
formatter = {
command = "${config.treefmt.build.wrapper}/bin/treefmt";
args = [
"--stdin"
".md"
"--quiet"
options.languages.markdown.enable = lib.mkEnableOption "Markdown";
config = {
editors.helix.languages = {
language = [
{
name = "markdown";
language-servers = [
"marksman"
"ltex-ls-plus"
"vale-ls"
"typos"
];
};
auto-format = true;
}
];
language-server.marksman.command = "${pkgs.marksman}/bin/marksman";
};
treefmt.programs.dprint = {
enable = true;
settings = {
plugins = (pkgs.dprint-plugins.getPluginList (plugins: with plugins; [ dprint-plugin-markdown ]));
markdown = {
lineWidth = 80;
textWrap = "always";
};
formatter = {
command = "${config.treefmt.build.wrapper}/bin/treefmt";
args = [
"--stdin"
".md"
"--quiet"
];
};
auto-format = true;
}
];
language-server.marksman.command = "${pkgs.marksman}/bin/marksman";
};
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 ];
perSystem =
options.perSystem = flake-parts-lib.mkPerSystemOption (
{ config, pkgs, ... }:
{
helix.languages = {
language = [
{
name = "nix";
language-servers = [
"nil"
"harper-ls"
"typos"
];
formatter = {
command = "${config.treefmt.build.wrapper}/bin/treefmt";
args = [
"--stdin"
".nix"
"--quiet"
options.languages.nix.enable = lib.mkEnableOption "Nix";
config = lib.mkIf config.languages.nix.enable {
editors.helix.languages = {
language = [
{
name = "nix";
language-servers = [
"nil"
"harper-ls"
"typos"
];
};
auto-format = true;
}
];
language-server.nil.command = "${pkgs.nil}/bin/nil";
formatter = {
command = "${config.treefmt.build.wrapper}/bin/treefmt";
args = [
"--stdin"
".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 ];
perSystem =
options.perSystem = flake-parts-lib.mkPerSystemOption (
{ config, pkgs, ... }:
{
helix.languages = {
language = [
{
name = "toml";
language-servers = [
"taplo"
"harper-ls"
"typos"
];
formatter = {
command = "${config.treefmt.build.wrapper}/bin/treefmt";
args = [
"--stdin"
".toml"
"--quiet"
options.languages.toml.enable = lib.mkEnableOption "TOML";
config = {
editors.helix.languages = {
language = [
{
name = "toml";
language-servers = [
"taplo"
"harper-ls"
"typos"
];
};
auto-format = true;
}
];
language-server.taplo.command = "${pkgs.taplo}/bin/taplo";
formatter = {
command = "${config.treefmt.build.wrapper}/bin/treefmt";
args = [
"--stdin"
".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 ];
perSystem =
options.perSystem = flake-parts-lib.mkPerSystemOption (
{ config, pkgs, ... }:
{
helix.languages = {
language = [
{
name = "yaml";
language-servers = [
"yaml-language-server"
"harper-ls"
"typos"
];
formatter = {
command = "${config.treefmt.build.wrapper}/bin/treefmt";
args = [
"--stdin"
".yaml"
"--quiet"
options.languages.yaml.enable = lib.mkEnableOption "YAML";
config = {
editors.helix.languages = {
language = [
{
name = "yaml";
language-servers = [
"yaml-language-server"
"harper-ls"
"typos"
];
};
auto-format = true;
}
];
language-server.yaml-language-server.command = "${pkgs.yaml-language-server}/bin/yaml-language-server";
formatter = {
command = "${config.treefmt.build.wrapper}/bin/treefmt";
args = [
"--stdin"
".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 =
{ 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
devshells.default = {
packages = [ pkgs.forgejo-cli ];

View file

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

View file

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