Tailwind-Formatter
Tailwind-Formatter copied to clipboard
Any plan on supporting Tailwind classes in Ruby files?
I've just discovered this plugin and it seems working great! I'm using it with Rubymine.
One thing that I've noticed is that it formats html files, but not Ruby ones. I'm having Ruby classes with components where sometimes I set the class to be reused in the html, something like:
LEVELS = {
danger: "border-transparent shadow-sm text-white bg-red-500 hover:bg-red-600",
primary: "shadow-sm text-white border-transparent bg-emerald-500 hover:bg-emerald-600",
secondary: "border-transparent text-emerald-700 bg-emerald-100 hover:bg-emerald-200",
tertiary: "border-gray-300 shadow-sm text-gray-700 bg-white hover:bg-gray-50"
}.freeze
def button_classes
"inline-flex justify-center items-center py-2 px-4 select-none " \
"text-sm font-normal rounded-md border cursor-pointer text-center " \
"focus:ring-2 focus:ring-emerald-500 focus:ring-offset-2 focus:outline-none " \
"#{LEVELS[level]}"
end
It'd be nice if this plugin was able to reformat those as well. I don't know if that'd even be possible (especially the multi line ones, but I could format them first, and then manually split the line)
Can you link me a few files to test against?
Sure, I've uploaded a couple of example files here (removing most of the ruby logic): https://pastebin.com/GDmBUBFh https://pastebin.com/bx4SPm6j
Let me know if you'd need more
So this is challenging and I'm not sure what approach to take. For the PsiElements API to work, the IDE would need to support ruby in order to crawl and identify which nodes are plain text. Which isn't much different than just processing plain text with regex & checking if most of it is tailwind. It feels really messy, so I'm still thinkin things over.
Would it make it easier to support this only on Rubymine, as it understands Ruby and hopefully identifies those nodes as plain text? :thinking:
I think so, ill download & play with rubymine and see how far I get with this when I have time.