Closed YH-Seo closed 6 months ago
Hey so the problem here is that, with the way the feature works currently, you must have exactly one capture group. This was done to ensure there's no ambiguity for what's considered to be a class list. If you need additional groups to use other regex features you can make them non-capturing ((?:…)
)
To support situations like tw(...)
, tw([...])
, tw([..., ...])
you can use the combo form of the classRegex filter which supports defining a container regex as well as a class list regex:
["tw\\(([^\\)]*)\\)", "`([^`]*)`"]
This basically says:
tw(…)
function callsAnd you can combine both types in the same list — so for your config I would write it like so:
"tailwindCSS.experimental.classRegex": [
// tw`...`
"tw`([^`]*)",
// tw(`...`)
// tw([`...`])
// tw([`...`, `...`])
["tw\\(([^\\)]*)\\)", "`([^`]*)`"],
],
Hope that helps! ✨
It works nice.... 👍 Thanks.
Hi @thecrypticace Sorry for mention
Can you help me, I not good for regex, I'm using primevue tailwind (unstyled) and need tailwindcss-intellisense on my preset folder
for example https://github.com/primefaces/primevue-tailwind/blob/main/presets/lara/autocomplete/index.js
export default {
root: ({ props }) => ({
class: [
'relative',
// Flex
'inline-flex',
// Size
{ 'w-full': props.multiple },
// Color
'text-surface-900 dark:text-surface-0',
//States
{
'opacity-60 select-none pointer-events-none cursor-default': props.disabled
}
]
}),
transition: {
enterFromClass: 'opacity-0 scale-y-[0.8]',
enterActiveClass: 'transition-[transform,opacity] duration-[120ms] ease-[cubic-bezier(0,0,0.2,1)]',
leaveActiveClass: 'transition-opacity duration-100 ease-linear',
leaveToClass: 'opacity-0'
}
};
How to configure tailwindCSS.experimental.classRegex
or other tailwind intellisense vscode config, to make this have autocomplete or hover class ?
What version of VS Code are you using?
Version: 1.85.1 (Universal)
What version of Tailwind CSS IntelliSense are you using?
v0.10.4
What version of Tailwind CSS are you using?
3.4.0
What package manager are you using?
pnpm
What operating system are you using?
macOS Ventura 13.5.2
Tailwind config
VS Code settings
Reproduction URL
Check below description. You can reproduce easily :)
Describe your issue
In Good case, works properly.![image](https://github.com/tailwindlabs/tailwindcss-intellisense/assets/106050088/ee1b9a9e-4784-418d-a247-c68f6aebdb11)
In the above BAD case, autocompletion is not working properly.![image](https://github.com/tailwindlabs/tailwindcss-intellisense/assets/106050088/5d9e3799-c20b-4bac-a725-3dc156e78884)
I tested the code below at https://regex101.com/ and it works normally.