vscode icon indicating copy to clipboard operation
vscode copied to clipboard

[css] Add support for CSS nesting (experimental)

Open Th3S4mur41 opened this issue 3 years ago • 29 comments
trafficstars

It is already possible today to use CSS nesting based on the working draft with PostCSS and the PostCSS Nesting plugin.

Unfortunately doing so throws a whole bunch of errors: css-rcurlyexpected, css-lcurlyexpected, css-selectorexpected, css-ruleorselectorexpected, ...

It would be great if there would be a way to enable support for this upcoming feature (experimental features flag?)

Th3S4mur41 avatar Apr 21 '22 07:04 Th3S4mur41

We normally wait until a spec is finalized...

aeschli avatar Apr 25 '22 16:04 aeschli

You can set

"css.validate": false,

in your settings.json to disable all syntax highlighting for CSS files.

BenjaminAster avatar May 18 '22 12:05 BenjaminAster

Any news? No time to wait! CSS nesting is awesome!

mahnunchik avatar Sep 13 '22 15:09 mahnunchik

Same looking forward to it. I hate to disable validation.

dapptain avatar Oct 11 '22 12:10 dapptain

Chromium has just implemented experimental CSS nesting support and the CSSWG confirmed that the syntax will not change any more. At this point of time, there is no reason any more not to implement CSS nesting support in VSCode. As already mentioned by @Th3S4mur41, nesting is also already possible with a PostCSS plugin. Now that Chromium has an implementation, Apple and Mozilla will probably follow soon, and then things can go pretty quickly. So in my opinion now the time has come to implement nesting support in VSCode.

I've opened an issue on microsoft/vscode-css-languageservice, which is a more suitable place for this discussion to continue.

BenjaminAster avatar Oct 19 '22 14:10 BenjaminAster

Is there any update? need the support. I configured css file association as scss, but code comments would turn into '//', which would cause error.

DophinL avatar Nov 24 '22 07:11 DophinL

No work is planed until we get a few green boxes here: https://caniuse.com/css-nesting

aeschli avatar Nov 24 '22 08:11 aeschli

Experimental in Chromium 109 is a good first step to gather feedback and move the spec forward 😊 Let's hope the other will follow soon

Th3S4mur41 avatar Nov 24 '22 08:11 Th3S4mur41

image

I see some green boxes 👀

jacobrask avatar Feb 01 '23 20:02 jacobrask

You can use this extension temporarily. https://marketplace.visualstudio.com/items?itemName=csstools.postcss

receptiryaki avatar Feb 15 '23 06:02 receptiryaki

CSS Nesting is shipping in 2 days to Chrome 112.

VS Code is currently not highlighting it correctly.

manake avatar Mar 26 '23 16:03 manake

Any news? No time to wait! CSS nesting is awesome!

ballonura avatar Apr 07 '23 17:04 ballonura

Very green now! image

rapPayne avatar Apr 07 '23 20:04 rapPayne

CanIUse has not been updated yet at the time I write this comment, but with recently released Edge version 112, CSS nesting is working there, too (not exactly a surprise, given the common render engine).

RWeigelt avatar Apr 12 '23 09:04 RWeigelt

Very green now! image

sure , but some people work on desktop app (nwjs,electron) with chromium ! so it supported since the start !

No work is planed until we get a few green boxes here: https://caniuse.com/css-nesting

So the team should not wait until it fully supported ! You penalizes a developers branch that doesn't necessarily develop web content and would like use last technologie. disable css rule it not suitable ! i hope we can see soon a update !

jonlepage avatar Apr 16 '23 03:04 jonlepage

I tried a few extensions. I think this one works fine: https://marketplace.visualstudio.com/items?itemName=csstools.postcss

sellwawy avatar Apr 19 '23 05:04 sellwawy

I tried a few extensions. I think this one works fine: https://marketplace.visualstudio.com/items?itemName=csstools.postcss

it broke intellisence

But this one seem do the jobs. (forked with fix) https://marketplace.visualstudio.com/items?itemName=vunguyentuan.vscode-postcss

you just need install new formater like prettier because eslint,vscode seem not format the file. image

jonlepage avatar Apr 19 '23 06:04 jonlepage

But this one seem do the jobs. (forked with fix) https://marketplace.visualstudio.com/items?itemName=vunguyentuan.vscode-postcss

Actually I intended to refer to this one! Thank you.

sellwawy avatar Apr 19 '23 08:04 sellwawy

Nesting supported at a Global-rate of 40.94% right now.

But I understand Microsoft and VS-Code as a product, not want to misslead anyone that's not deep into the subject and risk breaking stuff for their customers. However, it would be nice if VS-Code itself would be able to offer some kind of setting to use "experimental features syntax-highlighting". Instead of installing a bunch of formatters that's not officially supported.

fjohanssondev avatar Apr 19 '23 08:04 fjohanssondev

This is already stable in Chrome and Safari, it should be supported natively.

nickserv avatar Apr 23 '23 04:04 nickserv

Actually I intended to refer to this one! Thank you.

seem issue with the plugin type in postcss for @container query image

jonlepage avatar Apr 24 '23 15:04 jonlepage

CanIUse has updated the table to include Edge 112:

image

RWeigelt avatar Apr 24 '23 15:04 RWeigelt

CanIUse has updated the table to include Opera 98:

image

CerealeZ avatar May 02 '23 15:05 CerealeZ

image I hate it

vistwang avatar May 09 '23 06:05 vistwang

1.78 has parsing support for css nesting. What's still missing is the syntax highlighting.

aeschli avatar May 09 '23 13:05 aeschli

[...] What's still missing is the syntax highlighting.

REALLY missing!

danielgraziani91 avatar Jun 12 '23 08:06 danielgraziani91

Bumping this issue since nesting is used now in every production project I work with, and there is a big shift going on from sass to a lighter-weight combo css + postcss.

maslennikov avatar Jul 02 '23 09:07 maslennikov

in a free and open-source projects, developers behind will often work themselves on what they love and do things they like. I don't think anyone on the vscode team wants to take care of this feature (maybe pain to work), hence the bizarre and strange excuse "we are waiting for full web support."

jonlepage avatar Jul 02 '23 14:07 jonlepage

Firefox 116 added support for CSS nesting.

https://caniuse.com/css-nesting

image

erosman avatar Jul 08 '23 12:07 erosman

I was under the impression the nesting syntax without the & (for example .parent { .child {...} } was invalid because vscode syntax highlighting breaks, and makes the child selector looks like a property. I assumed that since it was breaking syntax highlighting, it wasn't valid.

Turns out & is optional in that use case and the syntax issue led me here.

viveleroi avatar Jul 30 '23 20:07 viveleroi