Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

☂️ CSS support #2350

Open
4 of 8 tasks
ematipico opened this issue Apr 5, 2022 · 8 comments
Open
4 of 8 tasks

☂️ CSS support #2350

ematipico opened this issue Apr 5, 2022 · 8 comments
Assignees
Labels
A-LSP Area: language server protocol A-Parser Area: parser Help wanted Help would be really appreciated L-CSS Language: CSS umbrella Issue to track a collection of other issues
Milestone

Comments

@ematipico
Copy link
Contributor

ematipico commented Apr 5, 2022

Description

We are going to use this issue to track the various work around CSS. We don't plan, for the time being, to support super languages, although we might think about preparing the infrastructure to be able to support them.

PREVIOUS DISCUSSIONS: #984

  • create a css.ungram file where we will slowly implement new grammars
  • create a rome_css_syntax crate, where we will have all things related to the CSS syntax, generated code too
  • expand the codegen of the grammar to include CSS too
  • evaluate how to implement the parser, lexer, etc. (it will require a separate discussion)
  • create a rome_css_formatter crate
  • make the rome_formatter generic
  • prepare the Rome architecture to include CSS (file handlers, capabilities, etc.)
  • add support for CSS inside the VSCode extension
@ematipico ematipico added umbrella Issue to track a collection of other issues L-CSS Language: CSS labels Apr 5, 2022
@nstepien
Copy link
Contributor

I was planning on enabling the Rome formatter with its next release to replace prettier in one of our repos, but I realized that CSS formatting, specifically css-in-js, isn't supported yet.

Very much looking forward to Rome having CSS formatting support!

@ematipico
Copy link
Contributor Author

CSS-in-JS is still JavaScript, right? If so, then I believe that that the JS formatter should do that

@nstepien
Copy link
Contributor

CSS-in-JS is still JavaScript, right?

It depends on the css-in-js lib, in our case we use linaria so it looks like this:

const myClass = css`
  color: red;
`;

which is plain CSS (without the topmost selector) in a template string.
I believe #2572 is related.

With some other libs like vanilla-extract it may be

const myClass = style({
  color: 'red'
});

which is indeed plain js.

@ematipico
Copy link
Contributor Author

ematipico commented Oct 26, 2022

CSS-in-JS is still JavaScript, right?

It depends on the css-in-js lib, in our case we use linaria so it looks like this:

const myClass = css`
  color: red;
`;

which is plain CSS (without the topmost selector) in a template string. I believe #2572 is related.

I did a quick search, I think prettier call these cases "embedded" languages:
https://github.com/prettier/prettier/blob/d13feed42b6478710bebbcd3225ab6f203a914c1/src/language-js/embed/css.js

And yes, they use a different parser/formatter inside these instances. Thank you for pointing it out!

@BasixKOR
Copy link

Could we leverage Lightning CSS (and by extension cssparser) to achieve this?

@ematipico
Copy link
Contributor Author

Could we leverage Lightning CSS (and by extension cssparser) to achieve this?

We explored cssparser a bit. While it's a good starting point, unfortunately it doesn't fit very well our CST. I haven't done a lot of exploration work, but it seemed that retrieving trivia is not an easy task.

@ematipico ematipico reopened this Apr 12, 2023
@ematipico ematipico added this to the v12.2.0 milestone May 9, 2023
@ematipico ematipico added Help wanted Help would be really appreciated A-Parser Area: parser A-LSP Area: language server protocol labels May 9, 2023
@denbezrukov denbezrukov self-assigned this Jun 30, 2023
@MrHBS
Copy link

MrHBS commented Jul 4, 2023

Any updates on this?

@denbezrukov
Copy link
Contributor

I've started to implement a lexer for a css parser.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-LSP Area: language server protocol A-Parser Area: parser Help wanted Help would be really appreciated L-CSS Language: CSS umbrella Issue to track a collection of other issues
Projects
Status: Done
Development

No branches or pull requests

5 participants