windicss-intellisense icon indicating copy to clipboard operation
windicss-intellisense copied to clipboard

Extension doesn't work with modules like "classnames"

Open shadoworion opened this issue 3 years ago • 13 comments

Extension autocomplete doesn't work in code like this:

import cx from "classnames"

...

<div className={cx("flex flex-row justify-center items-center", { "mr-2": align === "right", "ml-2": align === "left" })}></div>

shadoworion avatar Jun 26 '21 21:06 shadoworion

It should. Also you can setup .includeLanguages to support your custom pattern

alexanderniebuhr avatar Jun 27 '21 19:06 alexanderniebuhr

It should. Also you can setup .includeLanguages to support your custom pattern

Can you provide the custom pattern?

epavanello avatar Oct 31 '21 22:10 epavanello

That solved the problem for me:

"windicss.includeLanguages": {
    "svelte": {  // .svelte or your extension file
      "type": "html",
      "patterns": [
        "classnames\\(([^)]*)\\)",
        "[\"'`]([^\"'`]*).*?[\"'`]"
      ],
    },
  }

epavanello avatar Nov 03 '21 21:11 epavanello

@epavanello Why doesn't it work in my .tsx file, can you help me see it

"windicss.includeLanguages": {
    "tsx": {  // .tsx or your extension file
      "type": "html",
      "patterns": [
        "classnames\\(([^)]*)\\)",
        "[\"'`]([^\"'`]*).*?[\"'`]"
      ],
    },
  }

sin7777 avatar Nov 05 '21 08:11 sin7777

@epavanello Why doesn't it work in my .tsx file, can you help me see it

"windicss.includeLanguages": {
    "tsx": {  // .tsx or your extension file
      "type": "html",
      "patterns": [
        "classnames\\(([^)]*)\\)",
        "[\"'`]([^\"'`]*).*?[\"'`]"
      ],
    },
  }

Verify to restart your vscode after each config change. Anyway, that pattern works for me but isn’t perfect, because the extension suggests windi classes also out of classnames utility function 🤦🏻‍♂️ New suggestions are appreciated

epavanello avatar Nov 05 '21 09:11 epavanello

@epavanello Do you have Hover Preview when hovering over it?

sin7777 avatar Nov 07 '21 06:11 sin7777

I wonder why it's not working by default.. Have to check that again

alexanderniebuhr avatar Nov 07 '21 18:11 alexanderniebuhr

@epavanello Do you have Hover Preview when hovering over it?

Yes

epavanello avatar Nov 07 '21 22:11 epavanello

I ran into the same problem. Here is my vscode configuration, everything else is the default configuration of windicss-intellisense

"windicss.enableCodeFolding": true,
    "windicss.includeLanguages": {
        "tsx": { // .tsx
            "type": "html",
            "patterns": [
                "classnames\\(([^)]*)\\)",
                "[\"'`]([^\"'`]*).*?[\"'`]"
            ],
        },
    }

bluescurry avatar Nov 25 '21 09:11 bluescurry

This should work

"windicss.includeLanguages": {
    "typescriptreact": {
      "type": "js",
      "patterns": ["(\\s+class(Name)?\\s*=\\s*{?\\s*(cx\\((.*[{,]\\s?)?)?[\"'\\`])[^\"'\\`]*$"]
    }
  },

galkatz373 avatar Dec 10 '21 08:12 galkatz373

I tried your configuration, unfortunately it didn't work.Is it ok for you to apply to your TSX files?

bluescurry avatar Dec 13 '21 03:12 bluescurry

Nothings works

epavanello avatar Dec 15 '21 17:12 epavanello

There are many reasons why this issue did not get any more bandwidth or attention, one being not clear enough what is broken by providing a test repo, another that we don't use tsx files at all.

I think there is a fix to this, and it would be great if it will get fixed at some point. But upfront there is very little chance that we have time right now for this. We do accept PRs with a solution as well with a way to support tsx natively without the includeLanguages setting.

alexanderniebuhr avatar Dec 15 '21 17:12 alexanderniebuhr