Skip to content
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

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

Merged
merged 9 commits into from
Apr 24, 2024

Conversation

thecrypticace
Copy link
Contributor

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

It makes more sense for our server to ask for them like we do all other config options rather than expecting them to be passed in during initialization
This is a bit of a behavioral change but if _any_ folder in your current workspace might need the language server when we’ll boot it. We do still wait for an open document currently.
@thecrypticace
Copy link
Contributor Author

@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
Copy link

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
Copy link
Contributor Author

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
Copy link

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
Copy link
Contributor Author

thecrypticace commented Apr 24, 2024

Excellent — good to know! And will do!

Copy link
Member

@RobinMalfait RobinMalfait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • When running prettier --write . I do get some changes in files

Built a local vsix file and everything still seems to work!

packages/vscode-tailwindcss/src/extension.ts Outdated Show resolved Hide resolved
packages/vscode-tailwindcss/src/extension.ts Outdated Show resolved Hide resolved
packages/vscode-tailwindcss/src/extension.ts Outdated Show resolved Hide resolved
@thecrypticace thecrypticace merged commit 9d7006d into master Apr 24, 2024
@thecrypticace thecrypticace deleted the fix/one-ls-for-workspace branch April 24, 2024 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Intellisense does not activate when the directory is included in a workspace but not the first directory.
3 participants