-
Notifications
You must be signed in to change notification settings - Fork 178
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
Gracefully Handle Unknown At-Rules #51
Comments
http://www.w3.org/TR/css-syntax-3/#at-rule has the syntax of atrules |
@aeschli How can this co-exist with validation against wrong at-rules, such as |
It seems the original issue is for being able to use https://github.com/css-modules/postcss-icss-values
The original issue is about syntax highlighting. @amiller-gh We don't use parser but a TextMate grammar to support syntax highlighting, see: https://code.visualstudio.com/docs/extensions/themes-snippets-colorizers TextMate grammars are static and cannot highlight incorrect at values, since each at value has its own syntax. IMO the current support is good enough: |
Current implementation works well enough for single line at-rules (although the prelude highlighting could be a little more fallback-friendly), but it starts getting even little less ideal when you begin using block custom-at-rules: It fails to highlight the prelude, and some of the contents of the block. As far as the CSS grammar parser spec is concerned, it doesn't look like it defines specific keyword identification for at-rules parsing, the CSSOM is what determines what is and isn't a valid at-rule. So I would expect that the grammar to have a nicer fallback for unknown keywords... Either way – its not the best user experience for those of us using (or writing!) pre-processors that define custom at-rules 😢 |
@amiller-gh From https://www.w3.org/TR/css-syntax-3/#consume-an-at-rule it seems possible to update the grammar to highlight @aeschli What's your opinion? Adding a new config that toggles semantic checking for all at-rules? |
Yes, let's add a new validation setting For improving the TextMate grammar we can file an issue against https://github.com/atom/language-css |
Handle syntax highlighting of custom at-rules for microsoft/vscode-css-languageservice#51
Currently, the parser just gives up when it encounters an at-rule it does not understand. This puts the parser into "recovery mode" and can cause some very wonky syntax highlighting until it successfully recovers.
It should be possible to build a generic unknown at-rule parser that will mark the error and gracefully handle any valid at-rule syntax if all other at-rule parsers fail.
The text was updated successfully, but these errors were encountered: