2022-01-04 00:09:24 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.programs.helix;
|
|
|
|
tomlFormat = pkgs.formats.toml { };
|
|
|
|
in {
|
|
|
|
meta.maintainers = [ hm.maintainers.Philipp-M ];
|
|
|
|
|
|
|
|
options.programs.helix = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption "helix text editor";
|
2022-01-04 00:09:24 +01:00
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.helix;
|
|
|
|
defaultText = literalExpression "pkgs.helix";
|
2024-09-12 22:09:22 +02:00
|
|
|
example = literalExpression "pkgs.evil-helix";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "The package to use for helix.";
|
2022-01-04 00:09:24 +01:00
|
|
|
};
|
|
|
|
|
2023-10-25 18:11:33 +02:00
|
|
|
extraPackages = mkOption {
|
|
|
|
type = with types; listOf package;
|
|
|
|
default = [ ];
|
|
|
|
example = literalExpression "[ pkgs.marksman ]";
|
|
|
|
description = "Extra packages available to hx.";
|
|
|
|
};
|
|
|
|
|
2023-06-21 15:50:13 +02:00
|
|
|
defaultEditor = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2023-07-01 01:30:13 +02:00
|
|
|
Whether to configure {command}`hx` as the default
|
|
|
|
editor using the {env}`EDITOR` environment variable.
|
2023-06-21 15:50:13 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-01-04 00:09:24 +01:00
|
|
|
settings = mkOption {
|
|
|
|
type = tomlFormat.type;
|
|
|
|
default = { };
|
|
|
|
example = literalExpression ''
|
|
|
|
{
|
|
|
|
theme = "base16";
|
2023-05-04 00:42:04 +02:00
|
|
|
editor = {
|
|
|
|
line-number = "relative";
|
|
|
|
lsp.display-messages = true;
|
|
|
|
};
|
2022-01-04 00:09:24 +01:00
|
|
|
keys.normal = {
|
|
|
|
space.space = "file_picker";
|
|
|
|
space.w = ":w";
|
|
|
|
space.q = ":q";
|
2023-05-04 00:42:04 +02:00
|
|
|
esc = [ "collapse_selection" "keep_primary_selection" ];
|
2022-01-04 00:09:24 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
'';
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2022-01-04 00:09:24 +01:00
|
|
|
Configuration written to
|
2023-07-01 01:30:13 +02:00
|
|
|
{file}`$XDG_CONFIG_HOME/helix/config.toml`.
|
|
|
|
|
|
|
|
See <https://docs.helix-editor.com/configuration.html>
|
2022-01-04 00:09:24 +01:00
|
|
|
for the full list of options.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
languages = mkOption {
|
2023-05-20 17:22:06 +02:00
|
|
|
type = with types;
|
|
|
|
coercedTo (listOf tomlFormat.type) (language:
|
|
|
|
lib.warn ''
|
|
|
|
The syntax of programs.helix.languages has changed.
|
|
|
|
It now generates the whole languages.toml file instead of just the language array in that file.
|
|
|
|
|
|
|
|
Use
|
2023-05-26 15:35:29 +02:00
|
|
|
programs.helix.languages = { language = <languages list>; }
|
2023-05-20 17:22:06 +02:00
|
|
|
instead.
|
|
|
|
'' { inherit language; }) (addCheck tomlFormat.type builtins.isAttrs);
|
|
|
|
default = { };
|
|
|
|
example = literalExpression ''
|
|
|
|
{
|
|
|
|
language-server.typescript-language-server = with pkgs.nodePackages; {
|
|
|
|
command = "''${typescript-language-server}/bin/typescript-language-server";
|
|
|
|
args = [ "--stdio" "--tsserver-path=''${typescript}/lib/node_modules/typescript/lib" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
language = [{
|
|
|
|
name = "rust";
|
|
|
|
auto-format = false;
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
'';
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2022-01-04 00:09:24 +01:00
|
|
|
Language specific configuration at
|
2023-07-01 01:30:13 +02:00
|
|
|
{file}`$XDG_CONFIG_HOME/helix/languages.toml`.
|
|
|
|
|
|
|
|
See <https://docs.helix-editor.com/languages.html>
|
2022-01-04 00:09:24 +01:00
|
|
|
for more information.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-04-19 12:05:08 +02:00
|
|
|
ignores = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ ];
|
|
|
|
example = [ ".build/" "!.gitignore" ];
|
|
|
|
description = ''
|
|
|
|
List of paths that should be globally ignored for file picker.
|
|
|
|
Supports the usual ignore and negative ignore (unignore) rules used in `.gitignore` files.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-01-04 00:09:24 +01:00
|
|
|
themes = mkOption {
|
|
|
|
type = types.attrsOf tomlFormat.type;
|
|
|
|
default = { };
|
|
|
|
example = literalExpression ''
|
|
|
|
{
|
|
|
|
base16 = let
|
|
|
|
transparent = "none";
|
|
|
|
gray = "#665c54";
|
|
|
|
dark-gray = "#3c3836";
|
|
|
|
white = "#fbf1c7";
|
|
|
|
black = "#282828";
|
|
|
|
red = "#fb4934";
|
|
|
|
green = "#b8bb26";
|
|
|
|
yellow = "#fabd2f";
|
|
|
|
orange = "#fe8019";
|
|
|
|
blue = "#83a598";
|
|
|
|
magenta = "#d3869b";
|
|
|
|
cyan = "#8ec07c";
|
|
|
|
in {
|
|
|
|
"ui.menu" = transparent;
|
|
|
|
"ui.menu.selected" = { modifiers = [ "reversed" ]; };
|
|
|
|
"ui.linenr" = { fg = gray; bg = dark-gray; };
|
|
|
|
"ui.popup" = { modifiers = [ "reversed" ]; };
|
|
|
|
"ui.linenr.selected" = { fg = white; bg = black; modifiers = [ "bold" ]; };
|
|
|
|
"ui.selection" = { fg = black; bg = blue; };
|
|
|
|
"ui.selection.primary" = { modifiers = [ "reversed" ]; };
|
|
|
|
"comment" = { fg = gray; };
|
|
|
|
"ui.statusline" = { fg = white; bg = dark-gray; };
|
|
|
|
"ui.statusline.inactive" = { fg = dark-gray; bg = white; };
|
|
|
|
"ui.help" = { fg = dark-gray; bg = white; };
|
|
|
|
"ui.cursor" = { modifiers = [ "reversed" ]; };
|
|
|
|
"variable" = red;
|
|
|
|
"variable.builtin" = orange;
|
|
|
|
"constant.numeric" = orange;
|
|
|
|
"constant" = orange;
|
|
|
|
"attributes" = yellow;
|
|
|
|
"type" = yellow;
|
|
|
|
"ui.cursor.match" = { fg = yellow; modifiers = [ "underlined" ]; };
|
|
|
|
"string" = green;
|
|
|
|
"variable.other.member" = red;
|
|
|
|
"constant.character.escape" = cyan;
|
|
|
|
"function" = blue;
|
|
|
|
"constructor" = blue;
|
|
|
|
"special" = blue;
|
|
|
|
"keyword" = magenta;
|
|
|
|
"label" = magenta;
|
|
|
|
"namespace" = blue;
|
|
|
|
"diff.plus" = green;
|
|
|
|
"diff.delta" = yellow;
|
|
|
|
"diff.minus" = red;
|
|
|
|
"diagnostic" = { modifiers = [ "underlined" ]; };
|
|
|
|
"ui.gutter" = { bg = black; };
|
|
|
|
"info" = blue;
|
|
|
|
"hint" = dark-gray;
|
|
|
|
"debug" = dark-gray;
|
|
|
|
"warning" = yellow;
|
|
|
|
"error" = red;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
'';
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2022-01-04 00:09:24 +01:00
|
|
|
Each theme is written to
|
2023-07-01 01:30:13 +02:00
|
|
|
{file}`$XDG_CONFIG_HOME/helix/themes/theme-name.toml`.
|
2022-01-04 00:09:24 +01:00
|
|
|
Where the name of each attribute is the theme-name (in the example "base16").
|
2023-07-01 01:30:13 +02:00
|
|
|
|
|
|
|
See <https://docs.helix-editor.com/themes.html>
|
2022-01-04 00:09:24 +01:00
|
|
|
for the full list of options.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2023-10-25 18:11:33 +02:00
|
|
|
home.packages = if cfg.extraPackages != [ ] then
|
|
|
|
[
|
|
|
|
(pkgs.symlinkJoin {
|
|
|
|
name =
|
|
|
|
"${lib.getName cfg.package}-wrapped-${lib.getVersion cfg.package}";
|
|
|
|
paths = [ cfg.package ];
|
|
|
|
preferLocalBuild = true;
|
|
|
|
nativeBuildInputs = [ pkgs.makeWrapper ];
|
|
|
|
postBuild = ''
|
|
|
|
wrapProgram $out/bin/hx \
|
|
|
|
--prefix PATH : ${lib.makeBinPath cfg.extraPackages}
|
|
|
|
'';
|
|
|
|
})
|
|
|
|
]
|
|
|
|
else
|
|
|
|
[ cfg.package ];
|
2022-01-04 00:09:24 +01:00
|
|
|
|
2023-06-21 15:50:13 +02:00
|
|
|
home.sessionVariables = mkIf cfg.defaultEditor { EDITOR = "hx"; };
|
|
|
|
|
2022-01-04 00:09:24 +01:00
|
|
|
xdg.configFile = let
|
|
|
|
settings = {
|
|
|
|
"helix/config.toml" = mkIf (cfg.settings != { }) {
|
|
|
|
source = tomlFormat.generate "helix-config" cfg.settings;
|
|
|
|
};
|
2023-05-20 17:22:06 +02:00
|
|
|
"helix/languages.toml" = mkIf (cfg.languages != { }) {
|
|
|
|
source = tomlFormat.generate "helix-languages-config" cfg.languages;
|
2022-01-04 00:09:24 +01:00
|
|
|
};
|
2024-04-19 12:05:08 +02:00
|
|
|
"helix/ignore" = mkIf (cfg.ignores != [ ]) {
|
|
|
|
text = concatStringsSep "\n" cfg.ignores + "\n";
|
|
|
|
};
|
2022-01-04 00:09:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
themes = (mapAttrs' (n: v:
|
|
|
|
nameValuePair "helix/themes/${n}.toml" {
|
|
|
|
source = tomlFormat.generate "helix-theme-${n}" v;
|
|
|
|
}) cfg.themes);
|
|
|
|
in settings // themes;
|
|
|
|
};
|
|
|
|
}
|