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

Incompatible with prettier-plugin-twig-melody #16

Closed
perruche opened this issue Jan 25, 2022 · 11 comments
Closed

Incompatible with prettier-plugin-twig-melody #16

perruche opened this issue Jan 25, 2022 · 11 comments

Comments

@perruche
Copy link

Hello,

Regarding this part of the README.

This means this plugin is incompatible with other Prettier plugins that are using the same APIs.
...
If you discover any other incompatibilities, open an issue and hopefully we can figure out a way to make it work.

This plugin does not work with *.twig files, with prettier-plugin-twig-melody

prettier version: 2.5.1
prettier-plugin-twig-melody version: 0.4.6
tailwindcss version: 2.2.19

My .prettierrc.js

module.exports = {
  bracketSpacing: true,
  printWidth: 100,
  semi: true,
  singleQuote: true,
  tabWidth: 2,
  trailingComma: 'es5',
  useTabs: false,
  vueIndentScriptAndStyle: true,
  htmlWhitespaceSensitivity: 'ignore',
  twigPrintWidth: 100,
  twigMultiTags: ['html_element,end_html_element', 'with,endwith'],
  tailwindConfig: './tailwind.config.js'
};

Only the settings from the twig plugin are applied when running prettier, class names stay in the same order.

@davidhellmann
Copy link

Tried the same today. Hope there is a solution for this 😅

@perruche
Copy link
Author

The source from the plugin does not have a parser for Twig:
https://github.com/tailwindlabs/prettier-plugin-tailwindcss/blob/main/src/index.js#L349

If a different approach can be taken to use this tailwind prettier plugin with twig files, i'm all ears

Anyway this plugin is 🔥

@florianbouvot
Copy link

florianbouvot commented Jan 25, 2022

Same request for me, how to make this plugin work with twig files? 🤔 #PrettierBeginner

@perruche I think this plugin only work with tailwindcss v3

@perruche
Copy link
Author

perruche commented Jan 25, 2022

@perruche I think this plugin only work with tailwindcss v3

The above configuration is working for *.html files 😄
The limitation here seems to be the parser for the langage, not the tailwind version

@florianbouvot
Copy link

florianbouvot commented Jan 27, 2022

@perruche you're right, this plugin works for me in *.html and *.html.twig file but I need to find a way to keep empty lines in html 😁

@davidhellmann
Copy link

@florianbouvot
Hm, .html it works fine but on .html.twig not.
I'm using PHPStorm. Did you something special? :D

@reinink
Copy link
Member

reinink commented Jan 28, 2022

Hey! Thanks for reporting this. I've created a new issue (#31) dedicated to keeping track of Prettier plugins that are not compatible with this plugin. Closing this issue in favor of that 👍

Please feel free to post this incompatibility with prettier-plugin-twig-melody in that issue, it would be great to have it there for quick reference.

@reinink reinink closed this as completed Jan 28, 2022
@kerns
Copy link

kerns commented Mar 16, 2022

I posted the same question in the discord but worried it's too specific to get an answer there.

Just wondering if there is a way in VSC to enjoy class sorting via prettier-plugin-tailwindcss inside of .twig files, ...but without losing basic twig syntax highlighting...which would be lost if I simply asked VSC to treat .twig as .html.

@jan-dh
Copy link

jan-dh commented Apr 25, 2022

@kerns did you ever found a solution to this?

@sweetroll
Copy link

Is it possible to set this plugin as the parser of twig files without having to use the HTML parser too?

@florianbouvot
Copy link

@kerns did you find a solution?

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

7 participants