WIP: Add custom css class from config files to completion#1425
Draft
felix-droese wants to merge 3 commits intotailwindlabs:mainfrom
Draft
WIP: Add custom css class from config files to completion#1425felix-droese wants to merge 3 commits intotailwindlabs:mainfrom
felix-droese wants to merge 3 commits intotailwindlabs:mainfrom
Conversation
- Implemented `scanCssFilesForCustomClasses` to extract custom CSS classes from specified CSS files. - Enhanced `createProjectService` to scan for custom classes in project dependencies and main CSS config. - Updated completion provider to include custom CSS classes in completion suggestions. - Added tests for custom class extraction functionality. - Introduced a new utility for identifying and extracting custom classes from CSS content.
- Enhanced the hover provider to return CSS rules for custom classes when hovered over. - Implemented functionality to scan project directories for CSS files and include them in class completion. - Added tests for hover functionality on custom classes to ensure accurate display of CSS rules. - Improved error handling during project directory scanning for CSS files.
- Removed the CSS class scanning logic from the project service to streamline functionality. - Deleted outdated hover tests for custom classes to improve test clarity and maintainability. - Enhanced error handling and logging during project directory scanning for CSS files.
Contributor
|
I had a WIP of this in https://github.com/tailwindlabs/tailwindcss-intellisense/tree/feat/custom-class-suggestions but it was too slow. I was going to make this feature v4 only and then add an API in that gave me the AST back so the extra parsing / caching / whatever wasn't necessary. (but have not yet done that) Can keep on with this PR but I may change some stuff if I get a new API in core. |
Author
|
thanks for your insight. How would you benchmark speed? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is WIP and not ready yet!
What this PR tries do do
In our tailwind v4 project, we define custom classes in our projects css config file ./resources/css/main.css.
This PR aims to provide the custom classes for the language servers completion list and also provide hover functionality.
Example
in ./resources/css/main.css:
Added completion item:

Hover functionality:
