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

[CSS] Update completions from MDN #3881

Merged
merged 10 commits into from
Mar 15, 2024
15 changes: 9 additions & 6 deletions CSS/CSS.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -2014,7 +2014,9 @@ contexts:
color-color-functions:
# color()
# https://drafts.csswg.org/css-color/#color-function
- match: \b(?i:color)(?=\()
# light-dark()
# https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/light-dark
- match: \b(?i:color|light-dark)(?=\()
scope: meta.function-call.identifier.css support.function.color.css
push:
- color-color-function-arguments-list-body
Expand All @@ -2036,8 +2038,9 @@ contexts:
# https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hwb
# lch()
# https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/lch
# https://drafts.csswg.org/css-color/#funcdef-lch
- match: \b(?i:hsla?|hwb|lch)(?=\()
# oklch()
# https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/oklch
- match: \b(?i:hsla?|hwb|(?:ok)?lch)(?=\()
scope: meta.function-call.identifier.css support.function.color.css
push:
- hsl-color-function-arguments-list-body
Expand All @@ -2055,11 +2058,11 @@ contexts:
rgb-color-functions:
# rgb(), rgba()
# https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb
# https://drafts.csswg.org/css-color/#funcdef-rgb
# lab()
# https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/lab
# https://drafts.csswg.org/css-color/#funcdef-lab
- match: \b(?i:rgba?|lab)(?=\()
# oklab()
# https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/oklab
- match: \b(?i:rgba?|(?:ok)?lab)(?=\()
scope: meta.function-call.identifier.css support.function.color.css
push:
- rgb-color-function-arguments-list-body
Expand Down
28 changes: 23 additions & 5 deletions CSS/completions/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,16 @@ def get_common_values():
"color": [
"currentColor",
"transparent",
["rgb()", "rgb(${1:0}, ${2:0}, ${3:0}${4:, ${5:1.0}})"],
["rgb()", "rgb(${1:0}, ${2:0}, ${3:0}${4: / ${5:1.0}})"],
["rgba()", "rgba(${1:0}, ${2:0}, ${3:0}, ${4:1.0})"],
["hsl()", "hsl(${1:0}, ${2:100%}, ${3:50%}${4:, ${5:1.0}})"],
["hsl()", "hsl(${1:0}, ${2:100%}, ${3:50%}${4: / ${5:1.0}})"],
["hsla()", "hsla(${1:0}, ${2:100%}, ${3:50%}, ${4:1.0})"],
["hwb()", "hwb(${1:0}, ${2:100%}, ${3:50%}${4:, ${5:1.0}})"],
["lab()", "lab(${1:0%}, ${2:0}, ${3:0}${4:, ${5:1.0}})"],
["lch()", "lch(${1:0%}, ${2:0.0}, ${3:0.0}${4:, ${5:1.0}})"],
["hwb()", "hwb(${1:0}, ${2:100%}, ${3:50%}${4: / ${5:1.0}})"],
["lab()", "lab(${1:0%}, ${2:0}, ${3:0}${4: / ${5:1.0}})"],
["lch()", "lch(${1:0%}, ${2:0.0}, ${3:0.0}${4: / ${5:1.0}})"],
["light-dark()", "light-dark(${1}, ${2})"],
["oklab()", "oklab(${1:0%}, ${2:0}, ${3:0}${4: / ${5:1.0}})"],
["oklch()", "oklch(${1:0%}, ${2:0.0}, ${3:0.0}${4: / ${5:1.0}})"],
# Named colors
"aliceblue",
"antiquewhite",
Expand Down Expand Up @@ -441,6 +444,7 @@ def get_common_values():
],
"shape-radius": ["closest-side", "farthest-side"],
"side-or-corner": ["left", "right", "top", "bottom"],
"text-wrap": ["wrap", "nowrap", "balance", "stable", "pretty"],
"timing-function": [
"linear",
"ease",
Expand Down Expand Up @@ -494,6 +498,20 @@ def get_common_values():
"%",
],
"url": [["url()", "url($1)"]],
"white-space-collapse": [
"collapse",
"discard",
"preserve",
"preserve-breaks",
"preserve-spaces",
"break-spaces"
],
"white-space-trim": [
"none",
"discard-before",
"discard-after",
"discard-inner"
],
}

resolved_values = {}
Expand Down
3 changes: 3 additions & 0 deletions CSS/completions/function_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def get_func_args():
"lab": ["<calc>", "none"],
"lch": ["<calc>", "none"],
"leader": ["<leader-type>"],
"light-dark": ["<color>"],
"linear-gradient": ["<side-or-corner>", "<color>", "to"],
"log": ["<calc>"],
"matrix": ["<calc>"],
Expand All @@ -49,6 +50,8 @@ def get_func_args():
"min": [["attr()", "attr($1)"], "<calc>"],
"minmax": ["min-content", "max-content", "auto"],
"mod": ["<calc>"],
"oklab": ["<calc>", "none"],
"oklch": ["<calc>", "none"],
"opacity": ["<calc>"],
"path": ["<fill-rule>"],
"paint": [],
Expand Down
17 changes: 15 additions & 2 deletions CSS/completions/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def get_properties():
],
"columns": ["<calc>", "auto"],
"container": ["<container-type>"],
"container-name": [],
"container-name": ["none"],
"container-type": ["<container-type>"],
"contain": ["content", "layout", "none", "paint", "inline-size", "size", "strict", "style"],
"contain-intrinsic-size": ["none", "auto"],
Expand Down Expand Up @@ -479,6 +479,9 @@ def get_properties():
],
"font-style": ["normal", "italic", "oblique"],
"font-synthesis": ["none", "weight", "style", "small-caps"],
"font-synthesis-small-caps": ["auto", "none"],
"font-synthesis-style": ["auto", "none"],
"font-synthesis-weight": ["auto", "none"],
"font-variant": ["normal", "small-caps"],
"font-variant-alternates": ["<font-variant-alternates>"],
"font-variant-caps": [
Expand All @@ -500,6 +503,7 @@ def get_properties():
"simplified",
"traditional",
],
"font-variant-emoji": ["normal", "text", "emoji", "unicode"],
"font-variant-ligatures": [
"normal",
"none",
Expand Down Expand Up @@ -626,6 +630,7 @@ def get_properties():
"height": ["<calc>", "auto", "fit-content"],
"hyphens": ["none", "manual", "auto"],
"hyphenate-character": ["auto"],
"hyphenate-limit-chars": ["auto"],
"image-orientation": ["flip", "from-image"],
"image-rendering": ["auto", "optimizeSpeed", "optimizeQuality", "pixelated"],
"image-resolution": ["from-image"],
Expand Down Expand Up @@ -812,7 +817,7 @@ def get_properties():
"offset-inline-end": ["<calc>", "auto"],
"offset-inline-start": ["<calc>", "auto"],
"offset-path": ["<calc>", "none"],
"offset-position": ["<calc>", "auto"],
"offset-position": ["<calc>", "auto", "normal"],
"offset-rotate": ["<calc>", "auto", "reverse"],
"opacity": [
"<calc>",
Expand Down Expand Up @@ -872,9 +877,11 @@ def get_properties():
"padding-left": ["<calc>", "auto"],
"padding-right": ["<calc>", "auto"],
"padding-top": ["<calc>", "auto"],
"page": ["auto"],
"page-break-after": ["auto", "always", "avoid", "left", "right"],
"page-break-before": ["auto", "always", "avoid", "left", "right"],
"page-break-inside": ["avoid", "auto"],
"page-orientation": ["upright", "rotate-left", "rotate-right"],
"paint-order": ["normal", "fill", "stroke", "markers"],
"perspective": ["none"],
"perspective-origin": ["<calc>", "<position>"],
Expand Down Expand Up @@ -1091,6 +1098,7 @@ def get_properties():
],
"text-underline-offset": ["<calc>", "auto"],
"text-underline-position": ["auto", "under", "left", "right"],
"text-wrap": ["<text-wrap>"],
"top": ["<calc>", "auto"],
"touch-action": [
"auto",
Expand Down Expand Up @@ -1192,7 +1200,12 @@ def get_properties():
"nowrap",
"pre-wrap",
"pre-line",
"<text-wrap>",
"<white-space-collapse>",
"<white-space-trim>",
],
"white-space-collapse": ["<white-space-collapse>"],
"white-space-trim": ["<white-space-trim>"],
"widows": [
"<calc>",
],
Expand Down
19 changes: 19 additions & 0 deletions CSS/syntax_test_css.css
Original file line number Diff line number Diff line change
Expand Up @@ -3243,6 +3243,25 @@
/* ^^^ constant.numeric.value.css */
/* ^ constant.numeric.suffix.css */

color: oklab(0% 0 0 / 1.0);
/* ^^^^^ support.function.color.css */
/* ^ punctuation.separator.alpha.css */

color: oklch(0% 0.0 0.0 / 1.0);
/* ^^^^^ support.function.color.css */
/* ^^ meta.number.integer.decimal.css */
/* ^ constant.numeric.value.css */
/* ^^^ meta.number.float.decimal.css constant.numeric.value.css */
/* ^^^ meta.number.float.decimal.css constant.numeric.value.css */
/* ^ punctuation.separator.alpha.css */
/* ^^^ meta.number.float.decimal.css constant.numeric.value.css */

color: light-dark(red, rgb(0, 0, 0));
/* ^^^^^^^^^^ support.function.color.css */
/* ^^^ support.constant.color.w3c.standard.css */
/* ^ punctuation.separator.sequence.css */
/* ^^^ support.function.color.css */

top: color(w(var()) s(var()) () ));
/* ^^^^^ support.function.color.css */
/* ^ punctuation.section.group.begin.css */
Expand Down