diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index e666e8b..a161070 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -4,9 +4,7 @@ "tools": { "roslynator.dotnet.cli": { "version": "0.8.4", - "commands": [ - "roslynator" - ] + "commands": ["roslynator"] } } -} \ No newline at end of file +} diff --git a/.envrc b/.envrc index 8392d15..2d1d9c0 100644 --- a/.envrc +++ b/.envrc @@ -1 +1,3 @@ -use flake \ No newline at end of file +use flake + +npm i diff --git a/.gitignore b/.gitignore index 13b192f..2d63743 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /.vscode/obj /.direnv/ -/log/rimworld.log \ No newline at end of file +/log/rimworld.log +/node_modules/ diff --git a/.vscode/about.xml.xslt b/.vscode/about.xml.xslt index fda5365..c2cd92f 100644 --- a/.vscode/about.xml.xslt +++ b/.vscode/about.xml.xslt @@ -1,8 +1,5 @@ - - + + @@ -21,4 +18,4 @@ - \ No newline at end of file + diff --git a/.vscode/build.sh b/.vscode/build.sh index 7c13278..4a6c2e9 100755 --- a/.vscode/build.sh +++ b/.vscode/build.sh @@ -1,4 +1,5 @@ set -e +set -x script_dir=$(dirname $(readlink -f $0)) mod_dir=$(dirname $script_dir) @@ -7,11 +8,12 @@ pushd $script_dir configuration=${1:-Debug} # build dll -rm -f ../1.4/Assemblies/* -dotnet build mod.csproj -c ${configuration} +echo "Building for RimWorld 1.5" +rm -f $mod_dir/1.5/Assemblies/BetterAutocastVPE.dll +dotnet build $script_dir/mod.csproj -c ${configuration} -p:GAME_VERSION=v1.5 # generate About.xml -rm -f ../About/About.xml -xsltproc -o ../About/About.xml ./about.xml.xslt ./mod.csproj +rm -f $mod_dir/About/About.xml +xsltproc -o $mod_dir/About/About.xml $script_dir/about.xml.xslt $script_dir/mod.csproj -popd \ No newline at end of file +popd diff --git a/.vscode/fmt.sh b/.vscode/fmt.sh index c6ff51c..35763b9 100755 --- a/.vscode/fmt.sh +++ b/.vscode/fmt.sh @@ -1,9 +1,12 @@ set -e +set -x script_dir=$(dirname $(readlink -f $0)) mod_dir=$(dirname $script_dir) pushd $mod_dir -nix fmt +treefmt +dotnet tool restore +dotnet roslynator format $script_dir/mod.csproj -popd \ No newline at end of file +popd diff --git a/.vscode/launch.sh b/.vscode/launch.sh index 5e5c6d9..b046057 100755 --- a/.vscode/launch.sh +++ b/.vscode/launch.sh @@ -1,9 +1,11 @@ set -e +set -x script_dir=$(dirname $(readlink -f $0)) mod_dir=$(dirname $script_dir) -pushd $script_dir +game_dir=$(realpath ~/.local/share/Steam/steamapps/common/RimWorld/) +pushd $mod_dir -SDL_VIDEODRIVER=X11 LC_ALL=C steam-run ~/.local/share/Steam/steamapps/common/RimWorld/RimWorldLinux -logfile $mod_dir/log/rimworld.log -popupwindow $@ +SDL_VIDEODRIVER=X11 LC_ALL=C steam-run $game_dir/RimWorldLinux -logfile $mod_dir/log/rimworld.log -popupwindow $@ -popd \ No newline at end of file +popd diff --git a/.vscode/mod.csproj b/.vscode/mod.csproj index 8aca5ea..1080444 100644 --- a/.vscode/mod.csproj +++ b/.vscode/mod.csproj @@ -1,4 +1,12 @@ + + v1_5 + ../1.5/Assemblies + + + v1_5 + ../1.5/Assemblies + Library net480 @@ -6,25 +14,25 @@ Template Template - ../1.4/Assemblies latest - 0.1.0.0 + 0.0.0.0 none false false enable + True - dev.tobot.mod-template - Mod Template + dev.tobot.rimworld.template + Toby's Mod Template
  • Toby
  • - A mod template.\nReady to build on NixOS. + Template mod for nix and VS Code -
  • 1.4
  • +
  • 1.5
  • @@ -32,17 +40,21 @@ https://git.tobot.dev/toby/rimworld-mod-template - + - + + +
  • brrainz.harmony
  • +
    +
    @@ -51,22 +63,20 @@
    + + + + + + + + + + - - - - - - + + +
    diff --git a/.vscode/roslynator.sh b/.vscode/roslynator.sh index bcf9d04..933c756 100755 --- a/.vscode/roslynator.sh +++ b/.vscode/roslynator.sh @@ -1,9 +1,11 @@ set -e +set -x script_dir=$(dirname $(readlink -f $0)) mod_dir=$(dirname $script_dir) pushd $mod_dir +dotnet tool restore dotnet roslynator analyze $script_dir/mod.csproj -popd \ No newline at end of file +popd diff --git a/.vscode/settings.json b/.vscode/settings.json index 4a9a2b2..f2c6fac 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,29 +3,13 @@ "files.exclude": { ".direnv": true, ".vscode/obj": true, - "*/Assemblies/": true + "*/Assemblies/": true, + "1.4": true }, "files.readonlyInclude": { "log/rimworld.log": true, "About/About.xml": true }, - "omnisharp.organizeImportsOnFormat": true, - "dotnet.inlayHints.enableInlayHintsForParameters": true, - "dotnet.inlayHints.enableInlayHintsForLiteralParameters": true, - "dotnet.inlayHints.enableInlayHintsForIndexerParameters": true, - "dotnet.inlayHints.enableInlayHintsForObjectCreationParameters": true, - "dotnet.inlayHints.enableInlayHintsForOtherParameters": true, - "dotnet.inlayHints.suppressInlayHintsForParametersThatDifferOnlyBySuffix": true, - "dotnet.inlayHints.suppressInlayHintsForParametersThatMatchMethodIntent": true, - "dotnet.inlayHints.suppressInlayHintsForParametersThatMatchArgumentName": true, - "csharp.inlayHints.enableInlayHintsForTypes": true, - "csharp.inlayHints.enableInlayHintsForImplicitVariableTypes": true, - "csharp.inlayHints.enableInlayHintsForLambdaParameterTypes": true, - "csharp.inlayHints.enableInlayHintsForImplicitObjectCreation": true, - "csharp.suppressDotnetInstallWarning": true, - "csharp.suppressDotnetRestoreNotification": true, - "dotnet.server.useOmnisharp": true, - "omnisharp.enableLspDriver": false, "[xml]": { "editor.quickSuggestions": { "other": "on", @@ -36,8 +20,18 @@ "[jsonc]": { "editor.quickSuggestions": { "strings": true - }, - "editor.suggest.insertMode": "replace", - "editor.defaultFormatter": "esbenp.prettier-vscode" - } + } + }, + "csharp.inlayHints.enableInlayHintsForImplicitObjectCreation": true, + "csharp.inlayHints.enableInlayHintsForImplicitVariableTypes": true, + "csharp.inlayHints.enableInlayHintsForLambdaParameterTypes": true, + "csharp.inlayHints.enableInlayHintsForTypes": true, + "dotnet.inlayHints.enableInlayHintsForIndexerParameters": true, + "dotnet.inlayHints.enableInlayHintsForLiteralParameters": true, + "dotnet.inlayHints.enableInlayHintsForObjectCreationParameters": true, + "dotnet.inlayHints.enableInlayHintsForOtherParameters": true, + "dotnet.inlayHints.enableInlayHintsForParameters": true, + "dotnet.inlayHints.suppressInlayHintsForParametersThatDifferOnlyBySuffix": true, + "dotnet.inlayHints.suppressInlayHintsForParametersThatMatchArgumentName": true, + "dotnet.inlayHints.suppressInlayHintsForParametersThatMatchMethodIntent": true } diff --git a/.vscode/setup.sh b/.vscode/setup.sh index 7912a92..e73ba9c 100755 --- a/.vscode/setup.sh +++ b/.vscode/setup.sh @@ -6,16 +6,13 @@ mod_dir=$(dirname $script_dir) pushd $script_dir mod_name="${mod_dir##*/}" -target_dir=$(readlink -f ~/.local/share/Steam/steamapps/common/RimWorld/Mods/)/$mod_name - -dotnet tool restore +target_dir=${1:-$(realpath ~/.local/share/Steam/steamapps/common/RimWorld/Mods/)/$mod_name} if [ "$target_dir" = "$mod_dir" ]; then - echo "Target directory is the same as the mod directory. Cloned in RimWorld/Mods. Skipping setup" + echo "Target directory is the same as the mod directory. Cloned in RimWorld/Mods. Skipping setup" else - mkdir -p $target_dir - rsync -av --exclude '$mod_dir/*' --delete $mod_dir/1.4 $mod_dir/About $mod_dir/README $mod_dir/LICENSE $target_dir + mkdir -p $target_dir + rsync -av --exclude '$mod_dir/*' --delete $mod_dir/1.4 $mod_dir/1.5 $mod_dir/About $mod_dir/README $mod_dir/LICENSE $mod_dir/Changelog.md $target_dir fi popd - \ No newline at end of file diff --git a/1.4/Assemblies/Template.dll b/1.4/Assemblies/Template.dll deleted file mode 100644 index 318d518..0000000 Binary files a/1.4/Assemblies/Template.dll and /dev/null differ diff --git a/1.4/Defs/LetterDef.xml b/1.4/Defs/LetterDef.xml deleted file mode 100644 index 9e746ff..0000000 --- a/1.4/Defs/LetterDef.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - success_letter - (65, 200, 65) - (85, 255, 85) - 6 - false - LetterArrive_Good - If you can see this letter, then mod template is set up correctly. - - \ No newline at end of file diff --git a/1.4/Languages/English/Data.xml b/1.4/Languages/English/Data.xml deleted file mode 100644 index dc58f25..0000000 --- a/1.4/Languages/English/Data.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - Template Mod - \ No newline at end of file diff --git a/1.5/Assemblies/Template.dll b/1.5/Assemblies/Template.dll new file mode 100644 index 0000000..965c696 Binary files /dev/null and b/1.5/Assemblies/Template.dll differ diff --git a/1.5/Defs/LetterDef.xml b/1.5/Defs/LetterDef.xml new file mode 100644 index 0000000..6e3e56c --- /dev/null +++ b/1.5/Defs/LetterDef.xml @@ -0,0 +1,12 @@ + + + + success_letter + (65, 200, 65) + (85, 255, 85) + 6 + false + LetterArrive_Good + If you can see this letter, then mod template is set up correctly. + + diff --git a/1.5/Languages/English/Data.xml b/1.5/Languages/English/Data.xml new file mode 100644 index 0000000..3c71d0c --- /dev/null +++ b/1.5/Languages/English/Data.xml @@ -0,0 +1,4 @@ + + + Template Mod + diff --git a/1.4/Patches/Patches.xml b/1.5/Patches/Patches.xml similarity index 80% rename from 1.4/Patches/Patches.xml rename to 1.5/Patches/Patches.xml index b7a1ae5..bc3792a 100644 --- a/1.4/Patches/Patches.xml +++ b/1.5/Patches/Patches.xml @@ -1,2 +1,2 @@ - \ No newline at end of file + diff --git a/About/About.xml b/About/About.xml old mode 100644 new mode 100755 index 85d892c..d060cf4 --- a/About/About.xml +++ b/About/About.xml @@ -1,33 +1,39 @@ - dev.tobot.mod-template - Mod Template + dev.tobot.rimworld.template + Toby's Mod Template
  • Toby
  • - A mod template.\nReady to build on NixOS. + Template mod for nix and VS Code -
  • 1.4
  • +
  • 1.5
  • - 0.1.0.0 + 0.0.0.0 https://git.tobot.dev/toby/rimworld-mod-template - + - + + +
  • brrainz.harmony
  • +
    +
    - + + +
    diff --git a/Source/Extensions/TranslateExtension.cs b/Source/Extensions/TranslateExtension.cs new file mode 100644 index 0000000..09d6680 --- /dev/null +++ b/Source/Extensions/TranslateExtension.cs @@ -0,0 +1,21 @@ +global using static Template.Extensions.TranslateExtension; + +namespace Template.Extensions; + +static class TranslateExtension +{ + public static Verse.TaggedString TranslateSafe( + this string self, + params Verse.NamedArgument[] args + ) + { + if (!Verse.Translator.CanTranslate(self)) + { + TemplateMod.DebugError( + $"Untranslated key: {self}", + Verse.GenString.GetHashCodeSafe(self) + ); + } + return Verse.TranslatorFormattedStringExtensions.Translate(self, args); + } +} diff --git a/Source/Mod.cs b/Source/Mod.cs index fcf9208..5fc13b5 100644 --- a/Source/Mod.cs +++ b/Source/Mod.cs @@ -7,28 +7,33 @@ namespace Template; using Settings; using UnityEngine; +#if DEBUG +#warning Compiling in Debug mode +#endif + public class TemplateMod : Mod { - internal static string Translate(string key) - { - const string TranslationKey = nameof(TemplateMod); - return (TranslationKey + "." + key).Translate(); - } - public TemplateMod(ModContentPack content) : base(content) { +#if v1_5 + const string GAME_VERSION = "v1.5"; +#else +#error No version defined + const string GAME_VERSION = "UNDEFINED"; +#endif + #if DEBUG const string build = "Debug"; #else const string build = "Release"; #endif - Log.Message( - $"Running Version {Assembly.GetAssembly(typeof(TemplateMod)).GetName().Version} " + Log( + $"Running Version {Assembly.GetAssembly(typeof(TemplateMod)).GetName().Version} {build} compiled for RimWorld version {GAME_VERSION}" + build ); - Log.Message(content.ModMetaData.packageIdLowerCase); + Log(content.ModMetaData.packageIdLowerCase); Settings = GetSettings(); WriteSettings(); @@ -42,54 +47,52 @@ public class TemplateMod : Mod #nullable enable - public void ResetSettings() - { - Settings = new(); - } - public override void DoSettingsWindowContents(Rect inRect) => SettingsWindow.DoSettingsWindowContents(inRect); public override string SettingsCategory() => SettingsWindow.SettingsCategory(); - public static class Log + const string LogPrefix = "Toby's Template Mod - "; + + public static void DebugError(string message, int? key = null) { - const string LogPrefix = "Toby's Template Mod - "; - - public static void DebugError(string message) - { #if DEBUG - Error(message); + Error(message, key); #endif - } + } - public static void Error(string message) - { + public static void Error(string message, int? key = null) + { + if (key is int keyNotNull) + Verse.Log.ErrorOnce(LogPrefix + message, keyNotNull); + else Verse.Log.Error(LogPrefix + message); - } + } - public static void DebugWarn(string message) - { + public static void DebugWarn(string message, int? key = null) + { #if DEBUG - Warn(message); + Warn(message, key); #endif - } + } - public static void Warn(string message) - { + public static void Warn(string message, int? key = null) + { + if (key is int keyNotNull) + Verse.Log.WarningOnce(LogPrefix + message, keyNotNull); + else Verse.Log.Warning(LogPrefix + message); - } + } - public static void DebugLog(string message) - { + public static void DebugLog(string message) + { #if DEBUG - Message(message); + Log(message); #endif - } + } - public static void Message(string message) - { - Verse.Log.Message(LogPrefix + message); - } + public static void Log(string message) + { + Verse.Log.Message(LogPrefix + message); } } diff --git a/Source/Settings/SettingsWindow.cs b/Source/Settings/SettingsWindow.cs index 23a0a35..5e441d5 100644 --- a/Source/Settings/SettingsWindow.cs +++ b/Source/Settings/SettingsWindow.cs @@ -25,6 +25,6 @@ public static class SettingsWindow public static string SettingsCategory() { - return TemplateMod.Translate("SettingsCategory"); + return "TemplateMod.SettingsCategory".TranslateSafe(); } } diff --git a/Source/Settings/TemplateSettings.cs b/Source/Settings/TemplateSettings.cs index edcaad1..29b9e1d 100644 --- a/Source/Settings/TemplateSettings.cs +++ b/Source/Settings/TemplateSettings.cs @@ -1,15 +1,37 @@ +using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Reflection; using Verse; namespace Template.Settings; public class TemplateSettings : ModSettings { + private static TemplateSettings DefaultValues() => new(); + #region Scribe Helpers - private static void LookField(ref T value, string label, T defaultValue) - where T : struct + private void LookStruct(Expression> expression) { - Scribe_Values.Look(ref value, label, defaultValue); + if ( + expression.Body + is not MemberExpression + { + Member: MemberInfo { MemberType: MemberTypes.Field, Name: string memberName } + } + ) + { + throw new ArgumentException( + "Invalid expression passed to LookField", + nameof(expression) + ); + } + + FieldInfo fieldInfo = typeof(TemplateSettings).GetField(memberName); + T? value = fieldInfo.GetValue(this).ChangeType(); + T defaultValue = fieldInfo.GetValue(DefaultValues()).ChangeType(); + Scribe_Values.Look(ref value, memberName, defaultValue); + fieldInfo.SetValue(this, value); } private static void LookHashSet( @@ -21,24 +43,34 @@ public class TemplateSettings : ModSettings { if (Scribe.mode == LoadSaveMode.Saving && valueHashSet is null) { - TemplateMod.Log.Warn( - label + " is null before saving. Reinitializing with default values." - ); + TemplateMod.Warn(label + " is null before saving. Reinitializing with default values."); valueHashSet = defaultValues; } Scribe_Collections.Look(ref valueHashSet, label, lookMode: LookMode.Value); if (Scribe.mode == LoadSaveMode.LoadingVars && valueHashSet is null) { - TemplateMod.Log.Warn( - label + " is null after loading. Reinitializing with default values." - ); + TemplateMod.Warn(label + " is null after loading. Reinitializing with default values."); valueHashSet = defaultValues; } } #endregion + public bool TemplateEnabled; + + public TemplateSettings() + { + Reset(); + } + + public void Reset() + { + TemplateEnabled = true; + } + public override void ExposeData() { base.ExposeData(); + + LookStruct(() => TemplateEnabled); } } diff --git a/Source/TemplateDefOf.cs b/Source/TemplateDefOf.cs index 0611801..a4f2cf2 100644 --- a/Source/TemplateDefOf.cs +++ b/Source/TemplateDefOf.cs @@ -6,7 +6,7 @@ using Verse; namespace Template; [DefOf] -public static class StinkyTweaksDefOf +public static class TemplateDefOf { public static LetterDef success_letter; } diff --git a/Source/TemplateMapComponent.cs b/Source/TemplateMapComponent.cs index b8af6c6..18f9051 100644 --- a/Source/TemplateMapComponent.cs +++ b/Source/TemplateMapComponent.cs @@ -12,9 +12,8 @@ public class TemplateMapComponent(Map map) : MapComponent(map) Messages.Message("Success", null, MessageTypeDefOf.PositiveEvent); Find.LetterStack.ReceiveLetter( "Success", - StinkyTweaksDefOf.success_letter.description, - StinkyTweaksDefOf.success_letter, - null + TemplateDefOf.success_letter.description, + TemplateDefOf.success_letter ); } } diff --git a/flake.lock b/flake.lock index 523e62c..448a19e 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1712014858, - "narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=", + "lastModified": 1727826117, + "narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "9126214d0a59633752a136528f5f3b9aa8565b7d", + "rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1", "type": "github" }, "original": { @@ -20,52 +20,30 @@ }, "nixpkgs": { "locked": { - "lastModified": 1712963716, - "narHash": "sha256-WKm9CvgCldeIVvRz87iOMi8CFVB1apJlkUT4GGvA0iM=", - "owner": "nixos", + "lastModified": 1728538411, + "narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "cfd6b5fc90b15709b780a5a1619695a88505a176", + "rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221", "type": "github" }, "original": { - "owner": "nixos", - "ref": "nixos-unstable", + "owner": "NixOS", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } }, "nixpkgs-lib": { "locked": { - "dir": "lib", - "lastModified": 1711703276, - "narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "d8fe5e6c92d0d190646fb9f1056741a229980089", - "type": "github" + "lastModified": 1727825735, + "narHash": "sha256-0xHYkMkeLVQAMa7gvkddbPqpxph+hDzdu1XdGPJR+Os=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz" }, "original": { - "dir": "lib", - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1708475490, - "narHash": "sha256-g1v0TsWBQPX97ziznfJdWhgMyMGtoBFs102xSYO4syU=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "0e74ca98a74bc7270d28838369593635a5db3260", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz" } }, "root": { @@ -93,14 +71,16 @@ }, "treefmt-nix": { "inputs": { - "nixpkgs": "nixpkgs_2" + "nixpkgs": [ + "nixpkgs" + ] }, "locked": { - "lastModified": 1711963903, - "narHash": "sha256-N3QDhoaX+paWXHbEXZapqd1r95mdshxToGowtjtYkGI=", + "lastModified": 1729077719, + "narHash": "sha256-zayHqZO9gA1U85c4CPvVSnLV8/cBgc2yVrSKWaKeBUs=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "49dc4a92b02b8e68798abd99184f228243b6e3ac", + "rev": "5307ba60125bb024d7e52d71d582eafd511f3fee", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 353fe0b..063d896 100644 --- a/flake.nix +++ b/flake.nix @@ -1,10 +1,13 @@ { inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; systems.url = "github:nix-systems/default"; # Dev tools - treefmt-nix.url = "github:numtide/treefmt-nix"; + treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = @@ -22,16 +25,17 @@ ... }: { - # Rust dev environment devShells.default = pkgs.mkShell { inputsFrom = [ config.treefmt.build.devShell ]; nativeBuildInputs = with pkgs; [ - dotnet-sdk_8 - libxslt + dotnetCorePackages.dotnet_8.sdk + nixfmt-rfc-style + omnisharp-roslyn + libxslt.bin + nodePackages.npm ]; - shellHook = '' - DOTNET_ROOT="${pkgs.dotnet-sdk_8}"; - ''; + + DOTNET_ROOT = "${pkgs.dotnet-sdk_8}"; }; # Add your auto-formatters here. @@ -39,10 +43,48 @@ treefmt.config = { projectRootFile = "flake.nix"; programs = { - nixpkgs-fmt.enable = true; - csharpier.enable = true; - nixfmt-rfc-style.enable = true; + csharpier = { + enable = true; + dotnet-sdk = pkgs.dotnet-sdk_6; + package = pkgs.csharpier; + }; + nixfmt.enable = true; + shfmt.enable = true; + prettier = { + enable = true; + includes = [ + "**/*.xml" + "**/*.xslt" + "**/*.json" + "**/*.csproj" + ".github/workflows/*" + ]; + settings = { + plugins = [ "@prettier/plugin-xml" ]; + bracketSameLine = true; + printWidth = 1000; + overrides = [ + { + files = "*.xml"; + options = { + xmlQuoteAttributes = "double"; + xmlSortAttributesByKey = true; + xmlWhitespaceSensitivity = "preserve"; + }; + } + ]; + }; + }; }; + settings.global.excludes = [ + ".direnv" + "node_modules" + "1.4/**/*" + "*.ase" + "*.dll" + "*.png" + "About/About.xml" + ]; }; }; }; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..cad46de --- /dev/null +++ b/package-lock.json @@ -0,0 +1,64 @@ +{ + "name": "no-nutrient-ingredients", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "@prettier/plugin-xml": "^3.4.1" + } + }, + "node_modules/@prettier/plugin-xml": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/@prettier/plugin-xml/-/plugin-xml-3.4.1.tgz", + "integrity": "sha512-Uf/6/+9ez6z/IvZErgobZ2G9n1ybxF5BhCd7eMcKqfoWuOzzNUxBipNo3QAP8kRC1VD18TIo84no7LhqtyDcTg==", + "license": "MIT", + "dependencies": { + "@xml-tools/parser": "^1.0.11" + }, + "peerDependencies": { + "prettier": "^3.0.0" + } + }, + "node_modules/@xml-tools/parser": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@xml-tools/parser/-/parser-1.0.11.tgz", + "integrity": "sha512-aKqQ077XnR+oQtHJlrAflaZaL7qZsulWc/i/ZEooar5JiWj1eLt0+Wg28cpa+XLney107wXqneC+oG1IZvxkTA==", + "license": "Apache-2.0", + "dependencies": { + "chevrotain": "7.1.1" + } + }, + "node_modules/chevrotain": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/chevrotain/-/chevrotain-7.1.1.tgz", + "integrity": "sha512-wy3mC1x4ye+O+QkEinVJkPf5u2vsrDIYW9G7ZuwFl6v/Yu0LwUuT2POsb+NUWApebyxfkQq6+yDfRExbnI5rcw==", + "license": "Apache-2.0", + "dependencies": { + "regexp-to-ast": "0.5.0" + } + }, + "node_modules/prettier": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", + "license": "MIT", + "peer": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/regexp-to-ast": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/regexp-to-ast/-/regexp-to-ast-0.5.0.tgz", + "integrity": "sha512-tlbJqcMHnPKI9zSrystikWKwHkBqu2a/Sgw01h3zFjvYrMxEDYHzzoMZnUrbIfpTFEsoRnnviOXNCzFiSc54Qw==", + "license": "MIT" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..a47d596 --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@prettier/plugin-xml": "^3.4.1" + } +}