From d32e296dc94301f3b2bf8888f8b64b5022ce6652 Mon Sep 17 00:00:00 2001 From: Winter Date: Wed, 13 Aug 2025 17:34:23 +0000 Subject: [PATCH] add prettier configuration This also removes the Zed Prettier configuration, because AFAICT, it never actually worked, and will not work with how we install Prettier now. :( Signed-off-by: Winter --- .prettierignore | 13 +++++++++++++ .prettierrc.json | 12 ++++++++++++ .zed/settings.json | 16 ---------------- flake.nix | 6 ++++++ 4 file(s) changed, 31 insertion(s)(+), 16 deletion(s)(-) diff --git a/.prettierignore b/.prettierignore new file mode 100644 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,13 @@ +flake.lock + +# for now, we don't want these formatted, but let's consider it in the future? +*.json +*.md +*.yml +*.yaml +*.jsonc +*.json + +# causes Go template plugin errors: https://github.com/NiklasPor/prettier-plugin-go-template/issues/120 +appview/pages/templates/layouts/repobase.html +appview/pages/templates/repo/tags.html diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,12 @@ +{ + "overrides": [ + { + "files": ["*.html"], + "options": { + "parser": "go-template" + } + } + ], + "bracketSameLine": true, + "htmlWhitespaceSensitivity": "ignore" +} diff --git a/.zed/settings.json b/.zed/settings.json deleted file mode 100644 --- a/.zed/settings.json +++ /dev/null @@ -1,16 +0,0 @@ -// Folder-specific settings -// -// For a full list of overridable settings, and general information on folder-specific settings, -// see the documentation: https://zed.dev/docs/configuring-zed#settings-files -{ - "languages": { - "HTML": { - "prettier": { - "format_on_save": false, - "allowed": true, - "parser": "go-template", - "plugins": ["prettier-plugin-go-template"] - } - } - } -} diff --git a/flake.nix b/flake.nix --- a/flake.nix +++ b/flake.nix @@ -106,6 +106,11 @@ pkgsCross-gnu64-pkgsStatic-appview = crossPackages.appview; pkgsCross-gnu64-pkgsStatic-knot = crossPackages.knot; pkgsCross-gnu64-pkgsStatic-knot-unwrapped = crossPackages.knot-unwrapped; pkgsCross-gnu64-pkgsStatic-spindle = crossPackages.spindle; + + prettier-wrapper = pkgs.runCommandLocal "prettier-wrapper" {nativeBuildInputs = [pkgs.makeWrapper];} '' + mkdir -p "$out/bin" + makeWrapper ${pkgs.prettier}/bin/prettier "$out/bin/prettier" --add-flags "--plugin=${pkgs.prettier-plugin-go-template}/lib/node_modules/prettier-plugin-go-template/lib/index.js" + ''; }); defaultPackage = forAllSystems (system: self.packages.${system}.appview); formatter = forAllSystems (system: nixpkgsFor.${system}.alejandra); @@ -129,6 +134,7 @@ pkgs.nixos-shell pkgs.redis pkgs.coreutils # for those of us who are on systems that use busybox (alpine) packages'.lexgen + packages'.prettier-wrapper ]; shellHook = '' mkdir -p appview/pages/static -- tangled.sh