tailwindlabs / tailwindcss-intellisense

Intelligent Tailwind CSS tooling for Visual Studio Code
2.74k stars 182 forks source link

Use one server to handle all folders in a workspace #957

Closed thecrypticace closed 2 months ago

thecrypticace commented 2 months ago

Previously, if your workspace had multiple folders, we would boot a separate server per workspace folder. This was because our server didn't support workspace folders. However, it now does which means we can make use of this feature.

This change should help reduce CPU and memory usage in any workspace making use of multiple folders. This will also solve an issue where Intellisense would not load when a workspace that is open is a subdirectory of another workspace, the subdirectory folder was listed first, and that subdirectory didn't contain a tailwind config or tailwind-related CSS file.

Fixes #921

thecrypticace commented 2 months ago

@alexander-doroshko I'm landing a change here that will have the server ask for "user languages" from the config rather than from initialization options. We have an existing setting for this that we use populate the initialization options in our extension: tailwindCSS.includedLanguages.

Would this cause any problems with jet brains stuff? Right now it'll still fall back to initialization options so it shouldn't break if none are defined in the config but it's likely I'll remove that in the near future.

alexander-doroshko commented 2 months ago

jet brains

JetBrains :)

ask for "user languages" from the config

Do you mean the server will ask

  "method": "workspace/configuration",
  "params": {
    "items": [
      {
        "section": "tailwindCSS"
      }
    ]
  }

and the IDE is expected to answer with

  "result": [
    {
      "includeLanguages": {
        "ftl": "html",
        "jinja": "html",
        "jinja2": "html",
        "smarty": "html",
        "tmpl": "gohtml",
        "cshtml": "html",
        "vbhtml": "html",
        "razor": "html"
      },
      "files": {
        "exclude": [
          "**/.git/**",
          "**/node_modules/**",
          "**/.hg/**",
          "**/.svn/**"
        ]
      },
      "emmetCompletions": false,
      "classAttributes": [
        "class",
        "className",
        "ngClass"
      ],
      "colorDecorators": false,
      "showPixelEquivalents": true,
      "rootFontSize": 16,
      "hovers": true,
      "suggestions": true,
      "codeActions": true,
      "validate": true,
      "lint": {
        "invalidScreen": "error",
        "invalidVariant": "error",
        "invalidTailwindDirective": "error",
        "invalidApply": "error",
        "invalidConfigPath": "error",
        "cssConflict": "warning",
        "recommendedVariantOrder": "warning"
      },
      "experimental": {
        "classRegex": []
      }
    }
  ]

?

thecrypticace commented 2 months ago

JetBrains :)

Dammit — my autocorrect screwed this one up :D — I'll have to add a shortcut to fix that.

Do you mean the server will ask … and the IDE is expected to answer with

Yup, exactly.

alexander-doroshko commented 2 months ago

Cool, thanks, this is what our Tailwind CSS plugin already does.

Anyway, we'll check everything once again when we are updating the bundled Tailwind CSS LSP server. Please ping me somehow when you publish a new version to https://www.npmjs.com/package/@tailwindcss/language-server. For example, by email alexander.doroshko at jetbrains.com.

thecrypticace commented 2 months ago

Excellent — good to know! And will do!