Skip to content

Duplicated semicolon in CSS file causes Tailwind CSS language server to not work #1382

Closed
@alexander-doroshko

Description

@alexander-doroshko

I'll give very specific steps to reproduce the problem. At the same time I'd suggest treating this issue as a more general problem: the Tailwind CSS language server is too sensitive to the contents of the CSS file at the moment of the server initialization. See below for more thoughts on this. Thank you.

Steps: create a trivial project with two files, run npm install, open the project in the IDE (WebStorm or VS Code):
package.json

{
  "devDependencies": {
    "tailwindcss": "^4.1.7",
  }
}

style.css

@import 'tailwindcss';

@theme {
    --mono-foreground: green;;
}

.foo {
    @apply text-amber-600;
}

Problems:

  • Tailwind intellisense doesn't work (code completion, color preview, hover, etc.). For example, try code completion after @apply in this CSS file
    • workaround: remove duplicated semicolon, save file, restart Tailwind LSP server
  • Related usability problem: IDE doesn't give any hint about the fact and the reason of the server initialization failure
  • Fixing the problem (removing the duplicated semicolon) doesn't help
    • removing the duplicated semicolon and restarting the server doesn't help either if the CSS file has not been saved
    • so all three steps are important: fix CSS file content, save file, restart the server

This example with a duplicated semicolon is only one of the examples that make the Tailwind server unhappy. So I wonder if a general solution of such kind of problems is possible. What I would expect in an ideal scenario:

  • Tailwind CSS server should be tolerant to errors in the CSS file, most of errors shouldn't prevent from the server initialization
  • If the server failed to initialize, user should be notified about this fact and the reason
  • Once the reason is fixed (CSS file content updated), the server should start working without the need to restart it
  • Ideally, saving the CSS file with corrected content should not be needed. Thanks to the LSP protocol, the server knows the unsaved file content

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions