1. This function simplifies an unnecessary lua-match usage.
2. Fixes an accidental change, where "cls" was changed to "class" (fe4f320b66)
3. Match functions, which have have a decorator.
4. But exclude @staticmethod
5. Only highlight "cls" as @variable.builtin when the decorator is @classmethod
This might be a bit to complicated and some of this not to useful,
as this existing rule:
```scm
((identifier) @variable.builtin
(#eq? @variable.builtin "self"))
```
overwrites the queries anyway.
0.5-compat branch was not actively maintained and nvim-treesitter
also runs with stable versions. We should be able to maintain
compatibility with latest stable by fall-back implementations in case
there should be a breaking change.
Now that there are 4 cases handled, I thought it probably needs some comments to
show which case each injection is for.
There are other unsupported cases, such as `.withConfig` but I'm not sure if
they all belong here or into their own plugin or something.
The API reference is available here:
https://styled-components.com/docs/api
Also, not sure if there is a more generic way of handling all these cases at
once, a rule that would read: "any template string descendant from 'styled'".
Will attempt to open a PR and get some advice.
I've never written this sort of code before but I was able to get this to work
with the help of copy and paste and using nvim-treesitter/playground.
I had a hard time trying to understand how to indent this style of code so I let
vim do it with `=` and 2 spaces seems to match other files I looked at.
This works for a basic example, like this:
```
const Layout = styled.div`
position: absolute;
inset: 0;
display: grid;
grid-template-rows: 100px 1fr 3rem;
`
```