From 9106dc6a52e15aaaef3addd9afb184a58a57220a Mon Sep 17 00:00:00 2001 From: Hellings Date: Fri, 23 Oct 2026 08:53:07 -0400 Subject: [PATCH] Initial commit --- index.ts | 21 +++++++++++++++++++++ package.json | 7 +++++++ 2 files changed, 28 insertions(+) create mode 100644 index.ts create mode 100644 package.json diff --git a/index.ts b/index.ts new file mode 100644 index 0000000..bafeebd --- /dev/null +++ b/index.ts @@ -0,0 +1,21 @@ +import type { Plugin, Parser } from "prettier"; +import { formatSource, type FormatLanguage } from "muddle/formatter"; + +interface Document { formatted: string } +const parser = (language: FormatLanguage): Parser => ({ + astFormat: "muddle-document", + async parse(source, options) { return { formatted: await formatSource(source, language, options) }; }, + locStart: () => 0, + locEnd: (node) => node.formatted.length, +}); + +const plugin: Plugin = { + languages: [ + { name: "SPUG", parsers: ["spug"], extensions: [".spug", ".stpug", ".stug"], vscodeLanguageIds: ["spug"] }, + { name: "STCSS", parsers: ["stcss"], extensions: [".stcss"], vscodeLanguageIds: ["stcss"] }, + ], + parsers: { spug: parser("spug"), stcss: parser("stcss") }, + printers: { "muddle-document": { print: (path) => path.node.formatted } }, +}; +export default plugin; +export const { languages, parsers, printers } = plugin; diff --git a/package.json b/package.json new file mode 100644 index 0000000..fc124ef --- /dev/null +++ b/package.json @@ -0,0 +1,7 @@ +{ + "name": "@muddle/prettier-plugin", + "version": "0.1.0", + "type": "module", + "exports": "./index.ts", + "peerDependencies": { "muddle": "*", "prettier": "^3.0.0" } +}