aboutsummaryrefslogtreecommitdiff
path: root/runtime/syntax/css.vim
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2026-10-01 13:19:35 +0800
committerGitHub <noreply@github.com>2026-10-01 13:19:35 +0800
commitdce927183cfec31fe8ca32ac7d58544f5c669bf9 (patch)
tree8b1a153de0668244d02462b2d1450fc2705a7344 /runtime/syntax/css.vim
parent02c98fb74fefa7573b8393e51005533a102a4f3a (diff)
downloadrneovim-dce927183cfec31fe8ca32ac7d58544f5c669bf9.tar.gz
rneovim-dce927183cfec31fe8ca32ac7d58544f5c669bf9.tar.bz2
rneovim-dce927183cfec31fe8ca32ac7d58544f5c669bf9.zip
vim-patch:43725ac: runtime(css): Add additional CSS pseudo-classes and functions (#42192)
Problem: Other than `state()` these are widely supported CSS features Solution: Add :host, :host-context(), slotted(), and state() CSS pseudo-classes and functions (S0AndS0). Reference: - https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/:host - https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/:host_function - https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/::slotted - https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/:state TLDR: `host` and `host-context()` are useful for shadowDom stuff, `::slotted()` enables targeting elements passed/injected into a `<template>` and `state()` enables targeting custom identifiers. For example, currently I'm (ab)using `:host` as a drop-in replacement for `:root` when defining variables that are intended to be shared across custom/template elements; - `./assets/css/host.css` ```css :host { --default__margin-block: 0.25rem; } ``` - `./custom-elements/example.html` ```html <template> <link rel="stylesheet" href="/assets/css/host.css"> <style> header { margin-block-start: calc(var(--default__margin-block) * 2); } </style> <header></header> </template> ``` closes: vim/vim#21404 https://github.com/vim/vim/commit/43725acce680d1b999e22fad68cea99c2b593325 Co-authored-by: S0AndS0 <strangerthanbland@gmail.com>
Diffstat (limited to 'runtime/syntax/css.vim')
-rw-r--r--runtime/syntax/css.vim7
1 files changed, 4 insertions, 3 deletions
diff --git a/runtime/syntax/css.vim b/runtime/syntax/css.vim
index b3510229e7..9c7e306413 100644
--- a/runtime/syntax/css.vim
+++ b/runtime/syntax/css.vim
@@ -12,6 +12,7 @@
" 2025 Nov 11: improve support for cssBoxProperties #18717
" 2026 Feb 13: add missing numeric units (baseline 2015, 2020, 2022, 2023, 2026) #19325
" 2026 Jun 28: add scrollbar-gutter properties
+" 2026 Sep 30: add :host, :host-context(), slotted(), and state() #21404
" quit when a syntax file was already loaded
if !exists("main_syntax")
@@ -479,12 +480,12 @@ syn match cssAttrComma ","
" Pseudo class
" https://www.w3.org/TR/selectors-4/
syn match cssPseudoClass ":[A-Za-z0-9_-]*" contains=cssNoise,cssPseudoClassId,cssUnicodeEscape,cssVendor,cssPseudoClassFn
-syn keyword cssPseudoClassId contained link visited active hover before after left right
-syn keyword cssPseudoClassId contained root empty target enabled disabled checked invalid
+syn keyword cssPseudoClassId contained link visited active hover before after left right slotted
+syn keyword cssPseudoClassId contained root host empty target enabled disabled checked invalid
syn match cssPseudoClassId contained "\<first-\%(line\|letter\)\>"
syn match cssPseudoClassId contained "\<\%(first\|last\|only\)-\%(of-type\|child\)\>"
syn match cssPseudoClassId contained "\<focus\%(-within\|-visible\)\=\>"
-syn region cssPseudoClassFn contained matchgroup=cssFunctionName start="\<\%(not\|is\|lang\|\%(nth\|nth-last\)-\%(of-type\|child\)\)(" end=")" contains=cssStringQ,cssStringQQ,cssTagName,cssAttributeSelector,cssClassName,cssIdentifier
+syn region cssPseudoClassFn contained matchgroup=cssFunctionName start="\<\%(not\|is\|lang\|host\|host-context\|state\|\%(nth\|nth-last\)-\%(of-type\|child\)\)(" end=")" contains=cssStringQ,cssStringQQ,cssTagName,cssAttributeSelector,cssClassName,cssIdentifier
" ------------------------------------
" Vendor specific properties
syn match cssPseudoClassId contained "\<selection\>"