Skip to content

Incorrect syntax highlighting of @plugin directive with options #1340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
EKliptus opened this issue Apr 30, 2025 · 8 comments · May be fixed by #1367
Open

Incorrect syntax highlighting of @plugin directive with options #1340

EKliptus opened this issue Apr 30, 2025 · 8 comments · May be fixed by #1367
Assignees
Labels
bug Something isn't working

Comments

@EKliptus
Copy link

What version of VS Code are you using?

v1.98.2

What version of Tailwind CSS IntelliSense are you using?

v0.14.16

What version of Tailwind CSS are you using?

v4.1.2

What package manager are you using?

deno

What operating system are you using?

Windows

Tailwind config
No config file, just css as config

@import "tailwindcss";
@plugin "@tailwindcss/typography";
@plugin "daisyui" {
  prefix: "d-";
  themes: false;
};

VS Code settings

// ...
  "files.associations": {
    "*.css": "tailwindcss"
  },
  "editor.quickSuggestions": {
    "strings": "on"
  },
  "tailwindCSS.classFunctions": ["tw", "clsx"],
// ...

I have my css file :

@import "tailwindcss";
@plugin "@tailwindcss/typography";
@plugin "daisyui" {
  prefix: "d-";
  themes: false;
}; /* <<<< this semi colon !!! ??? */ 

#container {
  font-family:
    Inter,
    Roboto,
    "Helvetica Neue",
    "Arial Nova",
    "Nimbus Sans",
    Arial,
    sans-serif;
  height: 100%;
}

....

Why this semicolon is required after a bracket bloc ?
All formatters delete it !? dprint, biome, prettier, ...
Because when this semicolon is not present after a @plugin "plugin-name" { <with bloc> } all code highlighting after the block is incoherent.
malva team used by dprint for css formatting say this semicolon isn't required ? Source : g-plane/malva#28 (comment)

What about ? For now I try many formatter with tailwindcss v4+ and all isn't support v4 !?? Which is the best formatter for tailwindcss files please ???

@LEstradioto
Copy link

I was about to open the exactly same issue, but found this!

I have the same dillema:
Adding a semicolon fixes syntax highlighting but triggers a compiler error Error: Unexpected semicolon
while removing it fixes the error but breaks highlighting.

some related discussions: tailwindlabs/tailwindcss#16964 and reddit discussion

@LEstradioto
Copy link

LEstradioto commented Apr 30, 2025

found an ugly workaround to maintain highlighting+compiling:

@import 'tailwindcss';

@plugin 'daisyui' {
  themes: all;
}

/*;*/

body {
  @apply bg-gray-100;
}

see the commented semicolon

@EKliptus
Copy link
Author

I have the same dillema: Adding a semicolon fixes syntax highlighting but triggers a compiler error Error: Unexpected semicolon while removing it fixes the error but breaks highlighting.

Yess me too, astro build fail because : [@tailwindcss/vite:generate:build] Unexpected semicolon

@EKliptus
Copy link
Author

EKliptus commented Apr 30, 2025

found an ugly workaround to maintain highlighting+compiling:

@import 'tailwindcss';

@plugin 'daisyui' {
themes: all;
}

/;/

body {
@apply bg-gray-100;
}

see the commented semicolon

Ugly but works fine for now ! Thanks

@bin16
Copy link

bin16 commented Apr 30, 2025

Same issue, see screenshots:

With semicolon:

Image

Highlight looks nice, but error:

[plugin:@tailwindcss/vite:generate:serve] Unexpected semicolon

Without semicolon:

No errors, but highlight is broken.

Image

@bin16
Copy link

bin16 commented Apr 30, 2025

found an ugly workaround to maintain highlighting+compiling:
@import 'tailwindcss';
@plugin 'daisyui' {
themes: all;
}
/;/
body {
@apply bg-gray-100;
}
see the commented semicolon

Ugly but works fine for now ! Thanks

Well, markdown, guess you mean /* ; */, it works, thanks.

Image

@thecrypticace thecrypticace self-assigned this May 1, 2025
@thecrypticace
Copy link
Contributor

The semicolon is not necessary. I'll have to adjust our syntax highlighting setup to handle this. I thought it would've already but apparently not.

We've got a number of issues related to syntax highlighting that I need to address.

@thecrypticace thecrypticace added the bug Something isn't working label May 1, 2025
@thecrypticace thecrypticace changed the title semi colon required for @plugin directive with bloc in css ?? which formatter for tailwindcss files ? Incorrect syntax highlighting of @plugin directive with options May 1, 2025
@EKliptus
Copy link
Author

In complement details about this highlighting issue :
The workaround /*;*/ work for all code outside the bloc of @plugin "xx" { /* this bloc */ }.
In all case the highlighting in the bloc of @plugindirective fail on mainy ligne.
To test with example, tou can Generate daisyUI theme with : https://daisyui.com/theme-generator/ and paste...

@thecrypticace thecrypticace linked a pull request May 14, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants