Matcher for functions #13925
Closed
scriptcoded
started this conversation in
Ideas
Replies: 1 comment
-
I just started digging through the code and it seems that this exact functionality is already documented. However, I couldn't find any documentation on it. Maybe I didn't look hard enough. Either way, nice to see that this is already implemented! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey there!
I have some extra regex in my VS Code config (
tailwindCSS.experimental.classRegex
) to match classes passed to utility function, for exampletwMerge\(([^)]*)\)
is a pretty simple (albeit naive) pattern to match the following use case:However, when doing more complex things using tools such as Class Variance Authority it becomes a bit more complex since this is seen as one big string and we get errors for colliding classes:
Writing a regex to match all strings within the
cva(...)
function is incredibly difficult, if not even impossible.My suggestion is to add some way to match these more complex use cases. Here are some ideas on how to solve this:
Idea 1
Allow for "nested" regex patterns. For example the following config would first match the content of the cva-function and then every string inside it:
First regex:
Second regex:
Idea 2
Not as refined, but since I believe using utility functions is quite a common use case, add an option to match functions specifically. Maybe not as flexible, but perhaps easier to use for the end user:
I'd be very happy to contribute with either solution!
Beta Was this translation helpful? Give feedback.
All reactions