1" Vim completion script 2" Language: CSS 3" Based on MDN CSS Reference at 2016 Jan <https://developer.mozilla.org/en-US/docs/Web/CSS/Reference> 4" plus CSS Speech Module <http://www.w3.org/TR/css3-speech/> 5" Maintainer: Kao, Wei-Ko(othree) ( othree AT gmail DOT com ) 6" Original Author: Mikolaj Machowski ( mikmach AT wp DOT pl ) 7" Last Change: 2016 Jan 11 8 9let s:values = split("all additive-symbols align-content align-items align-self animation animation-delay animation-direction animation-duration animation-fill-mode animation-iteration-count animation-name animation-play-state animation-timing-function backface-visibility background background-attachment background-blend-mode background-clip background-color background-image background-origin background-position background-repeat background-size block-size border border-block-end border-block-end-color border-block-end-style border-block-end-width border-block-start border-block-start-color border-block-start-style border-block-start-width border-bottom border-bottom-color border-bottom-left-radius border-bottom-right-radius border-bottom-style border-bottom-width border-collapse border-color border-image border-image-outset border-image-repeat border-image-slice border-image-source border-image-width border-inline-end border-inline-end-color border-inline-end-style border-inline-end-width border-inline-start border-inline-start-color border-inline-start-style border-inline-start-width border-left border-left-color border-left-style border-left-width border-radius border-right border-right-color border-right-style border-right-width border-spacing border-style border-top border-top-color border-top-left-radius border-top-right-radius border-top-style border-top-width border-width bottom box-decoration-break box-shadow box-sizing break-after break-before break-inside caption-side clear clip clip-path color columns column-count column-fill column-gap column-rule column-rule-color column-rule-style column-rule-width column-span column-width content counter-increment counter-reset cue cue-before cue-after cursor direction display empty-cells fallback filter flex flex-basis flex-direction flex-flow flex-grow flex-shrink flex-wrap float font font-family font-feature-settings font-kerning font-language-override font-size font-size-adjust font-stretch font-style font-synthesis font-variant font-variant-alternates font-variant-caps font-variant-east-asian font-variant-ligatures font-variant-numeric font-variant-position font-weight grid grid-area grid-auto-columns grid-auto-flow grid-auto-position grid-auto-rows grid-column grid-column-start grid-column-end grid-row grid-row-start grid-row-end grid-template grid-template-areas grid-template-rows grid-template-columns height hyphens image-rendering image-resolution image-orientation ime-mode inline-size isolation justify-content left letter-spacing line-break line-height list-style list-style-image list-style-position list-style-type margin margin-block-end margin-block-start margin-bottom margin-inline-end margin-inline-start margin-left margin-right margin-top marks mask mask-type max-block-size max-height max-inline-size max-width max-zoom min-block-size min-height min-inline-size min-width min-zoom mix-blend-mode negative object-fit object-position offset-block-end offset-block-start offset-inline-end offset-inline-start opacity order orientation orphans outline outline-color outline-offset outline-style outline-width overflow overflow-wrap overflow-x overflow-y pad padding padding-block-end padding-block-start padding-bottom padding-inline-end padding-inline-start padding-left padding-right padding-top page-break-after page-break-before page-break-inside pause-before pause-after pause perspective perspective-origin pointer-events position prefix quotes range resize rest rest-before rest-after right ruby-align ruby-merge ruby-position scroll-behavior scroll-snap-coordinate scroll-snap-destination scroll-snap-points-x scroll-snap-points-y scroll-snap-type scroll-snap-type-x scroll-snap-type-y shape-image-threshold shape-margin shape-outside speak speak-as suffix symbols system table-layout tab-size text-align text-align-last text-combine-upright text-decoration text-decoration-color text-decoration-line text-emphasis text-emphasis-color text-emphasis-position text-emphasis-style text-indent text-orientation text-overflow text-rendering text-shadow text-transform text-underline-position top touch-action transform transform-box transform-origin transform-style transition transition-delay transition-duration transition-property transition-timing-function unicode-bidi unicode-range user-zoom vertical-align visibility voice-balance voice-duration voice-family voice-pitch voice-rate voice-range voice-stress voice-volume white-space widows width will-change word-break word-spacing word-wrap writing-mode z-index zoom") 10 11 12function! csscomplete#CompleteCSS(findstart, base) 13 14 if a:findstart 15 " We need whole line to proper checking 16 let line = getline('.') 17 let start = col('.') - 1 18 let compl_begin = col('.') - 2 19 while start >= 0 && line[start - 1] =~ '\%(\k\|-\)' 20 let start -= 1 21 endwhile 22 let b:after = line[compl_begin :] 23 let b:compl_context = line[0:compl_begin] 24 return start 25 endif 26 27 " There are few chars important for context: 28 " ^ ; : { } /* */ 29 " Where ^ is start of line and /* */ are comment borders 30 " Depending on their relative position to cursor we will know what should 31 " be completed. 32 " 1. if nearest are ^ or { or ; current word is property 33 " 2. if : it is value (with exception of pseudo things) 34 " 3. if } we are outside of css definitions 35 " 4. for comments ignoring is be the easiest but assume they are the same 36 " as 1. 37 " 5. if @ complete at-rule 38 " 6. if ! complete important 39 if exists("b:compl_context") 40 let line = b:compl_context 41 let after = b:after 42 unlet! b:compl_context 43 else 44 let line = a:base 45 endif 46 47 let res = [] 48 let res2 = [] 49 let borders = {} 50 51 " Check last occurrence of sequence 52 53 let openbrace = strridx(line, '{') 54 let closebrace = strridx(line, '}') 55 let colon = strridx(line, ':') 56 let semicolon = strridx(line, ';') 57 let opencomm = strridx(line, '/*') 58 let closecomm = strridx(line, '*/') 59 let style = strridx(line, 'style\s*=') 60 let atrule = strridx(line, '@') 61 let exclam = strridx(line, '!') 62 63 if openbrace > -1 64 let borders[openbrace] = "openbrace" 65 endif 66 if closebrace > -1 67 let borders[closebrace] = "closebrace" 68 endif 69 if colon > -1 70 let borders[colon] = "colon" 71 endif 72 if semicolon > -1 73 let borders[semicolon] = "semicolon" 74 endif 75 if opencomm > -1 76 let borders[opencomm] = "opencomm" 77 endif 78 if closecomm > -1 79 let borders[closecomm] = "closecomm" 80 endif 81 if style > -1 82 let borders[style] = "style" 83 endif 84 if atrule > -1 85 let borders[atrule] = "atrule" 86 endif 87 if exclam > -1 88 let borders[exclam] = "exclam" 89 endif 90 91 92 if len(borders) == 0 || borders[max(keys(borders))] =~ '^\%(openbrace\|semicolon\|opencomm\|closecomm\|style\)$' 93 " Complete properties 94 95 96 let entered_property = matchstr(line, '.\{-}\zs[a-zA-Z-]*$') 97 98 for m in s:values 99 if m =~? '^'.entered_property 100 call add(res, m . ':') 101 elseif m =~? entered_property 102 call add(res2, m . ':') 103 endif 104 endfor 105 106 return res + res2 107 108 elseif borders[max(keys(borders))] == 'colon' 109 " Get name of property 110 let prop = tolower(matchstr(line, '\zs[a-zA-Z-]*\ze\s*:[^:]\{-}$')) 111 112 let wide_keywords = ["initial", "inherit", "unset"] 113 let color_values = ["transparent", "rgb(", "rgba(", "hsl(", "hsla(", "#"] 114 let border_style_values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"] 115 let border_width_values = ["thin", "thick", "medium"] 116 let list_style_type_values = ["decimal", "decimal-leading-zero", "arabic-indic", "armenian", "upper-armenian", "lower-armenian", "bengali", "cambodian", "khmer", "cjk-decimal", "devanagari", "georgian", "gujarati", "gurmukhi", "hebrew", "kannada", "lao", "malayalam", "mongolian", "myanmar", "oriya", "persian", "lower-roman", "upper-roman", "tamil", "telugu", "thai", "tibetan", "lower-alpha", "lower-latin", "upper-alpha", "upper-latin", "cjk-earthly-branch", "cjk-heavenly-stem", "lower-greek", "hiragana", "hiragana-iroha", "katakana", "katakana-iroha", "disc", "circle", "square", "disclosure-open", "disclosure-closed"] 117 let timing_functions = ["cubic-bezier(", "steps(", "linear", "ease", "ease-in", "ease-in-out", "ease-out", "step-start", "step-end"] 118 119 if prop == 'all' 120 let values = [] 121 elseif prop == 'additive-symbols' 122 let values = [] 123 elseif prop == 'align-content' 124 let values = ["flex-start", "flex-end", "center", "space-between", "space-around", "stretch"] 125 elseif prop == 'align-items' 126 let values = ["flex-start", "flex-end", "center", "baseline", "stretch"] 127 elseif prop == 'align-self' 128 let values = ["auto", "flex-start", "flex-end", "center", "baseline", "stretch"] 129 elseif prop == 'animation' 130 let values = timing_functions + ["normal", "reverse", "alternate", "alternate-reverse"] + ["none", "forwards", "backwards", "both"] + ["running", "paused"] 131 elseif prop == 'animation-delay' 132 let values = [] 133 elseif prop == 'animation-direction' 134 let values = ["normal", "reverse", "alternate", "alternate-reverse"] 135 elseif prop == 'animation-duration' 136 let values = [] 137 elseif prop == 'animation-fill-mode' 138 let values = ["none", "forwards", "backwards", "both"] 139 elseif prop == 'animation-iteration-count' 140 let values = [] 141 elseif prop == 'animation-name' 142 let values = [] 143 elseif prop == 'animation-play-state' 144 let values = ["running", "paused"] 145 elseif prop == 'animation-timing-function' 146 let values = timing_functions 147 elseif prop == 'background-attachment' 148 let values = ["scroll", "fixed"] 149 elseif prop == 'background-color' 150 let values = color_values 151 elseif prop == 'background-image' 152 let values = ["url(", "none"] 153 elseif prop == 'background-position' 154 let vals = matchstr(line, '.*:\s*\zs.*') 155 if vals =~ '^\%([a-zA-Z]\+\)\?$' 156 let values = ["top", "center", "bottom"] 157 elseif vals =~ '^[a-zA-Z]\+\s\+\%([a-zA-Z]\+\)\?$' 158 let values = ["left", "center", "right"] 159 else 160 return [] 161 endif 162 elseif prop == 'background-repeat' 163 let values = ["repeat", "repeat-x", "repeat-y", "no-repeat"] 164 elseif prop == 'background-size' 165 let values = ["auto", "contain", "cover"] 166 elseif prop == 'background' 167 let values = ["scroll", "fixed"] + color_values + ["url(", "none"] + ["top", "center", "bottom", "left", "right"] + ["repeat", "repeat-x", "repeat-y", "no-repeat"] + ["auto", "contain", "cover"] 168 elseif prop =~ 'border\%(-top\|-right\|-bottom\|-left\|-block-start\|-block-end\)\?$' 169 let vals = matchstr(line, '.*:\s*\zs.*') 170 if vals =~ '^\%([a-zA-Z0-9.]\+\)\?$' 171 let values = border_width_values 172 elseif vals =~ '^[a-zA-Z0-9.]\+\s\+\%([a-zA-Z]\+\)\?$' 173 let values = border_style_values 174 elseif vals =~ '^[a-zA-Z0-9.]\+\s\+[a-zA-Z]\+\s\+\%([a-zA-Z(]\+\)\?$' 175 let values = color_values 176 else 177 return [] 178 endif 179 elseif prop =~ 'border-\%(top\|right\|bottom\|left\|block-start\|block-end\)-color' 180 let values = color_values 181 elseif prop =~ 'border-\%(top\|right\|bottom\|left\|block-start\|block-end\)-style' 182 let values = border_style_values 183 elseif prop =~ 'border-\%(top\|right\|bottom\|left\|block-start\|block-end\)-width' 184 let values = border_width_values 185 elseif prop == 'border-color' 186 let values = color_values 187 elseif prop == 'border-style' 188 let values = border_style_values 189 elseif prop == 'border-width' 190 let values = border_width_values 191 elseif prop == 'bottom' 192 let values = ["auto"] 193 elseif prop == 'box-decoration-break' 194 let values = ["slice", "clone"] 195 elseif prop == 'box-shadow' 196 let values = ["inset"] 197 elseif prop == 'box-sizing' 198 let values = ["border-box", "content-box"] 199 elseif prop =~ 'break-\%(before\|after\)' 200 let values = ["auto", "always", "avoid", "left", "right", "page", "column", "region", "recto", "verso", "avoid-page", "avoid-column", "avoid-region"] 201 elseif prop == 'break-inside' 202 let values = ["auto", "avoid", "avoid-page", "avoid-column", "avoid-region"] 203 elseif prop == 'caption-side' 204 let values = ["top", "bottom"] 205 elseif prop == 'clear' 206 let values = ["none", "left", "right", "both"] 207 elseif prop == 'clip' 208 let values = ["auto", "rect("] 209 elseif prop == 'clip-path' 210 let values = ["fill-box", "stroke-box", "view-box", "none"] 211 elseif prop == 'color' 212 let values = color_values 213 elseif prop == 'columns' 214 let values = [] 215 elseif prop == 'column-count' 216 let values = ['auto'] 217 elseif prop == 'column-fill' 218 let values = ['auto', 'balance'] 219 elseif prop == 'column-rule-color' 220 let values = color_values 221 elseif prop == 'column-rule-style' 222 let values = border_style_values 223 elseif prop == 'column-rule-width' 224 let values = border_width_values 225 elseif prop == 'column-rule' 226 let vals = matchstr(line, '.*:\s*\zs.*') 227 if vals =~ '^\%([a-zA-Z0-9.]\+\)\?$' 228 let values = border_width_values 229 elseif vals =~ '^[a-zA-Z0-9.]\+\s\+\%([a-zA-Z]\+\)\?$' 230 let values = border_style_values 231 elseif vals =~ '^[a-zA-Z0-9.]\+\s\+[a-zA-Z]\+\s\+\%([a-zA-Z(]\+\)\?$' 232 let values = color_values 233 else 234 return [] 235 endif 236 elseif prop == 'column-span' 237 let values = ["none", "all"] 238 elseif prop == 'column-width' 239 let values = ["auto"] 240 elseif prop == 'content' 241 let values = ["normal", "attr(", "open-quote", "close-quote", "no-open-quote", "no-close-quote"] 242 elseif prop =~ 'counter-\%(increment\|reset\)$' 243 let values = ["none"] 244 elseif prop =~ 'cue\%(-after\|-before\)\=$' 245 let values = ["url("] 246 elseif prop == 'cursor' 247 let values = ["url(", "auto", "crosshair", "default", "pointer", "move", "e-resize", "ne-resize", "nw-resize", "n-resize", "se-resize", "sw-resize", "s-resize", "w-resize", "text", "wait", "help", "progress"] 248 elseif prop == 'direction' 249 let values = ["ltr", "rtl"] 250 elseif prop == 'display' 251 let values = ["inline", "block", "list-item", "inline-list-item", "run-in", "inline-block", "table", "inline-table", "table-row-group", "table-header-group", "table-footer-group", "table-row", "table-column-group", "table-column", "table-cell", "table-caption", "none", "flex", "inline-flex", "grid", "inline-grid", "ruby", "ruby-base", "ruby-text", "ruby-base-container", "ruby-text-container", "contents"] 252 elseif prop == 'elevation' 253 let values = ["below", "level", "above", "higher", "lower"] 254 elseif prop == 'empty-cells' 255 let values = ["show", "hide"] 256 elseif prop == 'fallback' 257 let values = list_style_type_values 258 elseif prop == 'filter' 259 let values = ["blur(", "brightness(", "contrast(", "drop-shadow(", "grayscale(", "hue-rotate(", "invert(", "opacity(", "sepia(", "saturate("] 260 elseif prop == 'flex-basis' 261 let values = ["auto", "content"] 262 elseif prop == 'flex-flow' 263 let values = ["row", "row-reverse", "column", "column-reverse", "nowrap", "wrap", "wrap-reverse"] 264 elseif prop == 'flex-grow' 265 let values = [] 266 elseif prop == 'flex-shrink' 267 let values = [] 268 elseif prop == 'flex-wrap' 269 let values = ["nowrap", "wrap", "wrap-reverse"] 270 elseif prop == 'flex' 271 let values = ["nowrap", "wrap", "wrap-reverse"] + ["row", "row-reverse", "column", "column-reverse", "nowrap", "wrap", "wrap-reverse"] + ["auto", "content"] 272 elseif prop == 'float' 273 let values = ["left", "right", "none"] 274 elseif prop == 'font-family' 275 let values = ["sans-serif", "serif", "monospace", "cursive", "fantasy"] 276 elseif prop == 'font-feature-settings' 277 let values = ["normal", '"aalt"', '"abvf"', '"abvm"', '"abvs"', '"afrc"', '"akhn"', '"blwf"', '"blwm"', '"blws"', '"calt"', '"case"', '"ccmp"', '"cfar"', '"cjct"', '"clig"', '"cpct"', '"cpsp"', '"cswh"', '"curs"', '"cv', '"c2pc"', '"c2sc"', '"dist"', '"dlig"', '"dnom"', '"dtls"', '"expt"', '"falt"', '"fin2"', '"fin3"', '"fina"', '"flac"', '"frac"', '"fwid"', '"half"', '"haln"', '"halt"', '"hist"', '"hkna"', '"hlig"', '"hngl"', '"hojo"', '"hwid"', '"init"', '"isol"', '"ital"', '"jalt"', '"jp78"', '"jp83"', '"jp90"', '"jp04"', '"kern"', '"lfbd"', '"liga"', '"ljmo"', '"lnum"', '"locl"', '"ltra"', '"ltrm"', '"mark"', '"med2"', '"medi"', '"mgrk"', '"mkmk"', '"mset"', '"nalt"', '"nlck"', '"nukt"', '"numr"', '"onum"', '"opbd"', '"ordn"', '"ornm"', '"palt"', '"pcap"', '"pkna"', '"pnum"', '"pref"', '"pres"', '"pstf"', '"psts"', '"pwid"', '"qwid"', '"rand"', '"rclt"', '"rkrf"', '"rlig"', '"rphf"', '"rtbd"', '"rtla"', '"rtlm"', '"ruby"', '"salt"', '"sinf"', '"size"', '"smcp"', '"smpl"', '"ss01"', '"ss02"', '"ss03"', '"ss04"', '"ss05"', '"ss06"', '"ss07"', '"ss08"', '"ss09"', '"ss10"', '"ss11"', '"ss12"', '"ss13"', '"ss14"', '"ss15"', '"ss16"', '"ss17"', '"ss18"', '"ss19"', '"ss20"', '"ssty"', '"stch"', '"subs"', '"sups"', '"swsh"', '"titl"', '"tjmo"', '"tnam"', '"tnum"', '"trad"', '"twid"', '"unic"', '"valt"', '"vatu"', '"vert"', '"vhal"', '"vjmo"', '"vkna"', '"vkrn"', '"vpal"', '"vrt2"', '"zero"'] 278 elseif prop == 'font-kerning' 279 let values = ["auto", "normal", "none"] 280 elseif prop == 'font-language-override' 281 let values = ["normal"] 282 elseif prop == 'font-size' 283 let values = ["xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large", "larger", "smaller"] 284 elseif prop == 'font-size-adjust' 285 let values = [] 286 elseif prop == 'font-stretch' 287 let values = ["normal", "ultra-condensed", "extra-condensed", "condensed", "semi-condensed", "semi-expanded", "expanded", "extra-expanded", "ultra-expanded"] 288 elseif prop == 'font-style' 289 let values = ["normal", "italic", "oblique"] 290 elseif prop == 'font-synthesis' 291 let values = ["none", "weight", "style"] 292 elseif prop == 'font-variant-alternates' 293 let values = ["normal", "historical-forms", "stylistic(", "styleset(", "character-variant(", "swash(", "ornaments(", "annotation("] 294 elseif prop == 'font-variant-caps' 295 let values = ["normal", "small-caps", "all-small-caps", "petite-caps", "all-petite-caps", "unicase", "titling-caps"] 296 elseif prop == 'font-variant-asian' 297 let values = ["normal", "ruby", "jis78", "jis83", "jis90", "jis04", "simplified", "traditional"] 298 elseif prop == 'font-variant-ligatures' 299 let values = ["normal", "none", "common-ligatures", "no-common-ligatures", "discretionary-ligatures", "no-discretionary-ligatures", "historical-ligatures", "no-historical-ligatures", "contextual", "no-contextual"] 300 elseif prop == 'font-variant-numeric' 301 let values = ["normal", "ordinal", "slashed-zero", "lining-nums", "oldstyle-nums", "proportional-nums", "tabular-nums", "diagonal-fractions", "stacked-fractions"] 302 elseif prop == 'font-variant-position' 303 let values = ["normal", "sub", "super"] 304 elseif prop == 'font-variant' 305 let values = ["normal", "historical-forms", "stylistic(", "styleset(", "character-variant(", "swash(", "ornaments(", "annotation("] + ["small-caps", "all-small-caps", "petite-caps", "all-petite-caps", "unicase", "titling-caps"] + ["ruby", "jis78", "jis83", "jis90", "jis04", "simplified", "traditional"] + ["none", "common-ligatures", "no-common-ligatures", "discretionary-ligatures", "no-discretionary-ligatures", "historical-ligatures", "no-historical-ligatures", "contextual", "no-contextual"] + ["ordinal", "slashed-zero", "lining-nums", "oldstyle-nums", "proportional-nums", "tabular-nums", "diagonal-fractions", "stacked-fractions"] + ["sub", "super"] 306 elseif prop == 'font-weight' 307 let values = ["normal", "bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900"] 308 elseif prop == 'font' 309 let values = ["normal", "italic", "oblique", "small-caps", "bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900", "xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large", "larger", "smaller", "sans-serif", "serif", "monospace", "cursive", "fantasy", "caption", "icon", "menu", "message-box", "small-caption", "status-bar"] 310 elseif prop =~ '^\%(height\|width\)$' 311 let values = ["auto", "border-box", "content-box", "max-content", "min-content", "available", "fit-content"] 312 elseif prop =~ '^\%(left\|rigth\)$' 313 let values = ["auto"] 314 elseif prop == 'image-rendering' 315 let values = ["auto", "crisp-edges", "pixelated"] 316 elseif prop == 'image-orientation' 317 let values = ["from-image", "flip"] 318 elseif prop == 'ime-mode' 319 let values = ["auto", "normal", "active", "inactive", "disabled"] 320 elseif prop == 'inline-size' 321 let values = ["auto", "border-box", "content-box", "max-content", "min-content", "available", "fit-content"] 322 elseif prop == 'isolation' 323 let values = ["auto", "isolate"] 324 elseif prop == 'justify-content' 325 let values = ["flex-start", "flex-end", "center", "space-between", "space-around"] 326 elseif prop == 'letter-spacing' 327 let values = ["normal"] 328 elseif prop == 'line-break' 329 let values = ["auto", "loose", "normal", "strict"] 330 elseif prop == 'line-height' 331 let values = ["normal"] 332 elseif prop == 'list-style-image' 333 let values = ["url(", "none"] 334 elseif prop == 'list-style-position' 335 let values = ["inside", "outside"] 336 elseif prop == 'list-style-type' 337 let values = list_style_type_values 338 elseif prop == 'list-style' 339 let values = list_style_type_values + ["inside", "outside"] + ["url(", "none"] 340 elseif prop == 'margin' 341 let values = ["auto"] 342 elseif prop =~ 'margin-\%(right\|left\|top\|bottom\|block-start\|block-end\|inline-start\|inline-end\)$' 343 let values = ["auto"] 344 elseif prop == 'marks' 345 let values = ["crop", "cross", "none"] 346 elseif prop == 'mask' 347 let values = ["url("] 348 elseif prop == 'mask-type' 349 let values = ["luminance", "alpha"] 350 elseif prop == '\%(max\|min\)-\%(block\|inline\)-size' 351 let values = ["auto", "border-box", "content-box", "max-content", "min-content", "available", "fit-content"] 352 elseif prop == '\%(max\|min\)-\%(height\|width\)' 353 let values = ["auto", "border-box", "content-box", "max-content", "min-content", "available", "fit-content"] 354 elseif prop == '\%(max\|min\)-zoom' 355 let values = ["auto"] 356 elseif prop == 'mix-blend-mode' 357 let values = ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"] 358 elseif prop == 'opacity' 359 let values = [] 360 elseif prop == 'orientation' 361 let values = ["auto", "portrait", "landscape"] 362 elseif prop == 'orphans' 363 let values = [] 364 elseif prop == 'outline-offset' 365 let values = [] 366 elseif prop == 'outline-color' 367 let values = color_values 368 elseif prop == 'outline-style' 369 let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"] 370 elseif prop == 'outline-width' 371 let values = ["thin", "thick", "medium"] 372 elseif prop == 'outline' 373 let vals = matchstr(line, '.*:\s*\zs.*') 374 if vals =~ '^\%([a-zA-Z0-9,()#]\+\)\?$' 375 let values = color_values 376 elseif vals =~ '^[a-zA-Z0-9,()#]\+\s\+\%([a-zA-Z]\+\)\?$' 377 let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"] 378 elseif vals =~ '^[a-zA-Z0-9,()#]\+\s\+[a-zA-Z]\+\s\+\%([a-zA-Z(]\+\)\?$' 379 let values = ["thin", "thick", "medium"] 380 else 381 return [] 382 endif 383 elseif prop == 'overflow-wrap' 384 let values = ["normal", "break-word"] 385 elseif prop =~ 'overflow\%(-x\|-y\)\=' 386 let values = ["visible", "hidden", "scroll", "auto"] 387 elseif prop == 'pad' 388 let values = [] 389 elseif prop == 'padding' 390 let values = [] 391 elseif prop =~ 'padding-\%(top\|right\|bottom\|left\|inline-start\|inline-end\|block-start\|block-end\)$' 392 let values = [] 393 elseif prop =~ 'page-break-\%(after\|before\)$' 394 let values = ["auto", "always", "avoid", "left", "right", "recto", "verso"] 395 elseif prop == 'page-break-inside' 396 let values = ["auto", "avoid"] 397 elseif prop =~ 'pause\%(-after\|-before\)\=$' 398 let values = ["none", "x-weak", "weak", "medium", "strong", "x-strong"] 399 elseif prop == 'perspective' 400 let values = ["none"] 401 elseif prop == 'perspective-origin' 402 let values = ["top", "bottom", "left", "center", " right"] 403 elseif prop == 'pointer-events' 404 let values = ["auto", "none", "visiblePainted", "visibleFill", "visibleStroke", "visible", "painted", "fill", "stroke", "all"] 405 elseif prop == 'position' 406 let values = ["static", "relative", "absolute", "fixed", "sticky"] 407 elseif prop == 'prefix' 408 let values = [] 409 elseif prop == 'quotes' 410 let values = ["none"] 411 elseif prop == 'range' 412 let values = ["auto", "infinite"] 413 elseif prop == 'resize' 414 let values = ["none", "both", "horizontal", "vertical"] 415 elseif prop =~ 'rest\%(-after\|-before\)\=$' 416 let values = ["none", "x-weak", "weak", "medium", "strong", "x-strong"] 417 elseif prop == 'ruby-align' 418 let values = ["start", "center", "space-between", "space-around"] 419 elseif prop == 'ruby-merge' 420 let values = ["separate", "collapse", "auto"] 421 elseif prop == 'ruby-position' 422 let values = ["over", "under", "inter-character"] 423 elseif prop == 'scroll-behavior' 424 let values = ["auto", "smooth"] 425 elseif prop == 'scroll-snap-coordinate' 426 let values = ["none"] 427 elseif prop == 'scroll-snap-destination' 428 return [] 429 elseif prop == 'scroll-snap-points-\%(x\|y\)$' 430 let values = ["none", "repeat("] 431 elseif prop == 'scroll-snap-type\%(-x\|-y\)\=$' 432 let values = ["none", "mandatory", "proximity"] 433 elseif prop == 'shape-image-threshold' 434 let values = [] 435 elseif prop == 'shape-margin' 436 let values = [] 437 elseif prop == 'shape-outside' 438 let values = ["margin-box", "border-box", "padding-box", "content-box", 'inset(', 'circle(', 'ellipse(', 'polygon(', 'url('] 439 elseif prop == 'speak' 440 let values = ["auto", "none", "normal"] 441 elseif prop == 'speak-as' 442 let values = ["auto", "normal", "spell-out", "digits"] 443 elseif prop == 'src' 444 let values = ["url("] 445 elseif prop == 'suffix' 446 let values = [] 447 elseif prop == 'symbols' 448 let values = [] 449 elseif prop == 'system' 450 let vals = matchstr(line, '.*:\s*\zs.*') 451 if vals =~ '^extends' 452 let values = list_style_type_values 453 else 454 let values = ["cyclic", "numeric", "alphabetic", "symbolic", "additive", "fixed", "extends"] 455 endif 456 elseif prop == 'table-layout' 457 let values = ["auto", "fixed"] 458 elseif prop == 'tab-size' 459 let values = [] 460 elseif prop == 'text-align' 461 let values = ["start", "end", "left", "right", "center", "justify", "match-parent"] 462 elseif prop == 'text-align-last' 463 let values = ["auto", "start", "end", "left", "right", "center", "justify"] 464 elseif prop == 'text-combine-upright' 465 let values = ["none", "all", "digits"] 466 elseif prop == 'text-decoration-line' 467 let values = ["none", "underline", "overline", "line-through", "blink"] 468 elseif prop == 'text-decoration-color' 469 let values = color_values 470 elseif prop == 'text-decoration-style' 471 let values = ["solid", "double", "dotted", "dashed", "wavy"] 472 elseif prop == 'text-decoration' 473 let values = ["none", "underline", "overline", "line-through", "blink"] + ["solid", "double", "dotted", "dashed", "wavy"] + color_values 474 elseif prop == 'text-emphasis-color' 475 let values = color_values 476 elseif prop == 'text-emphasis-position' 477 let values = ["over", "under", "left", "right"] 478 elseif prop == 'text-emphasis-style' 479 let values = ["none", "filled", "open", "dot", "circle", "double-circle", "triangle", "sesame"] 480 elseif prop == 'text-emphasis' 481 let values = color_values + ["over", "under", "left", "right"] + ["none", "filled", "open", "dot", "circle", "double-circle", "triangle", "sesame"] 482 elseif prop == 'text-indent' 483 let values = ["hanging", "each-line"] 484 elseif prop == 'text-orientation' 485 let values = ["mixed", "upright", "sideways", "sideways-right", "use-glyph-orientation"] 486 elseif prop == 'text-overflow' 487 let values = ["clip", "ellipsis"] 488 elseif prop == 'text-rendering' 489 let values = ["auto", "optimizeSpeed", "optimizeLegibility", "geometricPrecision"] 490 elseif prop == 'text-shadow' 491 let values = color_values 492 elseif prop == 'text-transform' 493 let values = ["capitalize", "uppercase", "lowercase", "full-width", "none"] 494 elseif prop == 'text-underline-position' 495 let values = ["auto", "under", "left", "right"] 496 elseif prop == 'touch-action' 497 let values = ["auto", "none", "pan-x", "pan-y", "manipulation", "pan-left", "pan-right", "pan-top", "pan-down"] 498 elseif prop == 'transform' 499 let values = ["matrix(", "translate(", "translateX(", "translateY(", "scale(", "scaleX(", "scaleY(", "rotate(", "skew(", "skewX(", "skewY(", "matrix3d(", "translate3d(", "translateZ(", "scale3d(", "scaleZ(", "rotate3d(", "rotateX(", "rotateY(", "rotateZ(", "perspective("] 500 elseif prop == 'transform-box' 501 let values = ["border-box", "fill-box", "view-box"] 502 elseif prop == 'transform-origin' 503 let values = ["left", "center", "right", "top", "bottom"] 504 elseif prop == 'transform-style' 505 let values = ["flat", "preserve-3d"] 506 elseif prop == 'top' 507 let values = ["auto"] 508 elseif prop == 'transition-property' 509 let values = ["all", "none"] + s:values 510 elseif prop == 'transition-duration' 511 let values = [] 512 elseif prop == 'transition-delay' 513 let values = [] 514 elseif prop == 'transition-timing-function' 515 let values = timing_functions 516 elseif prop == 'transition' 517 let values = ["all", "none"] + s:values + timing_functions 518 elseif prop == 'unicode-bidi' 519 let values = ["normal", "embed", "isolate", "bidi-override", "isolate-override", "plaintext"] 520 elseif prop == 'unicode-range' 521 let values = ["U+"] 522 elseif prop == 'user-zoom' 523 let values = ["zoom", "fixed"] 524 elseif prop == 'vertical-align' 525 let values = ["baseline", "sub", "super", "top", "text-top", "middle", "bottom", "text-bottom"] 526 elseif prop == 'visibility' 527 let values = ["visible", "hidden", "collapse"] 528 elseif prop == 'voice-volume' 529 let values = ["silent", "x-soft", "soft", "medium", "loud", "x-loud"] 530 elseif prop == 'voice-balance' 531 let values = ["left", "center", "right", "leftwards", "rightwards"] 532 elseif prop == 'voice-family' 533 let values = [] 534 elseif prop == 'voice-rate' 535 let values = ["normal", "x-slow", "slow", "medium", "fast", "x-fast"] 536 elseif prop == 'voice-pitch' 537 let values = ["absolute", "x-low", "low", "medium", "high", "x-high"] 538 elseif prop == 'voice-range' 539 let values = ["absolute", "x-low", "low", "medium", "high", "x-high"] 540 elseif prop == 'voice-stress' 541 let values = ["normal", "strong", "moderate", "none", "reduced "] 542 elseif prop == 'voice-duration' 543 let values = ["auto"] 544 elseif prop == 'white-space' 545 let values = ["normal", "pre", "nowrap", "pre-wrap", "pre-line"] 546 elseif prop == 'widows' 547 let values = [] 548 elseif prop == 'will-change' 549 let values = ["auto", "scroll-position", "contents"] + s:values 550 elseif prop == 'word-break' 551 let values = ["normal", "break-all", "keep-all"] 552 elseif prop == 'word-spacing' 553 let values = ["normal"] 554 elseif prop == 'word-wrap' 555 let values = ["normal", "break-word"] 556 elseif prop == 'writing-mode' 557 let values = ["horizontal-tb", "vertical-rl", "vertical-lr", "sideways-rl", "sideways-lr"] 558 elseif prop == 'z-index' 559 let values = ["auto"] 560 elseif prop == 'zoom' 561 let values = ["auto"] 562 else 563 " If no property match it is possible we are outside of {} and 564 " trying to complete pseudo-(class|element) 565 let element = tolower(matchstr(line, '\zs[a-zA-Z1-6]*\ze:[^:[:space:]]\{-}$')) 566 if stridx('a,abbr,address,area,article,aside,audio,b,base,bdi,bdo,bgsound,blockquote,body,br,button,canvas,caption,center,cite,code,col,colgroup,command,content,data,datalist,dd,del,details,dfn,dialog,div,dl,dt,element,em,embed,fieldset,figcaption,figure,font,footer,form,frame,frameset,head,header,hgroup,hr,html,i,iframe,image,img,input,ins,isindex,kbd,keygen,label,legend,li,link,main,map,mark,menu,menuitem,meta,meter,nav,nobr,noframes,noscript,object,ol,optgroup,option,output,p,param,picture,pre,progress,q,rp,rt,rtc,ruby,s,samp,script,section,select,shadow,small,source,span,strong,style,sub,summary,sup,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,u,ul,var,video,wbr', ','.element.',') > -1 567 let values = ["active", "any", "checked", "default", "dir(", "disabled", "empty", "enabled", "first", "first-child", "first-of-type", "fullscreen", "focus", "hover", "indeterminate", "in-range", "invalid", "lang(", "last-child", "last-of-type", "left", "link", "not(", "nth-child(", "nth-last-child(", "nth-last-of-type(", "nth-of-type(", "only-child", "only-of-type", "optional", "out-of-range", "read-only", "read-write", "required", "right", "root", "scope", "target", "valid", "visited", "first-line", "first-letter", "before", "after", "selection", "backdrop"] 568 else 569 return [] 570 endif 571 endif 572 573 let values = wide_keywords + values 574 " Complete values 575 let entered_value = matchstr(line, '.\{-}\zs[a-zA-Z0-9#,.(_-]*$') 576 577 for m in values 578 if m =~? '^'.entered_value 579 call add(res, m) 580 elseif m =~? entered_value 581 call add(res2, m) 582 endif 583 endfor 584 585 return res + res2 586 587 elseif borders[max(keys(borders))] == 'closebrace' 588 589 return [] 590 591 elseif borders[max(keys(borders))] == 'exclam' 592 593 " Complete values 594 let entered_imp = matchstr(line, '.\{-}!\s*\zs[a-zA-Z ]*$') 595 596 let values = ["important"] 597 598 for m in values 599 if m =~? '^'.entered_imp 600 call add(res, m) 601 endif 602 endfor 603 604 return res 605 606 elseif borders[max(keys(borders))] == 'atrule' 607 608 let afterat = matchstr(line, '.*@\zs.*') 609 610 if afterat =~ '\s' 611 612 let atrulename = matchstr(line, '.*@\zs[a-zA-Z-]\+\ze') 613 614 if atrulename == 'media' 615 let entered_atruleafter = matchstr(line, '.*@media\s\+\zs.*$') 616 617 if entered_atruleafter =~ "([^)]*$" 618 let entered_atruleafter = matchstr(entered_atruleafter, '(\s*\zs[^)]*$') 619 let values = ["max-width", "min-width", "width", "max-height", "min-height", "height", "max-aspect-ration", "min-aspect-ration", "aspect-ratio", "orientation", "max-resolution", "min-resolution", "resolution", "scan", "grid", "update-frequency", "overflow-block", "overflow-inline", "max-color", "min-color", "color", "max-color-index", "min-color-index", "color-index", "monochrome", "inverted-colors", "pointer", "hover", "any-pointer", "any-hover", "light-level", "scripting"] 620 else 621 let values = ["screen", "print", "speech", "all", "not", "and", "("] 622 endif 623 624 elseif atrulename == 'supports' 625 let entered_atruleafter = matchstr(line, '.*@supports\s\+\zs.*$') 626 627 if entered_atruleafter =~ "([^)]*$" 628 let entered_atruleafter = matchstr(entered_atruleafter, '(\s*\zs.*$') 629 let values = s:values 630 else 631 let values = ["("] 632 endif 633 634 elseif atrulename == 'charset' 635 let entered_atruleafter = matchstr(line, '.*@charset\s\+\zs.*$') 636 let values = [ 637 \ '"UTF-8";', '"ANSI_X3.4-1968";', '"ISO_8859-1:1987";', '"ISO_8859-2:1987";', '"ISO_8859-3:1988";', '"ISO_8859-4:1988";', '"ISO_8859-5:1988";', 638 \ '"ISO_8859-6:1987";', '"ISO_8859-7:1987";', '"ISO_8859-8:1988";', '"ISO_8859-9:1989";', '"ISO-8859-10";', '"ISO_6937-2-add";', '"JIS_X0201";', 639 \ '"JIS_Encoding";', '"Shift_JIS";', '"Extended_UNIX_Code_Packed_Format_for_Japanese";', '"Extended_UNIX_Code_Fixed_Width_for_Japanese";', 640 \ '"BS_4730";', '"SEN_850200_C";', '"IT";', '"ES";', '"DIN_66003";', '"NS_4551-1";', '"NF_Z_62-010";', '"ISO-10646-UTF-1";', '"ISO_646.basic:1983";', 641 \ '"INVARIANT";', '"ISO_646.irv:1983";', '"NATS-SEFI";', '"NATS-SEFI-ADD";', '"NATS-DANO";', '"NATS-DANO-ADD";', '"SEN_850200_B";', '"KS_C_5601-1987";', 642 \ '"ISO-2022-KR";', '"EUC-KR";', '"ISO-2022-JP";', '"ISO-2022-JP-2";', '"JIS_C6220-1969-jp";', '"JIS_C6220-1969-ro";', '"PT";', '"greek7-old";', 643 \ '"latin-greek";', '"NF_Z_62-010_(1973)";', '"Latin-greek-1";', '"ISO_5427";', '"JIS_C6226-1978";', '"BS_viewdata";', '"INIS";', '"INIS-8";', 644 \ '"INIS-cyrillic";', '"ISO_5427:1981";', '"ISO_5428:1980";', '"GB_1988-80";', '"GB_2312-80";', '"NS_4551-2";', '"videotex-suppl";', '"PT2";', 645 \ '"ES2";', '"MSZ_7795.3";', '"JIS_C6226-1983";', '"greek7";', '"ASMO_449";', '"iso-ir-90";', '"JIS_C6229-1984-a";', '"JIS_C6229-1984-b";', 646 \ '"JIS_C6229-1984-b-add";', '"JIS_C6229-1984-hand";', '"JIS_C6229-1984-hand-add";', '"JIS_C6229-1984-kana";', '"ISO_2033-1983";', 647 \ '"ANSI_X3.110-1983";', '"T.61-7bit";', '"T.61-8bit";', '"ECMA-cyrillic";', '"CSA_Z243.4-1985-1";', '"CSA_Z243.4-1985-2";', '"CSA_Z243.4-1985-gr";', 648 \ '"ISO_8859-6-E";', '"ISO_8859-6-I";', '"T.101-G2";', '"ISO_8859-8-E";', '"ISO_8859-8-I";', '"CSN_369103";', '"JUS_I.B1.002";', '"IEC_P27-1";', 649 \ '"JUS_I.B1.003-serb";', '"JUS_I.B1.003-mac";', '"greek-ccitt";', '"NC_NC00-10:81";', '"ISO_6937-2-25";', '"GOST_19768-74";', '"ISO_8859-supp";', 650 \ '"ISO_10367-box";', '"latin-lap";', '"JIS_X0212-1990";', '"DS_2089";', '"us-dk";', '"dk-us";', '"KSC5636";', '"UNICODE-1-1-UTF-7";', '"ISO-2022-CN";', 651 \ '"ISO-2022-CN-EXT";', '"ISO-8859-13";', '"ISO-8859-14";', '"ISO-8859-15";', '"ISO-8859-16";', '"GBK";', '"GB18030";', '"OSD_EBCDIC_DF04_15";', 652 \ '"OSD_EBCDIC_DF03_IRV";', '"OSD_EBCDIC_DF04_1";', '"ISO-11548-1";', '"KZ-1048";', '"ISO-10646-UCS-2";', '"ISO-10646-UCS-4";', '"ISO-10646-UCS-Basic";', 653 \ '"ISO-10646-Unicode-Latin1";', '"ISO-10646-J-1";', '"ISO-Unicode-IBM-1261";', '"ISO-Unicode-IBM-1268";', '"ISO-Unicode-IBM-1276";', 654 \ '"ISO-Unicode-IBM-1264";', '"ISO-Unicode-IBM-1265";', '"UNICODE-1-1";', '"SCSU";', '"UTF-7";', '"UTF-16BE";', '"UTF-16LE";', '"UTF-16";', '"CESU-8";', 655 \ '"UTF-32";', '"UTF-32BE";', '"UTF-32LE";', '"BOCU-1";', '"ISO-8859-1-Windows-3.0-Latin-1";', '"ISO-8859-1-Windows-3.1-Latin-1";', 656 \ '"ISO-8859-2-Windows-Latin-2";', '"ISO-8859-9-Windows-Latin-5";', '"hp-roman8";', '"Adobe-Standard-Encoding";', '"Ventura-US";', 657 \ '"Ventura-International";', '"DEC-MCS";', '"IBM850";', '"PC8-Danish-Norwegian";', '"IBM862";', '"PC8-Turkish";', '"IBM-Symbols";', '"IBM-Thai";', 658 \ '"HP-Legal";', '"HP-Pi-font";', '"HP-Math8";', '"Adobe-Symbol-Encoding";', '"HP-DeskTop";', '"Ventura-Math";', '"Microsoft-Publishing";', 659 \ '"Windows-31J";', '"GB2312";', '"Big5";', '"macintosh";', '"IBM037";', '"IBM038";', '"IBM273";', '"IBM274";', '"IBM275";', '"IBM277";', '"IBM278";', 660 \ '"IBM280";', '"IBM281";', '"IBM284";', '"IBM285";', '"IBM290";', '"IBM297";', '"IBM420";', '"IBM423";', '"IBM424";', '"IBM437";', '"IBM500";', '"IBM851";', 661 \ '"IBM852";', '"IBM855";', '"IBM857";', '"IBM860";', '"IBM861";', '"IBM863";', '"IBM864";', '"IBM865";', '"IBM868";', '"IBM869";', '"IBM870";', '"IBM871";', 662 \ '"IBM880";', '"IBM891";', '"IBM903";', '"IBM904";', '"IBM905";', '"IBM918";', '"IBM1026";', '"EBCDIC-AT-DE";', '"EBCDIC-AT-DE-A";', '"EBCDIC-CA-FR";', 663 \ '"EBCDIC-DK-NO";', '"EBCDIC-DK-NO-A";', '"EBCDIC-FI-SE";', '"EBCDIC-FI-SE-A";', '"EBCDIC-FR";', '"EBCDIC-IT";', '"EBCDIC-PT";', '"EBCDIC-ES";', 664 \ '"EBCDIC-ES-A";', '"EBCDIC-ES-S";', '"EBCDIC-UK";', '"EBCDIC-US";', '"UNKNOWN-8BIT";', '"MNEMONIC";', '"MNEM";', '"VISCII";', '"VIQR";', '"KOI8-R";', 665 \ '"HZ-GB-2312";', '"IBM866";', '"IBM775";', '"KOI8-U";', '"IBM00858";', '"IBM00924";', '"IBM01140";', '"IBM01141";', '"IBM01142";', '"IBM01143";', 666 \ '"IBM01144";', '"IBM01145";', '"IBM01146";', '"IBM01147";', '"IBM01148";', '"IBM01149";', '"Big5-HKSCS";', '"IBM1047";', '"PTCP154";', '"Amiga-1251";', 667 \ '"KOI7-switched";', '"BRF";', '"TSCII";', '"windows-1250";', '"windows-1251";', '"windows-1252";', '"windows-1253";', '"windows-1254";', '"windows-1255";', 668 \ '"windows-1256";', '"windows-1257";', '"windows-1258";', '"TIS-620";'] 669 670 elseif atrulename == 'namespace' 671 let entered_atruleafter = matchstr(line, '.*@namespace\s\+\zs.*$') 672 let values = ["url("] 673 674 elseif atrulename == 'document' 675 let entered_atruleafter = matchstr(line, '.*@document\s\+\zs.*$') 676 let values = ["url(", "url-prefix(", "domain(", "regexp("] 677 678 elseif atrulename == 'import' 679 let entered_atruleafter = matchstr(line, '.*@import\s\+\zs.*$') 680 681 if entered_atruleafter =~ "^[\"']" 682 let filestart = matchstr(entered_atruleafter, '^.\zs.*') 683 let files = split(glob(filestart.'*'), '\n') 684 let values = map(copy(files), '"\"".v:val') 685 686 elseif entered_atruleafter =~ "^url(" 687 let filestart = matchstr(entered_atruleafter, "^url([\"']\\?\\zs.*") 688 let files = split(glob(filestart.'*'), '\n') 689 let values = map(copy(files), '"url(".v:val') 690 691 else 692 let values = ['"', 'url('] 693 694 endif 695 696 else 697 return [] 698 699 endif 700 701 for m in values 702 if m =~? '^'.entered_atruleafter 703 if entered_atruleafter =~? '^"' && m =~? '^"' 704 let m = m[1:] 705 endif 706 if b:after =~? '"' && stridx(m, '"') > -1 707 let m = m[0:stridx(m, '"')-1] 708 endif 709 call add(res, m) 710 elseif m =~? entered_atruleafter 711 if m =~? '^"' 712 let m = m[1:] 713 endif 714 call add(res2, m) 715 endif 716 endfor 717 718 return res + res2 719 720 endif 721 722 let values = ["charset", "page", "media", "import", "font-face", "namespace", "supports", "keyframes", "viewport", "document"] 723 724 let entered_atrule = matchstr(line, '.*@\zs[a-zA-Z-]*$') 725 726 for m in values 727 if m =~? '^'.entered_atrule 728 call add(res, m .' ') 729 elseif m =~? entered_atrule 730 call add(res2, m .' ') 731 endif 732 endfor 733 734 return res + res2 735 736 endif 737 738 return [] 739 740endfunction 741