Skip to content

Enhancement Proposal: Generalize into a Multi-Language Sort Plugin #1

Open
@maekoya

Description

@maekoya

I'm really impressed with this extension! The way it leverages Tailwind's built-in sorting logic is a fantastic advantage over other sorting tools.(Also checked discussions about Tailwind CSS's getClassOrder.)

I once tried to build a similar Prettier plugin, but the complexity of handling ASTs and the need for language-specific parsers made it too challenging to pursue.

Summary

I was wondering if we could explore the possibility of making this a more universal sort plugin, not limited to Clojure. I think by adding these two configurable settings to the VS Code options, it could become a valuable tool for many languages:

  • Regex Rules: Allow users to define regular expressions to match class attributes in various language formats.
  • Support Languages: Enable users to specify the languages for which the sorting functionality should be active.

Example settings.json configuration:

"tailwindCssClojureClassSorter.tailwindClassRegexs": [
  ["<.+?class=(?:\"|')([^\"']+)(?:\"|').*?>", "(\\S+)", " "] // Append regex
],
"tailwindCssClojureClassSorter.supportLanguages": [
  "clojure",
  "mtml", // Append lang
  "htl" // Append lang
]

or

"tailwindCssClojureClassSorter.tailwindClassRegexs": [
  // Append lang & regexs
  "mtml": [
    ["<.+?class=(?:\"|')([^\"']+)(?:\"|').*?>", "(\\S+)", " "]
  ] 
]

Thanks for considering this suggestion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions