Separate each language into its own file
This commit is contained in:
parent
900beccb05
commit
cefdf3bc5d
7 changed files with 163 additions and 148 deletions
|
@ -8,6 +8,6 @@ This repository has the Nix home-manager configuration for my laptop, allowing m
|
|||
- **`flake-parts`** - Makes the Flake modular and reusable
|
||||
- **`sops`** - Encrypts secrets
|
||||
- **`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
|
||||
- **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
|
||||
- **Language tools** - Checks for grammatical and styling issues using Vale, Harper, LTeX, and Typos
|
||||
|
|
173
flake.nix
173
flake.nix
|
@ -68,107 +68,30 @@
|
|||
];
|
||||
};
|
||||
treefmt = config.treefmt.build.wrapper;
|
||||
langDir = ./languages;
|
||||
langFiles = builtins.attrNames (builtins.readDir langDir);
|
||||
nixFiles = builtins.filter (name: builtins.match ".*\\.nix" name != null) langFiles;
|
||||
configs = map (file: import (langDir + "/${file}") { inherit pkgs treefmt; }) nixFiles;
|
||||
helixLanguages = {
|
||||
language = [
|
||||
{
|
||||
name = "markdown";
|
||||
language-servers = [
|
||||
"marksman"
|
||||
"ltex-ls-plus"
|
||||
"vale-ls"
|
||||
];
|
||||
formatter = {
|
||||
command = "${treefmt}/bin/treefmt";
|
||||
args = [
|
||||
"--stdin"
|
||||
".md"
|
||||
"--quiet"
|
||||
];
|
||||
};
|
||||
auto-format = true;
|
||||
}
|
||||
{
|
||||
name = "nix";
|
||||
language-servers = [
|
||||
"nil"
|
||||
"harper-ls"
|
||||
];
|
||||
formatter = {
|
||||
command = "${treefmt}/bin/treefmt";
|
||||
args = [
|
||||
"--stdin"
|
||||
".nix"
|
||||
"--quiet"
|
||||
];
|
||||
};
|
||||
auto-format = true;
|
||||
}
|
||||
{
|
||||
name = "toml";
|
||||
language-servers = [
|
||||
"taplo"
|
||||
"harper-ls"
|
||||
];
|
||||
formatter = {
|
||||
command = "${treefmt}/bin/treefmt";
|
||||
args = [
|
||||
"--stdin"
|
||||
".toml"
|
||||
"--quiet"
|
||||
];
|
||||
};
|
||||
auto-format = true;
|
||||
}
|
||||
{
|
||||
name = "yaml";
|
||||
language-servers = [
|
||||
"yaml-language-server"
|
||||
"harper-ls"
|
||||
];
|
||||
formatter = {
|
||||
command = "${treefmt}/bin/treefmt";
|
||||
args = [
|
||||
"--stdin"
|
||||
".yaml"
|
||||
"--quiet"
|
||||
];
|
||||
};
|
||||
auto-format = true;
|
||||
}
|
||||
];
|
||||
language-server = {
|
||||
ltex-ls-plus = {
|
||||
command = "${pkgs.ltex-ls-plus}/bin/ltex-ls-plus";
|
||||
config = {
|
||||
ltex.dictionary = {
|
||||
en-US = [
|
||||
"Asahi"
|
||||
"LLMs"
|
||||
"LTeX"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
marksman = {
|
||||
command = "${pkgs.marksman}/bin/marksman";
|
||||
};
|
||||
harper-ls = {
|
||||
command = "${pkgs.harper}/bin/harper-ls";
|
||||
};
|
||||
nil = {
|
||||
command = "${pkgs.nil}/bin/nil";
|
||||
};
|
||||
taplo = {
|
||||
command = "${pkgs.taplo}/bin/taplo";
|
||||
};
|
||||
vale-ls = {
|
||||
command = "${pkgs.vale-ls}/bin/vale-ls";
|
||||
};
|
||||
yaml-language-server = {
|
||||
command = "${pkgs.yaml-language-server}/bin/yaml-language-server";
|
||||
};
|
||||
};
|
||||
language = map (cfg: cfg.helix.language) (
|
||||
(builtins.filter (cfg: builtins.hasAttr "language" cfg.helix) (
|
||||
builtins.filter (cfg: builtins.hasAttr "helix" cfg) configs
|
||||
))
|
||||
);
|
||||
language-server = builtins.foldl' (acc: cfg: acc // (cfg.helix.language-server or { })) { } configs;
|
||||
};
|
||||
treefmtPrograms = builtins.foldl' (acc: cfg: acc // (cfg.treefmt.programs or { })) { } configs;
|
||||
preCommitHooks = builtins.foldl' (acc: cfg: acc // (cfg.pre-commit or { })) { } configs;
|
||||
devshellCommands = builtins.concatMap (cfg: cfg.devshell.commands) (
|
||||
(builtins.filter (cfg: builtins.hasAttr "commands" cfg.devshell) (
|
||||
builtins.filter (cfg: builtins.hasAttr "devshell" cfg) configs
|
||||
))
|
||||
);
|
||||
devshellPackages = builtins.concatMap (cfg: cfg.devshell.packages) (
|
||||
(builtins.filter (cfg: builtins.hasAttr "packages" cfg.devshell) (
|
||||
builtins.filter (cfg: builtins.hasAttr "devshell" cfg) configs
|
||||
))
|
||||
);
|
||||
helixLanguagesFormat = pkgs.formats.toml { };
|
||||
helixLanguagesFile = helixLanguagesFormat.generate "languages.toml" helixLanguages;
|
||||
in
|
||||
|
@ -201,11 +124,6 @@
|
|||
name = "_helix-grammars";
|
||||
command = "${pkgs.helix}/bin/hx --grammar fetch && hx --grammar build";
|
||||
}
|
||||
{
|
||||
help = "sync vale configuration";
|
||||
name = "vale-sync";
|
||||
command = "${pkgs.vale}/bin/vale sync";
|
||||
}
|
||||
{
|
||||
help = "generate age key";
|
||||
name = "_age-generate-key";
|
||||
|
@ -216,7 +134,7 @@
|
|||
name = "sops-edit";
|
||||
command = "${pkgs.sops}/bin/sops edit ./home/secrets/secrets.yaml";
|
||||
}
|
||||
];
|
||||
] ++ devshellCommands;
|
||||
packages = [
|
||||
pkgs.age
|
||||
pkgs.forgejo-cli
|
||||
|
@ -228,8 +146,7 @@
|
|||
pkgs.man
|
||||
pkgs.sops
|
||||
pkgs.uutils-coreutils-noprefix
|
||||
pkgs.vale
|
||||
];
|
||||
] ++ devshellPackages;
|
||||
devshell = {
|
||||
motd = ''
|
||||
{202}🔨 Nix Laptop Configuration{reset}
|
||||
|
@ -247,49 +164,11 @@
|
|||
};
|
||||
};
|
||||
pre-commit.settings = {
|
||||
hooks = {
|
||||
markdownlint = {
|
||||
enable = true;
|
||||
};
|
||||
vale = {
|
||||
enable = true;
|
||||
};
|
||||
treefmt = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
hooks = preCommitHooks;
|
||||
};
|
||||
treefmt = {
|
||||
projectRootFile = "flake.nix";
|
||||
programs = {
|
||||
nixfmt = {
|
||||
enable = true;
|
||||
strict = true;
|
||||
};
|
||||
dprint = {
|
||||
enable = true;
|
||||
settings = {
|
||||
plugins = (
|
||||
pkgs.dprint-plugins.getPluginList (
|
||||
plugins: with plugins; [
|
||||
dprint-plugin-markdown
|
||||
g-plane-pretty_yaml
|
||||
]
|
||||
)
|
||||
);
|
||||
};
|
||||
};
|
||||
taplo = {
|
||||
enable = true;
|
||||
};
|
||||
typos = {
|
||||
enable = true;
|
||||
locale = "en-us";
|
||||
};
|
||||
};
|
||||
settings.global = {
|
||||
excludes = [ ".vale/*" ];
|
||||
};
|
||||
programs = treefmtPrograms;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
28
languages/en-us.nix
Normal file
28
languages/en-us.nix
Normal file
|
@ -0,0 +1,28 @@
|
|||
{ pkgs, treefmt }:
|
||||
{
|
||||
helix.language-server = {
|
||||
ltex-ls-plus = {
|
||||
command = "${pkgs.ltex-ls-plus}/bin/ltex-ls-plus";
|
||||
config.ltex.dictionary.en-US = [
|
||||
"Asahi"
|
||||
"LLMs"
|
||||
"LTeX"
|
||||
];
|
||||
};
|
||||
vale-ls.command = "${pkgs.vale-ls}/bin/vale-ls";
|
||||
};
|
||||
treefmt.programs.typos = {
|
||||
enable = true;
|
||||
locale = "en-us";
|
||||
};
|
||||
devshell = {
|
||||
commands = [
|
||||
{
|
||||
help = "sync vale configuration";
|
||||
name = "vale-sync";
|
||||
command = "${pkgs.vale}/bin/vale sync";
|
||||
}
|
||||
];
|
||||
packages = [ pkgs.vale ];
|
||||
};
|
||||
}
|
33
languages/markdown.nix
Normal file
33
languages/markdown.nix
Normal file
|
@ -0,0 +1,33 @@
|
|||
{ pkgs, treefmt }:
|
||||
{
|
||||
helix = {
|
||||
language = {
|
||||
name = "markdown";
|
||||
language-servers = [
|
||||
"marksman"
|
||||
"ltex-ls-plus"
|
||||
"vale-ls"
|
||||
];
|
||||
formatter = {
|
||||
command = "${treefmt}/bin/treefmt";
|
||||
args = [
|
||||
"--stdin"
|
||||
".md"
|
||||
"--quiet"
|
||||
];
|
||||
};
|
||||
auto-format = true;
|
||||
};
|
||||
language-server = {
|
||||
marksman.command = "${pkgs.marksman}/bin/marksman";
|
||||
};
|
||||
};
|
||||
treefmt.programs.dprint = {
|
||||
enable = true;
|
||||
settings.plugins = [ "dprint-plugin-markdown" ];
|
||||
};
|
||||
pre-commit = {
|
||||
markdownlint.enable = true;
|
||||
vale.enable = true;
|
||||
};
|
||||
}
|
26
languages/nix.nix
Normal file
26
languages/nix.nix
Normal file
|
@ -0,0 +1,26 @@
|
|||
{ pkgs, treefmt }:
|
||||
{
|
||||
helix = {
|
||||
language = {
|
||||
name = "nix";
|
||||
language-servers = [
|
||||
"nil"
|
||||
"harper-ls"
|
||||
];
|
||||
formatter = {
|
||||
command = "${treefmt}/bin/treefmt";
|
||||
args = [
|
||||
"--stdin"
|
||||
".nix"
|
||||
"--quiet"
|
||||
];
|
||||
};
|
||||
auto-format = true;
|
||||
};
|
||||
language-server.nil.command = "${pkgs.nil}/bin/nil";
|
||||
};
|
||||
treefmt.programs.nixfmt = {
|
||||
enable = true;
|
||||
strict = true;
|
||||
};
|
||||
}
|
23
languages/toml.nix
Normal file
23
languages/toml.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
{ pkgs, treefmt }:
|
||||
{
|
||||
helix = {
|
||||
language = {
|
||||
name = "toml";
|
||||
language-servers = [
|
||||
"taplo"
|
||||
"harper-ls"
|
||||
];
|
||||
formatter = {
|
||||
command = "${treefmt}/bin/treefmt";
|
||||
args = [
|
||||
"--stdin"
|
||||
".toml"
|
||||
"--quiet"
|
||||
];
|
||||
};
|
||||
auto-format = true;
|
||||
};
|
||||
language-server.taplo.command = "${pkgs.taplo}/bin/taplo";
|
||||
};
|
||||
treefmt.programs.taplo.enable = true;
|
||||
}
|
26
languages/yaml.nix
Normal file
26
languages/yaml.nix
Normal file
|
@ -0,0 +1,26 @@
|
|||
{ pkgs, treefmt }:
|
||||
{
|
||||
helix = {
|
||||
language = {
|
||||
name = "yaml";
|
||||
language-servers = [
|
||||
"yaml-language-server"
|
||||
"harper-ls"
|
||||
];
|
||||
formatter = {
|
||||
command = "${treefmt}/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 = [ "g-plane-pretty_yaml" ];
|
||||
};
|
||||
}
|
Loading…
Add table
Reference in a new issue