Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dprint wasm plugin integration? #48

Open
rope-hmg opened this issue Jan 28, 2022 · 3 comments
Open

dprint wasm plugin integration? #48

rope-hmg opened this issue Jan 28, 2022 · 3 comments

Comments

@rope-hmg
Copy link

We've recently started using dprint as our formatter, but we miss this from prettier.

For context:
https://dprint.dev/plugins/

I don't really know what's involved in making your tool compatible with dprint's plugin system, but it would be awesome.

Looks like this is the file that implements the interface:
https://github.com/dprint/dprint-plugin-typescript/blob/main/src/wasm_plugin.rs

@Airkro
Copy link

Airkro commented Feb 10, 2022

Release wasm version before doing this, publish *.wasm to npm could save people from download file from Github.

@b0o
Copy link

b0o commented Jul 1, 2023

We've switched to dprint as well, prettier's performance was killing us and dprint is much faster. The only thing we miss is the lack of tailwind sorting. This integration would be amazing!

@b0o
Copy link

b0o commented Jul 2, 2023

I was able to get rustywind working with dprint using dprint's exec plugin. Here's a minimal config:

{
  "exec": {
    "associations": "**/*.{jsx,tsx,html}",
    "rustywind": "rustywind --stdin",
    "rustywind.stdin": "true",
    "rustywind.associations": "**/*.{jsx,tsx,html}"
  },
  "includes":"**/*.{tsx,jsx,html}",
  "excludes": [
    "**/node_modules",
  ],
  "plugins": [
    "https://plugins.dprint.dev/exec-0.3.5.json@d687dda57be0fe9a0088ccdaefa5147649ff24127d8b3ea227536c68ee7abeab"
  ]
}

(Note: rather than copying "https://plugins.dprint.dev/exec-0.3.5.json@d687dda57be0fe9a0088ccdaefa5147649ff24127d8b3ea227536c68ee7abeab" into your config, run dprint config add exec to add the latest version.)

It may not be not as good as a first-class integration, but it works and it's fast!

Edit January 2024:

The configuration format for dprint's exec plugin has changed. Here's what I'm using now:

{
  "exec": {
    "associations": "**/*.{jsx,tsx,html}",
    "commands": [{
      "command": "rustywind --stdin",
      "exts": ["jsx", "tsx", "html"],
    }],
  },
  "excludes": [
    "**/node_modules",
    "**/*-lock.json",
  ],
  "plugins": [
    "https://plugins.dprint.dev/exec-0.4.4.json@c207bf9b9a4ee1f0ecb75c594f774924baf62e8e53a2ce9d873816a408cecbf7",
  ],
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants