coc-tailwind-intellisense icon indicating copy to clipboard operation
coc-tailwind-intellisense copied to clipboard

Not working with Tailwindcss 3.0.1

Open getnashty opened this issue 2 years ago • 10 comments

I just created two new react apps, one using Gatsby, and one using Create-react-app.

In the gatsby app - Coc tailwind works great!

But with the fresh create-react-app, I can't get it to work..

I'm following these instructions: https://tailwindcss.com/docs/guides/create-react-app, but using the typescript template. I've blown away the directory and tried twice to no avail.

When I check CocList > Extensions, it says tailwind is running..

my config looks like:


module.exports = {
    purge: ["./src/**/*.{js,jsx,ts,tsx}"],
    darkMode: false, // or 'media' or 'class'
    theme: {
        extend: {},
    },
    variants: {
        extend: {},
    },
    plugins: [],
};

What else can I check?

getnashty avatar Dec 13 '21 04:12 getnashty

looks like this breaks with tailwindcss 3.0.0... when I moved the react projects version down to 2.2.19 it worked fine

getnashty avatar Dec 13 '21 05:12 getnashty

I'm switching over to built-in lsp because of this issue. It's a nightmare. Hours of configuration is wasted.

Is there any update on this issue? Thanks.

thekaganugur avatar Dec 21 '21 09:12 thekaganugur

Also waiting for fix

izaguirrejoe avatar Dec 24 '21 02:12 izaguirrejoe

Me too. The vscode plugin seems to be working fine. Maybe its just a matter of upgrading the tailwind intellisense sub module?

cwahlfeldt avatar Dec 24 '21 12:12 cwahlfeldt

Here is a workaround for using LSP directly. You will need to install lsp globally.

yarn global add @tailwindcss/language-server

  "languageserver": {
    "tailwind-lsp": {
      "command": "tailwindcss-language-server",
      "args": ["--stdio"],

      "filetypes": [
        "javascript",
        "javascriptreact",
        "typescript",
        "typescriptreact"
      ],

      "rootPatterns": [
        "tailwind.config.js",
        "tailwind.config.ts",
        "postcss.config.js",
        "postcss.config.ts",
        "package.json",
        "node_modules",
        ".git"
      ],
      "settings": {
        "tailwindCSS": {
          "validate": true,
          "lint": {
            "cssConflict": "warning",
            "invalidApply": "error",
            "invalidScreen": "error",
            "invalidVariant": "error",
            "invalidConfigPath": "error",
            "invalidTailwindDirective": "error",
            "recommendedVariantOrder": "warning"
          },
          "classAttributes": ["class", "className", "classList", "ngClass"],
          "experimental": {}
        }
      }
    }
  }

thekaganugur avatar Dec 24 '21 14:12 thekaganugur

@kgnugur

Hi, thanks for your work-around, it's indeed enabling code-completion for tailwindcss > 3.0.x.

But i'm also using tailwind in django-html templates, and I'm having some trouble figuring out how to enable it with your config?

  • If I set filetype from htmldjango -> html the LS picks up and starts code-completion / enhancements for the file, but I lose some handy features from coc-htmldjango.

I've tried the following configuration with no success:

"languageserver": {
    "tailwind-lsp": {
      "command": "tailwindcss-language-server",
      "args": ["--stdio"],
      "filetypes": [
        "html",
        "htmldjango",
        "django-html",
        "javascript",
        "javascriptreact",
        "typescript",
        "typescriptreact"
      ],

      "rootPatterns": [
        "tailwind.config.js",
        "tailwind.config.ts",
        "postcss.config.js",
        "postcss.config.ts",
        "package.json",
        "node_modules",
        ".git"
      ],
      "settings": {
        "tailwindCSS": {
          "includeLanguages": {
            "htmldjango": "html",
            "django-html": "html"
          },
          "validate": true,
          "lint": {
            "cssConflict": "warning",
            "invalidApply": "error",
            "invalidScreen": "error",
            "invalidVariant": "error",
            "invalidConfigPath": "error",
            "invalidTailwindDirective": "error",
            "recommendedVariantOrder": "warning"
          },
          "classAttributes": ["class", "className", "classList"],
          "experimental": {}
        }
      }
    }
}

terminalkitten avatar Dec 26 '21 12:12 terminalkitten

Me too. The vscode plugin seems to be working fine. Maybe its just a matter of upgrading the tailwind intellisense sub module?

Also would love an update to this. 0.7.4 is out now with TailwindCSS v3 support. I even tried to fork this and do an upgrade myself but sadly I've not enough experience in this area.

I did notice the submodule needed updating to as the URL has changed from https://github.com/tailwindcss/intellisense to https://github.com/tailwindlabs/tailwindcss-intellisense as well.

legecha avatar Dec 31 '21 00:12 legecha

I created a PR for tailwindcss v3 support on the repository side of coc-tailwindcss. If you are interested, please try it out. https://github.com/iamcco/coc-tailwindcss/pull/70

yaegassy avatar Jan 18 '22 10:01 yaegassy

Here is a workaround for using LSP directly. You will need to install lsp globally.

yarn global add @tailwindcss/language-server

  "languageserver": {
    "tailwind-lsp": {
      "command": "tailwindcss-language-server",
      "args": ["--stdio"],

      "filetypes": [
        "javascript",
        "javascriptreact",
        "typescript",
        "typescriptreact"
      ],

      "rootPatterns": [
        "tailwind.config.js",
        "tailwind.config.ts",
        "postcss.config.js",
        "postcss.config.ts",
        "package.json",
        "node_modules",
        ".git"
      ],
      "settings": {
        "tailwindCSS": {
          "validate": true,
          "lint": {
            "cssConflict": "warning",
            "invalidApply": "error",
            "invalidScreen": "error",
            "invalidVariant": "error",
            "invalidConfigPath": "error",
            "invalidTailwindDirective": "error",
            "recommendedVariantOrder": "warning"
          },
          "classAttributes": ["class", "className", "classList", "ngClass"],
          "experimental": {}
        }
      }
    }
  }

After installing the package, how do I go about using it? I am currently using nvim-cmp (for completion) and nvim-lsp-installer (to manage language servers)

AnishDe12020 avatar Feb 09 '22 10:02 AnishDe12020

Here is a workaround for using LSP directly. You will need to install lsp globally.

yarn global add @tailwindcss/language-server

  "languageserver": {
    "tailwind-lsp": {
      "command": "tailwindcss-language-server",
      "args": ["--stdio"],

      "filetypes": [
        "javascript",
        "javascriptreact",
        "typescript",
        "typescriptreact"
      ],

      "rootPatterns": [
        "tailwind.config.js",
        "tailwind.config.ts",
        "postcss.config.js",
        "postcss.config.ts",
        "package.json",
        "node_modules",
        ".git"
      ],
      "settings": {
        "tailwindCSS": {
          "validate": true,
          "lint": {
            "cssConflict": "warning",
            "invalidApply": "error",
            "invalidScreen": "error",
            "invalidVariant": "error",
            "invalidConfigPath": "error",
            "invalidTailwindDirective": "error",
            "recommendedVariantOrder": "warning"
          },
          "classAttributes": ["class", "className", "classList", "ngClass"],
          "experimental": {}
        }
      }
    }
  }

Dude, this saved me!

oieeaaaa avatar Mar 10 '22 13:03 oieeaaaa