heybourn / headwind

An opinionated Tailwind CSS class sorter built for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=heybourn.headwind
MIT License
1.38k stars 46 forks source link

Support for Svelte files #140

Open michael4reynolds opened 3 years ago

michael4reynolds commented 3 years ago

Please add support for .svelte files or enable svelte files to be handled as html files.

Thanks

schtibe commented 2 years ago

You're probably able to solve this by adding a classRegex option to the settings. I did this for .njk files and just inserted the same regex as is used for html files:

  "headwind.classRegex": {
    "njk": "\\bclass\\s*=\\s*[\\\"\\']([_a-zA-Z0-9\\s\\-\\:\\/]+)[\\\"\\']"
  }
jmroon commented 2 years ago

You're probably able to solve this by adding a classRegex option to the settings. I did this for .njk files and just inserted the same regex as is used for html files:

  "headwind.classRegex": {
    "njk": "\\bclass\\s*=\\s*[\\\"\\']([_a-zA-Z0-9\\s\\-\\:\\/]+)[\\\"\\']"
  }

Tried this, unfortunately doesn't appear to work with Svelte.

Settings.json:

"headwind.classRegex": {
  "svelte": "\\bclass\\s*=\\s*[\\\"\\']([_a-zA-Z0-9\\s\\-\\:\\/]+)[\\\"\\']"
}
schtibe commented 2 years ago

@jmroon Strange! I just tested it and it worked in my editor. I used a slightly different RegEx, not sure why, but does it work on your machine with this one:

    "svelte": "\\bclass\\s*=\\s*[\\\"\\']([_a-zA-Z0-9\\s\\-\\:\\/\\[\\]]+)[\\\"\\']"