77 lines
2.5 KiB
Nix
77 lines
2.5 KiB
Nix
{ flake-parts-lib, lib, ... }:
|
|
{
|
|
imports = [ ../base ];
|
|
options.perSystem = flake-parts-lib.mkPerSystemOption (
|
|
{ config, pkgs, ... }:
|
|
{
|
|
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 = lib.mkOption {
|
|
description = ''
|
|
Configuration for Helix `languages.toml`.
|
|
'';
|
|
# type = types.attrs;
|
|
type = lib.types.submodule {
|
|
options = {
|
|
language = lib.mkOption {
|
|
description = ''
|
|
`language` in `languages.toml`.
|
|
'';
|
|
type = lib.types.listOf lib.types.attrs;
|
|
default = [ ];
|
|
};
|
|
language-server = lib.mkOption {
|
|
description = ''
|
|
`language-server` in `languages.toml`.
|
|
'';
|
|
type = lib.types.attrs;
|
|
default = { };
|
|
};
|
|
};
|
|
};
|
|
default = { };
|
|
};
|
|
};
|
|
config.devshells.default = lib.mkIf config.editors.helix.enable (
|
|
let
|
|
tomlFormatter = pkgs.formats.toml { };
|
|
helix = {
|
|
languages = {
|
|
name = "languages.toml";
|
|
text = config.editors.helix.languages;
|
|
path = tomlFormatter.generate "languages.toml" helix.languages.text;
|
|
};
|
|
directory = {
|
|
name = ".helix";
|
|
path = pkgs.linkFarm helix.directory.name [
|
|
{
|
|
name = helix.languages.name;
|
|
path = helix.languages.path;
|
|
}
|
|
];
|
|
};
|
|
};
|
|
in
|
|
{
|
|
commands = [
|
|
{
|
|
help = " generate Helix grammars";
|
|
name = "helix-grammars";
|
|
command = "${pkgs.helix}/bin/hx --grammar fetch && hx --grammar build";
|
|
category = " Helix";
|
|
}
|
|
];
|
|
packages = [ pkgs.helix ];
|
|
devshell.startup.helix_config.text = ''
|
|
mkdir -p .helix
|
|
${pkgs.uutils-coreutils-noprefix}/bin/rm -rf ./${helix.directory.name}
|
|
${pkgs.uutils-coreutils-noprefix}/bin/ln -fsn ${helix.directory.path} ./${helix.directory.name}
|
|
'';
|
|
}
|
|
);
|
|
}
|
|
);
|
|
}
|