1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-31 04:04:32 +00:00

helix: add extraConfig option (#6575)

The extraConfig option can be used to append
ordered lines to helix configuration. Helix
depends on order for rendering minor mode menus.
This commit is contained in:
Aneesh Bhave 2025-03-25 23:55:51 +00:00 committed by GitHub
parent 2321c6889b
commit 0ff53f6d33
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 30 additions and 8 deletions

View file

@ -1,7 +1,5 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.helix;
tomlFormat = pkgs.formats.toml { };
@ -26,6 +24,20 @@ in {
description = "Extra packages available to hx.";
};
extraConfig = mkOption {
type = types.lines;
default = "";
description = ''
Extra lines to be appended to the config file.
Use this if you would like to maintain order for helix settings (eg. for minor modes)
'';
example = literalExpression ''
[keys.normal.g] # Reverse Alphabetical Order
G = "goto_file_end"
g = "goto_file_start"
'';
};
defaultEditor = mkOption {
type = types.bool;
default = false;
@ -200,7 +212,9 @@ in {
xdg.configFile = let
settings = {
"helix/config.toml" = mkIf (cfg.settings != { }) {
source = tomlFormat.generate "helix-config" cfg.settings;
text =
builtins.readFile (tomlFormat.generate "helix-config" cfg.settings)
+ "\n" + cfg.extraConfig;
};
"helix/languages.toml" = mkIf (cfg.languages != { }) {
source = tomlFormat.generate "helix-languages-config" cfg.languages;
@ -210,10 +224,10 @@ in {
};
};
themes = (mapAttrs' (n: v:
themes = mapAttrs' (n: v:
nameValuePair "helix/themes/${n}.toml" {
source = tomlFormat.generate "helix-theme-${n}" v;
}) cfg.themes);
}) cfg.themes;
in settings // themes;
};
}

View file

@ -1,6 +1,4 @@
{ config, ... }:
{
{ config, ... }: {
programs.helix = {
enable = true;
@ -18,6 +16,12 @@
};
};
extraConfig = ''
[keys.normal.G]
G = "goto_file_end"
g = "goto_file_start"
'';
languages = {
language-server.typescript-language-server = let
typescript-language-server = config.lib.test.mkStubPackage {

View file

@ -12,3 +12,7 @@ esc = ["collapse_selection", "keep_primary_selection"]
q = ":q"
space = "file_picker"
w = ":w"
[keys.normal.G]
G = "goto_file_end"
g = "goto_file_start"