diff --git a/modules/programs/helix.nix b/modules/programs/helix.nix index bec6428cf..763a9b655 100644 --- a/modules/programs/helix.nix +++ b/modules/programs/helix.nix @@ -46,12 +46,31 @@ in { }; languages = mkOption { - type = types.listOf tomlFormat.type; - default = [ ]; - example = [{ - name = "rust"; - auto-format = false; - }]; + 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 + { language = ; } + instead. + '' { inherit language; }) (addCheck tomlFormat.type builtins.isAttrs); + default = { }; + example = literalExpression '' + { + # the language-server option currently requires helix from the master branch at https://github.com/helix-editor/helix/ + 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; + }]; + } + ''; description = '' Language specific configuration at $XDG_CONFIG_HOME/helix/languages.toml. @@ -140,9 +159,8 @@ in { "helix/config.toml" = mkIf (cfg.settings != { }) { source = tomlFormat.generate "helix-config" cfg.settings; }; - "helix/languages.toml" = mkIf (cfg.languages != [ ]) { - source = - tomlFormat.generate "helix-config" { language = cfg.languages; }; + "helix/languages.toml" = mkIf (cfg.languages != { }) { + source = tomlFormat.generate "helix-languages-config" cfg.languages; }; }; diff --git a/tests/modules/programs/helix/example-settings.nix b/tests/modules/programs/helix/example-settings.nix index 6a26c75eb..86c6766a8 100644 --- a/tests/modules/programs/helix/example-settings.nix +++ b/tests/modules/programs/helix/example-settings.nix @@ -21,10 +21,27 @@ with lib; }; }; - languages = [{ - name = "rust"; - auto-format = false; - }]; + languages = { + language-server.typescript-language-server = let + typescript-language-server = config.lib.test.mkStubPackage { + outPath = "@typescript-language-server@"; + }; + typescript = + config.lib.test.mkStubPackage { outPath = "@typescript@"; }; + in { + command = + "${typescript-language-server}/bin/typescript-language-server"; + args = [ + "--stdio" + "--tsserver-path=${typescript}/lib/node_modules/typescript/lib" + ]; + }; + + language = [{ + name = "rust"; + auto-format = false; + }]; + }; themes = { base16 = let diff --git a/tests/modules/programs/helix/languages-expected.toml b/tests/modules/programs/helix/languages-expected.toml index d3404397b..cb77ed2b9 100644 --- a/tests/modules/programs/helix/languages-expected.toml +++ b/tests/modules/programs/helix/languages-expected.toml @@ -1,3 +1,7 @@ [[language]] auto-format = false name = "rust" + +[language-server.typescript-language-server] +args = ["--stdio", "--tsserver-path=@typescript@/lib/node_modules/typescript/lib"] +command = "@typescript-language-server@/bin/typescript-language-server"