Hopefully this issue will be rendered irrelevant by the future Treesitter migration
In trying to solve the issue of the TailwindCSS extension providing completions in incorrect contexts, I was unable to definitively solve the problem due to lack of information regarding the current context. At least in a way that didn’t require parsing the entire document myself.
Issue is that the extension should only provide completion options inside CSS class related attributes (class
, className
, etc.). However due to being unable to determine the current attribute name from the completion selectors context I was only able to partially solve the issue by scanning the current line with the cursor and seeing if the first attribute name starts with the word class
.
Unfortunately this completely fails if the cursor is not on a line with the attribute name such as:
className={`h-4 w-4 fill-current transition duration-300 ease-out ${
contactIsInView && "rotate-0 |CURSOR HERE|"
}`}
Ideally, the CompletionContext selectors
would be enriched with information from the grammar provider to allow more nuance for extensions.