diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | autoload/stylcomplete.vim | 578 | ||||
-rw-r--r-- | ftplugin/stylus.vim | 10 | ||||
-rw-r--r-- | indent/stylus.vim | 95 | ||||
-rw-r--r-- | packages.yaml | 2 | ||||
-rw-r--r-- | syntax/stylus.vim | 1206 |
6 files changed, 1468 insertions, 425 deletions
@@ -174,7 +174,7 @@ On top of all language packs from [vim repository](https://github.com/vim/vim/tr - [slime](https://github.com/slime-lang/vim-slime-syntax) (Syntax highlighting for slime files) - [smt2](https://github.com/bohlender/vim-smt2) (SMT syntax highlighting for smt2 and smt files) - [solidity](https://github.com/tomlion/vim-solidity) (Solidity syntax highlighting for sol files) -- [stylus](https://github.com/wavded/vim-stylus) (Stylus syntax highlighting for styl and stylus files) +- [stylus](https://github.com/iloginow/vim-stylus) (Stylus syntax highlighting for styl and stylus files) - [svelte](https://github.com/evanleck/vim-svelte/tree/main) (Svelte syntax highlighting for svelte files) - [svg-indent](https://github.com/jasonshell/vim-svg-indent) - [svg](https://github.com/vim-scripts/svg.vim) (SVG syntax highlighting for svg files) diff --git a/autoload/stylcomplete.vim b/autoload/stylcomplete.vim new file mode 100644 index 00000000..7437d32b --- /dev/null +++ b/autoload/stylcomplete.vim @@ -0,0 +1,578 @@ +if has_key(g:polyglot_is_disabled, 'stylus') + finish +endif + +" Vim completion script +" Language: Stylus +" Author: Ilia Loginov <i.loginow@outlook.com> +" Created: 2018 Jan 28 + +fun! stylcomplete#CompleteStyl(findstart, base) + + if a:findstart + let line = getline('.') + let start = col('.') - 1 + while start > 0 && line[start - 1] !~ '\(\s\|\[\|(\|{\|:\)' + let start -= 1 + endwhile + let b:start = line[start] + let b:before = line[start - 1] + let b:line = line[0:col('.')] + let b:first_char = matchstrpos(b:line, '^\s*\S')[2] + let b:first_word_type = synIDattr(synID(line('.'), b:first_char, 1), 'name') + " Check if there is more than one word on the current line + let b:word_break = 0 + if b:line =~ '^.*\S\(\s\|\[\|(\|{\|:\)\S.*' + let b:word_break = 1 + endif + return start + endif + + " Complete properties + if b:start =~ '\w' && b:word_break == 0 + let res = [] + for m in g:css_props + if m =~ '^' . a:base + call add(res, m) + endif + endfor + return res + + " Complete pseudo classes and elements + elseif b:before == ':' && b:first_word_type =~ 'stylusSelector\w*' + let values = ["active", "any", "any-link", "blank", "checked", "cue", "cue-region", "disabled", "enabled", "default", "dir(", "disabled", "drop", "drop(", "empty", "enabled", "first", "first-child", "first-of-type", "fullscreen", "future", "focus", "focus-within", "has(", "hover", "indeterminate", "in-range", "invalid", "lang(", "last-child", "last-of-type", "left", "link", "matches(", "not(", "nth-child(", "nth-column(", "nth-last-child(", "nth-last-column(", "nth-last-of-type(", "nth-of-type(", "only-child", "only-of-type", "optional", "out-of-range", "past", "paused", "placeholder-shown", "playing", "read-only", "read-write", "required", "right", "root", "scope", "target", "user-invalid", "valid", "visited", "first-line", "first-letter", "before", "after", "selection", "backdrop"] + + let res = [] + for m in values + if m =~ '^' . a:base + call add(res, m) + endif + endfor + return res + + " Complete !important and !optional + elseif b:start == '!' && b:word_break == 1 && b:first_word_type == 'stylusProperty' + let values = ["important", "optional"] + + let res = [] + for m in values + if m =~ '^' . a:base + call add(res, m) + endif + endfor + return res + + " Complete values + elseif b:start =~ '\w' && b:word_break == 1 && b:first_word_type == 'stylusProperty' + let prop = matchstr(b:line, '\(^\s\+\)\@<=\<\(\w\|-\)\+\>') + let res = [] + + let wide_keywords = ["initial", "inherit", "unset"] + let color_values = ["transparent", "rgb(", "rgba(", "hsl(", "hsla(", "#"] + g:css_colors + let border_style_values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"] + let border_width_values = ["thin", "thick", "medium"] + 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"] + let timing_functions = ["cubic-bezier(", "steps(", "linear", "ease", "ease-in", "ease-in-out", "ease-out", "step-start", "step-end"] + + if prop == 'all' + + let values = [] + elseif prop == 'additive-symbols' + let values = [] + elseif prop == 'align-content' + let values = ["flex-start", "flex-end", "center", "space-between", "space-around", "stretch"] + elseif prop == 'align-items' + let values = ["flex-start", "flex-end", "center", "baseline", "stretch"] + elseif prop == 'align-self' + let values = ["auto", "flex-start", "flex-end", "center", "baseline", "stretch"] + elseif prop == 'animation' + let values = timing_functions + ["normal", "reverse", "alternate", "alternate-reverse"] + ["none", "forwards", "backwards", "both"] + ["running", "paused"] + elseif prop == 'animation-delay' + let values = [] + elseif prop == 'animation-direction' + let values = ["normal", "reverse", "alternate", "alternate-reverse"] + elseif prop == 'animation-duration' + let values = [] + elseif prop == 'animation-fill-mode' + let values = ["none", "forwards", "backwards", "both"] + elseif prop == 'animation-iteration-count' + let values = [] + elseif prop == 'animation-name' + let values = [] + elseif prop == 'animation-play-state' + let values = ["running", "paused"] + elseif prop == 'animation-timing-function' + let values = timing_functions + elseif prop == 'appearance' + let values = ["auto", "none"] + elseif prop == 'background-attachment' + let values = ["scroll", "fixed"] + elseif prop == 'background-color' + let values = color_values + elseif prop == 'background-image' + let values = ["url(", "none"] + elseif prop == 'background-position' + let vals = matchstr(b:line, '.*:\s*\zs.*') + if vals =~ '^\%([a-zA-Z]\+\)\?$' + let values = ["top", "center", "bottom"] + elseif vals =~ '^[a-zA-Z]\+\s\+\%([a-zA-Z]\+\)\?$' + let values = ["left", "center", "right"] + else + return [] + endif + elseif prop == 'background-repeat' + let values = ["repeat", "repeat-x", "repeat-y", "no-repeat"] + elseif prop == 'background-size' + let values = ["auto", "contain", "cover"] + elseif prop == 'background' + let values = ["scroll", "fixed"] + color_values + ["url(", "none"] + ["top", "center", "bottom", "left", "right"] + ["repeat", "repeat-x", "repeat-y", "no-repeat"] + ["auto", "contain", "cover"] + elseif prop =~ '^border\%(-top\|-right\|-bottom\|-left\|-block-start\|-block-end\)\?$' + let vals = matchstr(b:line, '.*:\s*\zs.*') + if vals =~ '^\%([a-zA-Z0-9.]\+\)\?$' + let values = border_width_values + elseif vals =~ '^[a-zA-Z0-9.]\+\s\+\%([a-zA-Z]\+\)\?$' + let values = border_style_values + elseif vals =~ '^[a-zA-Z0-9.]\+\s\+[a-zA-Z]\+\s\+\%([a-zA-Z(]\+\)\?$' + let values = color_values + else + return [] + endif + elseif prop =~ '^border-\%(top\|right\|bottom\|left\|block-start\|block-end\)-color' + let values = color_values + elseif prop =~ '^border-\%(top\|right\|bottom\|left\|block-start\|block-end\)-style' + let values = border_style_values + elseif prop =~ '^border-\%(top\|right\|bottom\|left\|block-start\|block-end\)-width' + let values = border_width_values + elseif prop == 'border-color' + let values = color_values + elseif prop == 'border-style' + let values = border_style_values + elseif prop == 'border-width' + let values = border_width_values + elseif prop == 'bottom' + let values = ["auto"] + elseif prop == 'box-decoration-break' + let values = ["slice", "clone"] + elseif prop == 'box-shadow' + let values = ["inset"] + elseif prop == 'box-sizing' + let values = ["border-box", "content-box"] + elseif prop =~ '^break-\%(before\|after\)' + let values = ["auto", "always", "avoid", "left", "right", "page", "column", "region", "recto", "verso", "avoid-page", "avoid-column", "avoid-region"] + elseif prop == 'break-inside' + let values = ["auto", "avoid", "avoid-page", "avoid-column", "avoid-region"] + elseif prop == 'caption-side' + let values = ["top", "bottom"] + elseif prop == 'clear' + let values = ["none", "left", "right", "both"] + elseif prop == 'clip' + let values = ["auto", "rect("] + elseif prop == 'clip-path' + let values = ["fill-box", "stroke-box", "view-box", "none"] + elseif prop == 'color' + let values = color_values + elseif prop == 'columns' + let values = [] + elseif prop == 'column-count' + let values = ['auto'] + elseif prop == 'column-fill' + let values = ['auto', 'balance'] + elseif prop == 'column-rule-color' + let values = color_values + elseif prop == 'column-rule-style' + let values = border_style_values + elseif prop == 'column-rule-width' + let values = border_width_values + elseif prop == 'column-rule' + let vals = matchstr(b:line, '.*:\s*\zs.*') + if vals =~ '^\%([a-zA-Z0-9.]\+\)\?$' + let values = border_width_values + elseif vals =~ '^[a-zA-Z0-9.]\+\s\+\%([a-zA-Z]\+\)\?$' + let values = border_style_values + elseif vals =~ '^[a-zA-Z0-9.]\+\s\+[a-zA-Z]\+\s\+\%([a-zA-Z(]\+\)\?$' + let values = color_values + else + return [] + endif + elseif prop == 'column-span' + let values = ["none", "all"] + elseif prop == 'column-width' + let values = ["auto"] + elseif prop == 'content' + let values = ["normal", "attr(", "open-quote", "close-quote", "no-open-quote", "no-close-quote"] + elseif prop =~ '^counter-\%(increment\|reset\)$' + let values = ["none"] + elseif prop =~ '^cue\%(-after\|-before\)\=$' + let values = ["url("] + elseif prop == 'cursor' + 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"] + elseif prop == 'direction' + let values = ["ltr", "rtl"] + elseif prop == 'display' + let values = ["inline", "block", "list-item", "run-in", "inline-block", "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", "inline-table", "inline-list-item", "ruby", "ruby-base", "ruby-text", "ruby-base-container", "ruby-text-container", "contents"] + elseif prop == 'elevation' + let values = ["below", "level", "above", "higher", "lower"] + elseif prop == 'empty-cells' + let values = ["show", "hide"] + elseif prop == 'fallback' + let values = list_style_type_values + elseif prop == 'filter' + let values = ["blur(", "brightness(", "contrast(", "drop-shadow(", "grayscale(", "hue-rotate(", "invert(", "opacity(", "sepia(", "saturate("] + elseif prop == 'flex-basis' + let values = ["auto", "content"] + elseif prop == 'flex-direction' + let values = ["row", "row-reverse", "column", "column-reverse"] + elseif prop == 'flex-flow' + let values = ["row", "row-reverse", "column", "column-reverse", "nowrap", "wrap", "wrap-reverse"] + elseif prop == 'flex-grow' + let values = [] + elseif prop == 'flex-shrink' + let values = [] + elseif prop == 'flex-wrap' + let values = ["nowrap", "wrap", "wrap-reverse"] + elseif prop == 'flex' + let values = ["nowrap", "wrap", "wrap-reverse"] + ["row", "row-reverse", "column", "column-reverse", "nowrap", "wrap", "wrap-reverse"] + ["auto", "content"] + elseif prop == 'float' + let values = ["left", "right", "none"] + elseif prop == 'font-display' + let values = ["auto", "block", "swap", "fallback", "optional"] + elseif prop == 'font-family' + let values = ["sans-serif", "serif", "monospace", "cursive", "fantasy", "system-ui", "emoji", "math", "fangsong"] + elseif prop == 'font-feature-settings' + 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"'] + elseif prop == 'font-kerning' + let values = ["auto", "normal", "none"] + elseif prop == 'font-language-override' + let values = ["normal"] + elseif prop == 'font-size' + let values = ["xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large", "larger", "smaller"] + elseif prop == 'font-size-adjust' + let values = [] + elseif prop == 'font-stretch' + let values = ["normal", "ultra-condensed", "extra-condensed", "condensed", "semi-condensed", "semi-expanded", "expanded", "extra-expanded", "ultra-expanded"] + elseif prop == 'font-style' + let values = ["normal", "italic", "oblique"] + elseif prop == 'font-synthesis' + let values = ["none", "weight", "style"] + elseif prop == 'font-variant-alternates' + let values = ["normal", "historical-forms", "stylistic(", "styleset(", "character-variant(", "swash(", "ornaments(", "annotation("] + elseif prop == 'font-variant-caps' + let values = ["normal", "small-caps", "all-small-caps", "petite-caps", "all-petite-caps", "unicase", "titling-caps"] + elseif prop == 'font-variant-asian' + let values = ["normal", "ruby", "jis78", "jis83", "jis90", "jis04", "simplified", "traditional"] + elseif prop == 'font-variant-ligatures' + let values = ["normal", "none", "common-ligatures", "no-common-ligatures", "discretionary-ligatures", "no-discretionary-ligatures", "historical-ligatures", "no-historical-ligatures", "contextual", "no-contextual"] + elseif prop == 'font-variant-numeric' + let values = ["normal", "ordinal", "slashed-zero", "lining-nums", "oldstyle-nums", "proportional-nums", "tabular-nums", "diagonal-fractions", "stacked-fractions"] + elseif prop == 'font-variant-position' + let values = ["normal", "sub", "super"] + elseif prop == 'font-variant' + 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"] + elseif prop == 'font-weight' + let values = ["normal", "bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900"] + elseif prop == 'font' + 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", "system-ui", "emoji", "math", "fangsong", "cursive", "fantasy", "caption", "icon", "menu", "message-box", "small-caption", "status-bar"] + elseif prop =~ '^\%(height\|width\)$' + let values = ["auto", "border-box", "content-box", "max-content", "min-content", "available", "fit-content"] + elseif prop =~ '^\%(left\|rigth\)$' + let values = ["auto"] + elseif prop == 'image-rendering' + let values = ["auto", "crisp-edges", "pixelated"] + elseif prop == 'image-orientation' + let values = ["from-image", "flip"] + elseif prop == 'ime-mode' + let values = ["auto", "normal", "active", "inactive", "disabled"] + elseif prop == 'inline-size' + let values = ["auto", "border-box", "content-box", "max-content", "min-content", "available", "fit-content"] + elseif prop == 'isolation' + let values = ["auto", "isolate"] + elseif prop == 'justify-content' + let values = ["flex-start", "flex-end", "center", "space-between", "space-around"] + elseif prop == 'letter-spacing' + let values = ["normal"] + elseif prop == 'line-break' + let values = ["auto", "loose", "normal", "strict"] + elseif prop == 'line-height' + let values = ["normal"] + elseif prop == 'list-style-image' + let values = ["url(", "none"] + elseif prop == 'list-style-position' + let values = ["inside", "outside"] + elseif prop == 'list-style-type' + let values = list_style_type_values + elseif prop == 'list-style' + let values = list_style_type_values + ["inside", "outside"] + ["url(", "none"] + elseif prop == 'margin' + let values = ["auto"] + elseif prop =~ '^margin-\%(right\|left\|top\|bottom\|block-start\|block-end\|inline-start\|inline-end\)$' + let values = ["auto"] + elseif prop == 'marks' + let values = ["crop", "cross", "none"] + elseif prop == 'mask' + let values = ["url("] + elseif prop == 'mask-type' + let values = ["luminance", "alpha"] + elseif prop == '\%(max\|min\)-\%(block\|inline\)-size' + let values = ["auto", "border-box", "content-box", "max-content", "min-content", "available", "fit-content"] + elseif prop == '\%(max\|min\)-\%(height\|width\)' + let values = ["auto", "border-box", "content-box", "max-content", "min-content", "available", "fit-content"] + elseif prop == '\%(max\|min\)-zoom' + let values = ["auto"] + elseif prop == 'mix-blend-mode' + let values = ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"] + elseif prop == 'object-fit' + let values = ['fill', 'contain', 'cover', 'scale-down'] + elseif prop == 'opacity' + let values = [] + elseif prop == 'orientation' + let values = ["auto", "portrait", "landscape"] + elseif prop == 'orphans' + let values = [] + elseif prop == 'outline-offset' + let values = [] + elseif prop == 'outline-color' + let values = color_values + elseif prop == 'outline-style' + let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"] + elseif prop == 'outline-width' + let values = ["thin", "thick", "medium"] + elseif prop == 'outline' + let vals = matchstr(b:line, '.*:\s*\zs.*') + if vals =~ '^\%([a-zA-Z0-9,()#]\+\)\?$' + let values = color_values + elseif vals =~ '^[a-zA-Z0-9,()#]\+\s\+\%([a-zA-Z]\+\)\?$' + let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"] + elseif vals =~ '^[a-zA-Z0-9,()#]\+\s\+[a-zA-Z]\+\s\+\%([a-zA-Z(]\+\)\?$' + let values = ["thin", "thick", "medium"] + else + return [] + endif + elseif prop == 'overflow-wrap' + let values = ["normal", "break-word"] + elseif prop =~ '^overflow\%(-x\|-y\)\=' + let values = ["visible", "hidden", "scroll", "auto"] + elseif prop == 'pad' + let values = [] + elseif prop == 'padding' + let values = [] + elseif prop =~ '^padding-\%(top\|right\|bottom\|left\|inline-start\|inline-end\|block-start\|block-end\)$' + let values = [] + elseif prop =~ '^page-break-\%(after\|before\)$' + let values = ["auto", "always", "avoid", "left", "right", "recto", "verso"] + elseif prop == 'page-break-inside' + let values = ["auto", "avoid"] + elseif prop =~ '^pause\%(-after\|-before\)\=$' + let values = ["none", "x-weak", "weak", "medium", "strong", "x-strong"] + elseif prop == 'perspective' + let values = ["none"] + elseif prop == 'perspective-origin' + let values = ["top", "bottom", "left", "center", " right"] + elseif prop == 'pointer-events' + let values = ["auto", "none", "visiblePainted", "visibleFill", "visibleStroke", "visible", "painted", "fill", "stroke", "all"] + elseif prop == 'position' + let values = ["static", "relative", "absolute", "fixed", "sticky"] + elseif prop == 'prefix' + let values = [] + elseif prop == 'quotes' + let values = ["none"] + elseif prop == 'range' + let values = ["auto", "infinite"] + elseif prop == 'resize' + let values = ["none", "both", "horizontal", "vertical"] + elseif prop =~ '^rest\%(-after\|-before\)\=$' + let values = ["none", "x-weak", "weak", "medium", "strong", "x-strong"] + elseif prop == 'ruby-align' + let values = ["start", "center", "space-between", "space-around"] + elseif prop == 'ruby-merge' + let values = ["separate", "collapse", "auto"] + elseif prop == 'ruby-position' + let values = ["over", "under", "inter-character"] + elseif prop == 'scroll-behavior' + let values = ["auto", "smooth"] + elseif prop == 'scroll-snap-coordinate' + let values = ["none"] + elseif prop == 'scroll-snap-destination' + return [] + elseif prop == 'scroll-snap-points-\%(x\|y\)$' + let values = ["none", "repeat("] + elseif prop == 'scroll-snap-type\%(-x\|-y\)\=$' + let values = ["none", "mandatory", "proximity"] + elseif prop == 'shape-image-threshold' + let values = [] + elseif prop == 'shape-margin' + let values = [] + elseif prop == 'shape-outside' + let values = ["margin-box", "border-box", "padding-box", "content-box", 'inset(', 'circle(', 'ellipse(', 'polygon(', 'url('] + elseif prop == 'speak' + let values = ["auto", "none", "normal"] + elseif prop == 'speak-as' + let values = ["auto", "normal", "spell-out", "digits"] + elseif prop == 'src' + let values = ["url("] + elseif prop == 'suffix' + let values = [] + elseif prop == 'symbols' + let values = [] + elseif prop == 'system' + let vals = matchstr(b:line, '.*:\s*\zs.*') + if vals =~ '^extends' + let values = list_style_type_values + else + let values = ["cyclic", "numeric", "alphabetic", "symbolic", "additive", "fixed", "extends"] + endif + elseif prop == 'table-layout' + let values = ["auto", "fixed"] + elseif prop == 'tab-size' + let values = [] + elseif prop == 'text-align' + let values = ["start", "end", "left", "right", "center", "justify", "match-parent"] + elseif prop == 'text-align-last' + let values = ["auto", "start", "end", "left", "right", "center", "justify"] + elseif prop == 'text-combine-upright' + let values = ["none", "all", "digits"] + elseif prop == 'text-decoration-line' + let values = ["none", "underline", "overline", "line-through", "blink"] + elseif prop == 'text-decoration-color' + let values = color_values + elseif prop == 'text-decoration-style' + let values = ["solid", "double", "dotted", "dashed", "wavy"] + elseif prop == 'text-decoration' + let values = ["none", "underline", "overline", "line-through", "blink"] + ["solid", "double", "dotted", "dashed", "wavy"] + color_values + elseif prop == 'text-emphasis-color' + let values = color_values + elseif prop == 'text-emphasis-position' + let values = ["over", "under", "left", "right"] + elseif prop == 'text-emphasis-style' + let values = ["none", "filled", "open", "dot", "circle", "double-circle", "triangle", "sesame"] + elseif prop == 'text-emphasis' + let values = color_values + ["over", "under", "left", "right"] + ["none", "filled", "open", "dot", "circle", "double-circle", "triangle", "sesame"] + elseif prop == 'text-indent' + let values = ["hanging", "each-line"] + elseif prop == 'text-orientation' + let values = ["mixed", "upright", "sideways", "sideways-right", "use-glyph-orientation"] + elseif prop == 'text-overflow' + let values = ["clip", "ellipsis", "fade", "fade("] + elseif prop == 'text-rendering' + let values = ["auto", "optimizeSpeed", "optimizeLegibility", "geometricPrecision"] + elseif prop == 'text-shadow' + let values = color_values + elseif prop == 'text-transform' + let values = ["capitalize", "uppercase", "lowercase", "full-width", "none"] + elseif prop == 'text-underline-position' + let values = ["auto", "under", "left", "right"] + elseif prop == 'touch-action' + let values = ["auto", "none", "pan-x", "pan-y", "manipulation", "pan-left", "pan-right", "pan-top", "pan-down"] + elseif prop == 'transform' + let values = ["matrix(", "translate(", "translateX(", "translateY(", "scale(", "scaleX(", "scaleY(", "rotate(", "skew(", "skewX(", "skewY(", "matrix3d(", "translate3d(", "translateZ(", "scale3d(", "scaleZ(", "rotate3d(", "rotateX(", "rotateY(", "rotateZ(", "perspective("] + elseif prop == 'transform-box' + let values = ["border-box", "fill-box", "view-box"] + elseif prop == 'transform-origin' + let values = ["left", "center", "right", "top", "bottom"] + elseif prop == 'transform-style' + let values = ["flat", "preserve-3d"] + elseif prop == 'top' + let values = ["auto"] + elseif prop == 'transition-property' + let values = ["all", "none"] + g:css_animatable_props + elseif prop == 'transition-duration' + let values = [] + elseif prop == 'transition-delay' + let values = [] + elseif prop == 'transition-timing-function' + let values = timing_functions + elseif prop == 'transition' + let values = ["all", "none"] + g:css_animatable_props + timing_functions + elseif prop == 'unicode-bidi' + let values = ["normal", "embed", "isolate", "bidi-override", "isolate-override", "plaintext"] + elseif prop == 'unicode-range' + let values = ["U+"] + elseif prop == 'user-select' + let values = ["auto", "text", "none", "contain", "all"] + elseif prop == 'user-zoom' + let values = ["zoom", "fixed"] + elseif prop == 'vertical-align' + let values = ["baseline", "sub", "super", "top", "text-top", "middle", "bottom", "text-bottom"] + elseif prop == 'visibility' + let values = ["visible", "hidden", "collapse"] + elseif prop == 'voice-volume' + let values = ["silent", "x-soft", "soft", "medium", "loud", "x-loud"] + elseif prop == 'voice-balance' + let values = ["left", "center", "right", "leftwards", "rightwards"] + elseif prop == 'voice-family' + let values = [] + elseif prop == 'voice-rate' + let values = ["normal", "x-slow", "slow", "medium", "fast", "x-fast"] + elseif prop == 'voice-pitch' + let values = ["absolute", "x-low", "low", "medium", "high", "x-high"] + elseif prop == 'voice-range' + let values = ["absolute", "x-low", "low", "medium", "high", "x-high"] + elseif prop == 'voice-stress' + let values = ["normal", "strong", "moderate", "none", "reduced "] + elseif prop == 'voice-duration' + let values = ["auto"] + elseif prop == 'white-space' + let values = ["normal", "pre", "nowrap", "pre-wrap", "pre-line"] + elseif prop == 'widows' + let values = [] + elseif prop == 'will-change' + let values = ["auto", "scroll-position", "contents"] + s:values + elseif prop == 'word-break' + let values = ["normal", "break-all", "keep-all"] + elseif prop == 'word-spacing' + let values = ["normal"] + elseif prop == 'word-wrap' + let values = ["normal", "break-word"] + elseif prop == 'writing-mode' + let values = ["horizontal-tb", "vertical-rl", "vertical-lr", "sideways-rl", "sideways-lr"] + elseif prop == 'z-index' + let values = ["auto"] + elseif prop == 'zoom' + let values = ["auto"] + else + let values = wide_keywords + endif + + let values = values + wide_keywords + + for m in values + if m =~ '^' . a:base + call add(res, m) + endif + endfor + return res + + " Complete @-rules + + elseif b:start =~ '\w' && b:word_break == 1 && b:first_word_type == 'stylusAtRuleMedia' + + let values = ["min-width", "min-height", "max-width", "max-height"] + + let res = [] + + for m in values + if m =~ '^' . a:base + call add(res, m . ': ') + endif + endfor + + return res + + elseif b:start == '@' + + let values = ["@media", "@import", "@extend", "@block", "@charset", "@page", "@font-face", "@namespace", "@supports", "@keyframes", "@viewport", "@document", "@css"] + + let res = [] + + for m in values + if m =~ '^' . a:base + call add(res, m .' ') + endif + endfor + + return res + + endif + + return [] + +endfun diff --git a/ftplugin/stylus.vim b/ftplugin/stylus.vim index 9d859939..d0b49d36 100644 --- a/ftplugin/stylus.vim +++ b/ftplugin/stylus.vim @@ -4,8 +4,8 @@ endif " Vim filetype plugin " Language: Stylus -" Maintainer: Marc Harter -" Credits: Tim Pope +" Maintainer: Ilia Loginov +" Credits: Marc Harter, Tim Pope " Only do this when not done yet for this buffer if exists("b:did_ftplugin") @@ -47,14 +47,14 @@ if exists("loaded_matchit") let b:match_words = s:match_words endif -setlocal comments= commentstring=//\ %s - setlocal suffixesadd=.styl " Add '-' and '#' to the what makes up a keyword. " This means that 'e' and 'w' work properly now, for properties " and valid variable names. -setl iskeyword+=#,- +setlocal iskeyword+=#,- + +setlocal omnifunc=stylcomplete#CompleteStyl let b:undo_ftplugin = "setl cms< com< " \ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin diff --git a/indent/stylus.vim b/indent/stylus.vim index 9f506e2f..eeb3fa0d 100644 --- a/indent/stylus.vim +++ b/indent/stylus.vim @@ -4,21 +4,21 @@ endif " Vim indent file " Language: Stylus -" Maintainer: Marc Harter -" Last Change: 2010 May 21 +" Maintainer: Ilia Loginov +" Last Change: 2018 Jan 19 " Based On: sass.vim from Tim Pope -" + if exists("b:did_indent") finish endif -unlet! b:did_indent let b:did_indent = 1 setlocal indentexpr=GetStylusIndent() -setlocal indentkeys=o,O,*<Return>,},],0),!^F +setlocal autoindent nolisp nosmartindent +setlocal indentkeys=o,O,*<Return>,0),!^F setlocal formatoptions+=r -if exists("*GetStylusIndent") " only define once +if exists('*GetStylusIndent') finish endif @@ -43,45 +43,7 @@ function s:prevnonblanknoncomment(lnum) return lnum endfunction -function s:count_braces(lnum, count_open) - let n_open = 0 - let n_close = 0 - let line = getline(a:lnum) - let pattern = '[{}]' - let i = match(line, pattern) - while i != -1 - if synIDattr(synID(a:lnum, i + 1, 0), 'name') !~ 'css\%(Comment\|StringQ\{1,2}\)' - if line[i] == '{' - let n_open += 1 - elseif line[i] == '}' - if n_open > 0 - let n_open -= 1 - else - let n_close += 1 - endif - endif - endif - let i = match(line, pattern, i + 1) - endwhile - return a:count_open ? n_open : n_close -endfunction - -" function CheckCSSIndent() -" let line = getline(v:lnum) -" if line =~ '^\s*\*' -" return cindent(v:lnum) -" endif -" -" let pnum = s:prevnonblanknoncomment(v:lnum - 1) -" if pnum == 0 -" return 0 -" endif -" -" return indent(pnum) + s:count_braces(pnum, 1) * &sw -" \ - s:count_braces(v:lnum, 0) * &sw -" endfunction - -function! GetStylusIndent() +function GetStylusIndent() let line = getline(v:lnum) if line =~ '^\s*\*' return cindent(v:lnum) @@ -92,42 +54,41 @@ function! GetStylusIndent() return 0 endif - let lnum = prevnonblank(v:lnum-1) + let lnum = prevnonblank(v:lnum-1) if lnum == 0 return 0 endif let pline = getline(pnum) - if pline =~ '[}{]' - return indent(pnum) + s:count_braces(pnum, 1) * &sw - s:count_braces(v:lnum, 0) * &sw - endif - - let line = substitute(getline(lnum),'[\s()]\+$','','') " get last line strip ending whitespace - let cline = substitute(substitute(getline(v:lnum),'\s\+$','',''),'^\s\+','','') " get current line, trimmed - let lastcol = strlen(line) " get last col in prev line - let line = substitute(line,'^\s\+','','') " then remove preceeding whitespace - let indent = indent(lnum) " get indent on prev line - let cindent = indent(v:lnum) " get indent on current line - let increase = indent + &sw " increase indent by the shift width + " Get last line strip ending whitespace + let line = substitute(getline(lnum),'[\s()]\+$','','') + " Get current line, trimmed + let cline = substitute(substitute(getline(v:lnum),'\s\+$','',''),'^\s\+','','') + " Get last col in prev line + let lastcol = strlen(line) + " Then remove preceeding whitespace + let line = substitute(line,'^\s\+','','') + " Get indent on prev line + let indent = indent(lnum) + " Get indent on current line + let cindent = indent(v:lnum) + " Increase indent by the shift width + let increase = indent + &sw if indent == indent(lnum) let indent = cindent <= indent ? indent : increase endif - let group = synIDattr(synID(lnum,lastcol,1),'name') + let group = synIDattr(synID(lnum, cindent + 1, 1), 'name') - " for debugging only - echo group - - " if group !~? 'css.*' && line =~? ')\s*$' " match user functions - " return increase - if group =~? '\v^%(cssTagName|cssClassName|cssIdentifier|cssSelectorOp|cssSelectorOp2|cssBraces|cssAttributeSelector|cssPseudo|stylusId|stylusClass)$' + if group =~ 'stylusSelector\w*' + return increase + elseif group =~ 'stylusAtRule\(Viewport\|Page\|Supports\|Document\|Font\|Keyframes\)\w*' return increase - elseif (group == 'stylusUserFunction') && (indent(lnum) == '0') " mixin definition + " Mixin or function definition + elseif group =~ 'stylusFunction\w*' && indent(lnum) == 0 return increase else return indent endif endfunction - -" vim:set sw=2; diff --git a/packages.yaml b/packages.yaml index a4dc4717..9f307446 100644 --- a/packages.yaml +++ b/packages.yaml @@ -1563,7 +1563,7 @@ filetypes: - sol --- name: stylus -remote: wavded/vim-stylus +remote: iloginow/vim-stylus filetypes: - name: stylus linguist: Stylus diff --git a/syntax/stylus.vim b/syntax/stylus.vim index 9b3008af..d66a6037 100644 --- a/syntax/stylus.vim +++ b/syntax/stylus.vim @@ -3,378 +3,882 @@ if has_key(g:polyglot_is_disabled, 'stylus') endif " Vim syntax file -" Language: CSS3 -" Maintainer: Hsiaoming Yang <lepture@me.com> -" URL: http://lepture.me/work/css3/ -" Created: Dec 14, 2011 -" Modified: Sep 4, 2012 - -" For version 5.x: Clear all syntax items -" For version 6.x: Quit when a syntax file was already loaded +" Language: Stylus +" Author: Ilia Loginov <iloginow@outlook.com> +" Created: Jan 5, 2018 + if !exists("main_syntax") - if version < 600 - syntax clear - elseif exists("b:current_syntax") + if exists("b:current_syntax") finish endif - let main_syntax = 'css' + let main_syntax = 'stylus' endif -syn case ignore -syn region cssString start='"' end='"' contained -syn region cssString start="'" end="'" contained - -" HTML4 tags -syn keyword cssTagName abbr acronym address applet area base a b -syn keyword cssTagName basefont bdo big blockquote body button br -syn keyword cssTagName caption cite code col colgroup dd del -syn keyword cssTagName dfn dir div dl dt em fieldset form frame -syn keyword cssTagName frameset h1 h2 h3 h4 h5 h6 head hr html img i -syn keyword cssTagName iframe img input ins isindex kbd label legend li -syn keyword cssTagName link map menu meta noframes noscript ol optgroup -syn keyword cssTagName option p param pre q s samp script select -syn keyword cssTagName span strike strong style sub sup tbody td -syn keyword cssTagName textarea tfoot th thead title tr tt ul u var -syn match cssTagName "\*" -syn match cssTagName /\<table\>/ -syn match cssTagName /\<small\>/ -syn match cssTagName /\<center\>/ -" HTML5 tags -syn keyword cssTagName article aside audio bb canvas command datagrid -syn keyword cssTagName datalist details dialog embed figure footer figcaption -syn keyword cssTagName header hgroup keygen mark meter nav output -syn keyword cssTagName progress time rt rp section time video -syn match cssTagName /\<ruby\>/ -" class select -syn match cssSelector /\.[A-Za-z][A-Za-z0-9_-]\+/ -" id select -syn match cssSelector /#[A-Za-z][A-Za-z0-9_-]\+/ -syn region cssSelector start='\[' end='\]' contains=cssString - -syn region cssDefineBlock start="{" end="}" transparent contains=TOP - -syn keyword cssCommonVal inherit initial auto both normal hidden none medium contained - - -" Comment -syn keyword cssTodo FIXME TODO contained -syn region cssComment start="/\*" end="\*/" contains=cssTodo -syn match cssImportant "!\s*important\>" contained - -syn match cssValueInteger "[-+]\=\d\+" contained -syn match cssValueNumber "[-+]\=\d\+\(\.\d*\)\=" -syn match cssValueLength "[-+]\=\d\+\(\.\d*\)\=\(%\|mm\|cm\|in\|pt\|pc\|em\|ex\|px\|rem\|vh\|vw\|vm\|fr\|gr\)" contained -syn match cssValueAngle "[-+]\=\d\+\(\.\d*\)\=\(deg\|grad\|rad\|turn\)" contained -syn match cssValueTime "+\=\d\+\(\.\d*\)\=\(ms\|s\)" contained -syn match cssValueFrequency "+\=\d\+\(\.\d*\)\=\(Hz\|kHz\)" contained - - -" Properties http://www.w3.org/community/webed/wiki/CSS/Properties -" background http://www.w3.org/TR/css3-background/ -syn match cssBackgroundProp /\(background-\(color\|image\|repeat\|attachment\|position\)\|background\)/ contained -syn match cssBackgroundProp /background-\(origin\|\(repeat\|position\)-[xy]\|clip\|size\)/ contained -syn match cssBackgroundProp /object-\(fit\|position\)/ contained -" http://www.evotech.net/blog/2010/02/css3-properties-values-browser-support/ -syn keyword cssBackgroundVal tb lr rl snap cover contain widthLength heightLength contained -syn match cssBackgroundVal /\(scale-down\|from-image\)/ contained -syn match cssBackgroundVal /repeat-[xy]/ contained -syn match cssBackgroundVal /no-repeat/ contained -syn keyword cssBackgroundVal circle ellipse to at contained -syn match cssBackgroundVal /\(closest\|farthest\)-\(side\|corner\)/ contained - -syn region cssFuncVal start="\(url\|calc\|min\|max\|counter\|cycle(\)" end=")" oneline contained contains=cssString,cssValueLength,cssValueInteger,cssValueNumber,cssValueAngle,cssValueTime,cssValueFrequency -syn region cssFuncVal start="\(linear\|radial\|repeating-linear\|repeating-radial\)-gradient(" end=")" oneline contained contains=cssString,cssValueLength,cssValueInteger,cssValueNumber,cssValueAngle,cssValueTime,cssValueFrequency,cssVisualProp,cssColorVal - -syn match cssBorderProp /\(border-\(color\|style\|width\|radius\)\|border\)/ contained -syn match cssBorderProp /border-\(image-\(source\|slice\|width\|outset\|repeat\)\|image\)/ contained -syn match cssBorderProp /border-\(\(top\|right\|bottom\|left\)-\(color\|style\|width\)\|\(top\|right\|bottom\|left\)\)/ contained -syn match cssBorderProp /border-\(top\|bottom\)-\(left\|right\)-radius/ contained -syn keyword cssBorderVal dotted dashed solid double groove ridge inset outset contained -syn match cssBorderVal /\<collapse\>/ contained -syn match cssBorderVal /\<separate\>/ contained -syn match cssBorderVal /\<fill\>/ contained - -" Font -syn match cssFontProp /\(font-\(family\|style\|variant\|weight\|size-adjust\|size\|stretch\)\|font\)/ contained -syn match cssFontVal /\(sans-serif\|small-caps\)/ contained -syn match cssFontVal /\<x\{1,2\}-\(large\|small\)\>/ contained -syn keyword cssFontVal cursive fantasy monospace italic oblique serif contained -syn keyword cssFontVal bold bolder lighter larger smaller contained -syn keyword cssFontVal icon narrower wider contained - -" Color -syn match cssColorVal /transparent/ contained -syn match cssColorVal "#[0-9A-Fa-f]\{3\}\>" contained -syn match cssColorVal "#[0-9A-Fa-f]\{6\}\>" contained -syn match cssFuncVal /rgb(\(\d\{1,3\}\s*,\s*\)\{2\}\d\{1,3\})/ contained contains=cssString,cssValueLength,cssValueInteger,cssValueNumber,cssValueAngle,cssValueTime,cssValueFrequency -syn match cssFuncVal /rgba(\(\d\{1,3\}\s*,\s*\)\{3\}\(1\|0\(\.\d\+\)\?\))/ contained contains=cssString,cssValueLength,cssValueInteger,cssValueNumber,cssValueAngle,cssValueTime,cssValueFrequency -syn match cssFuncVal /hsl(\d\{1,3\}\s*,\s*\(100\|\d\{1,2\}\(\.\d\+\)\?\)%\s*,\s*\(100\|\d\{1,2\}\(\.\d\+\)\?\)%)/ contained contains=cssString,cssValueLength,cssValueInteger,cssValueNumber,cssValueAngle,cssValueTime,cssValueFrequency -syn match cssFuncVal /hsla(\d\{1,3\}\s*,\s*\(\(100\|\d\{1,2\}\(\.\d\+\)\?\)%\s*,\s*\)\{2\}\(1\|0\(\.\d\+\)\?\))/ contained contains=cssString,cssValueLength,cssValueInteger,cssValueNumber,cssValueAngle,cssValueTime,cssValueFrequency -syn keyword cssColorVal aliceblue antiquewhite aqua aquamarine azure contained -syn keyword cssColorVal beige bisque black blanchedalmond blue blueviolet brown burlywood contained -syn keyword cssColorVal cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan contained -syn match cssColorVal /dark\(blue\|cyan\|goldenrod\|gray\|green\|grey\|khaki\)/ contained -syn match cssColorVal /dark\(magenta\|olivegreen\|orange\|orchid\|red\|salmon\|seagreen\)/ contained -syn match cssColorVal /darkslate\(blue\|gray\|grey\)/ contained -syn match cssColorVal /dark\(turquoise\|violet\)/ contained -syn keyword cssColorVal deeppink deepskyblue dimgray dimgrey dodgerblue firebrick contained -syn keyword cssColorVal floralwhite forestgreen fuchsia gainsboro ghostwhite gold contained -syn keyword cssColorVal goldenrod gray green greenyellow grey honeydew hotpink contained -syn keyword cssColorVal indianred indigo ivory khaki lavender lavenderblush lawngreen contained -syn keyword cssColorVal lemonchiffon lime limegreen linen magenta maroon contained -syn match cssColorVal /light\(blue\|coral\|cyan\|goldenrodyellow\|gray\|green\)/ contained -syn match cssColorVal /light\(grey\|pink\|salmon\|seagreen\|skyblue\|yellow\)/ contained -syn match cssColorVal /light\(slategray\|slategrey\|steelblue\)/ contained -syn match cssColorVal /medium\(aquamarine\|blue\|orchid\|purple\|seagreen\)/ contained -syn match cssColorVal /medium\(slateblue\|springgreen\|turquoise\|violetred\)/ contained -syn keyword cssColorVal midnightblue mintcream mistyrose moccasin navajowhite contained -syn keyword cssColorVal navy oldlace olive olivedrab orange orangered orchid contained -syn match cssColorVal /pale\(goldenrod\|green\|turquoise\|violetred\)/ contained -syn keyword cssColorVal papayawhip peachpuff peru pink plum powderblue purple contained -syn keyword cssColorVal red rosybrown royalblue saddlebrown salmon sandybrown contained -syn keyword cssColorVal seagreen seashell sienna silver skyblue slateblue contained -syn keyword cssColorVal slategray slategrey snow springgreen steelblue tan contained -syn keyword cssColorVal teal thistle tomato turquoise violet wheat contained -syn keyword cssColorVal whitesmoke yellow yellowgreen contained -syn match cssColorVal "\<white\>" contained -syn keyword cssColorProp color opaticy contained -syn match cssColorProp /color-profile/ contained - -" Box -syn match cssBoxProp /\(\(margin\|padding\)-\(top\|right\|bottom\|left\)\|\(margin\|padding\)\)/ contained -syn match cssBoxProp /\(min\|max\)-\(width\|height\)/ contained -syn match cssBoxProp /box-\(align\|decoration-break\|direction\|flex-group\|flex\|lines\)/ contained -syn match cssBoxProp /box-\(ordinal-group\|orient\|pack\|shadow\|sizing\)/ contained -syn match cssBoxProp /\(outline-\(color\|offset\|style\|width\)\|outline\)/ contained -syn keyword cssBoxProp width height contained - -" Text -syn match cssTextProp /text-\(align-last\|align\|decoration\|emphasis\|height\|indent\|justify\|outline\|shadow\|transform\|wrap\|overflow\)\|text/ contained -syn match cssTextProp /\(line-stacking-\(ruby\|shift\|strategy\)\|line-stacking\|line-height\)/ contained -syn match cssTextProp /vertical-align/ contained -syn match cssTextProp /letter-spacing/ contained -syn match cssTextProp /user-select/ contained -syn match cssTextProp /white-\(space-collapse\|space\)/ contained -syn match cssTextProp /word-\(break\|spacing\|wrap\)/ contained -syn match cssTextProp "\<word-wrap\>" contained -syn match cssTextVal "\<break-word\>" contained -syn match cssTextVal "\<break-all\>" contained -syn match cssTextVal "\<line-through\>" contained -syn match cssTextVal /text-\(top\|bottom\)/ contained -syn keyword cssTextVal uppercase lowercase ellipsis middle contained - -" List -syn match cssListProp /\(list-style-\(type\|image\|position\)\|list-style\)/ contained -syn keyword cssListVal armenian circle disc georgian hebrew square contained -syn match cssListVal /cjk-ideographic/ contained -syn match cssListVal /\(decimal-leading-zero\|decimal\)/ contained -syn match cssListVal /\(\(hiragana\|katakana\)-iroha\|\(hiragana\|katakana\)\)/ contained -syn match cssListVal /\(lower\|upper\)-\(alpha\|latin\|roman\)/ contained -syn match cssListVal /lower-greek/ contained - -" Visual formatting -syn keyword cssVisualProp display position top right bottom left float clear clip contained -syn keyword cssVisualProp zoom visibility cursor direction outline resize contained -syn keyword cssVisualProp opacity contained -syn match cssVisualProp /z-index/ contained -syn match cssVisualProp /\(overflow-\(style\|[xy]\)\|overflow\)/ contained -syn keyword cssVisualVal inline block compact contained -syn match cssVisualVal '\<table\>' contained -syn match cssVisualVal /\(inline-\(block\|table\)\|list-item\|run-in\)/ contained -syn match cssVisualVal /table-\(row-group\|header-group\|footer-group\|row\|column-group\|column\|cell\|caption\)/ contained -syn match cssVisualVal /\<ruby\>-\(base-group\|text-group\|base\|text\)/ contained -syn keyword cssVisualVal static relative absolute fixed contained -syn keyword cssVisualVal ltr rtl embed bidi-override pre nowrap contained -syn keyword cssVisualVal crosshair help move pointer progress wait contained -syn keyword cssVisualVal e-resize n-resize ne-resize nw-resize s-resize se-resize sw-resize w-resize contained - -" Table -syn match cssTableProp /border-\(collapse\|spacing\)/ contained -syn match cssTableProp /\(table-layout\|caption-side\|empty-cells\)/ contained - -" Generated content -syn match cssCommonProp /counter-\(reset\|increment\)/ contained -syn keyword cssCommonProp content quotes contained - -" Print -syn match cssPrintProp /break-\(before\|after\|inside\)/ -syn match cssPrintProp /\(page-break-\(before\|after\|inside\)\|page-policy\)/ -syn keyword cssPrintProp orphans windows - -" special keywords -syn match cssSpecialProp /-\(webkit\|moz\|ms\|o\)-/ -syn match cssRuleProp /@\(media\|font-face\|charset\|import\|page\|namespace\)/ -" http://www.w3.org/TR/selectors/ -syn match cssPseudo /:\(link\|visited\|active\|hover\|focus\|before\|after\)/ -syn match cssPseudo /:\(target\|lang\|enabled\|disabled\|checked\|indeterminate\)/ -syn match cssPseudo /:\(root\|\(first\|last\|only\)-\(child\|of-type\)\|empty\)/ -syn match cssPseudo /:\(nth-last-\|nth-\)\(child\|of-type\)(\<\S\+\>)/ -syn match cssPseudo /:not(\<\S*\>)/ -syn match cssPseudo /:first-\(line\|letter\)/ -syn match cssPseudo /::\(first-\(line\|letter\)\|before\|after\|selection\)/ - -" CSS3 Advanced http://meiert.com/en/indices/css-properties/ -syn keyword cssAdvancedProp appearance azimuth binding bleed columns crop hyphens icon -syn keyword cssAdvancedProp phonemes resize richness size volumne -syn match cssAdvancedProp /\(animation-\(delay\|direction\|duration\|name\|iteration-count\|play-state\|timing-function\)\|animation\)/ -syn match cssAdvancedProp /alignment-\(adjust\|baseline\)/ -syn match cssAdvancedProp /\(backface-visibility\baseline-shift\)/ -syn match cssAdvancedProp /bookmark-\(label\|level\|state\|target\)/ -syn match cssAdvancedProp /column-\(count\|fill\|gap\|rule-\(color\|style\|width\)\|rule\|span\|width\)/ -syn match cssAdvancedProp /\(cue-\(after\|before\)\|cue\)/ -syn match cssAdvancedProp /dominant-baseline/ -syn match cssAdvancedProp /drop-initial-\(size\|value\|\(after\|before\)-\(adjust\|align\)\)/ -syn match cssAdvancedProp /\(fit-position\|fit\)/ -syn match cssAdvancedProp /\(float-offset\|hanging-punctuation\)/ -syn match cssAdvancedProp /grid-\(columns\|rows\)/ -syn match cssAdvancedProp /hyphenate-\(after\|before\|character\|lines\|resource\)/ -syn match cssAdvancedProp /image-\(orientation\|rendering\|resolution\)/ -syn match cssAdvancedProp /inline-box-align/ -syn match cssAdvancedProp /\(mark-\(after\|before\)\|mark\|marks\)/ -syn match cssAdvancedProp /marquee-\(direction\|loop\|play-count\|speed\|style\)/ -syn match cssAdvancedProp /move-to/ -syn match cssAdvancedProp /nav-\(down\|index\|left\|right\|up\)/ -syn match cssAdvancedProp /\(pause-\(after\|before\)\|pause\)/ -syn match cssAdvancedProp /\(perspective-origin\|perspective\)/ -syn match cssAdvancedProp /\(pitch-range\|pitch\)/ -syn match cssAdvancedProp /presentation-level/ -syn match cssAdvancedProp /punctuation-trim/ -syn match cssAdvancedProp /rendering-intent/ -syn match cssAdvancedProp /pointer-events/ -syn match cssAdvancedProp /\(rest-\(after\|before\)\|rest\)/ -syn match cssAdvancedProp /\(rotation-point\|rotation\)/ -syn match cssAdvancedProp /ruby-\(align\|overhang\|position\|span\)/ -syn match cssAdvancedProp /\(target-\(name\|new\|position\)\|target\)/ -syn match cssAdvancedProp /\(transform-\(origin\|style\)\|transform\)/ -syn match cssAdvancedProp /\(transition-\(delay\|duration\|property\|timing-function\)\|transition\)/ -syn match cssAdvancedProp /voice-\(balance\|duration\|family\|pitch-range\|pitch\|rate\|stress\|volume\)/ - -syn match cssAdvancedVal /\(ease-\(in\|out\|in-out\)\|ease\)/ contained - -" CSS3 Advanced value -"syn match cssAdvancedVal - - -if main_syntax == "css" - syn sync minlines=10 -endif +syntax case ignore -" Define the default highlighting. -" For version 5.7 and earlier: only when not done already -" For version 5.8 and later: only when an item doesn't have highlighting yet -if version >= 508 || !exists("did_css_syn_inits") - if version < 508 - let did_css_syn_inits = 1 - command -nargs=+ HiLink hi link <args> - else - command -nargs=+ HiLink hi def link <args> - endif +" First of all define indented and not indented lines +syntax match stylusNewLine "^\S\@=" + \ nextgroup=stylusComment,stylusSelectorClass,stylusSelectorId,stylusSelectorCombinator,stylusSelectorElement,stylusSelectorAttribute,stylusVariable,stylusExplicitVariable,stylusInterpolationSelectors,stylusFunctionName,stylusConditional,stylusOperatorReturn,stylusAtRuleMedia,stylusAtRuleKeyframes,stylusAtRuleNamespace,stylusAtRuleSupports,stylusAtRuleDocument,stylusAtRulePage,stylusAtRuleViewport - HiLink cssString String - HiLink cssComment Comment - HiLink cssTagName Statement - HiLink cssSelector Function - HiLink cssBackgroundProp StorageClass - HiLink cssTableProp StorageClass - HiLink cssBorderProp StorageClass - HiLink cssFontProp StorageClass - HiLink cssColorProp StorageClass - HiLink cssBoxProp StorageClass - HiLink cssTextProp StorageClass - HiLink cssListProp StorageClass - HiLink cssVisualProp StorageClass - HiLink cssAdvancedProp StorageClass - HiLink cssCommonProp StorageClass - HiLink cssSpecialProp Special - HiLink cssImportant Special - HiLink cssRuleProp PreProc - HiLink cssPseudo PreProc - - HiLink cssColorVal Constant - HiLink cssCommonVal Type - HiLink cssFontVal Type - HiLink cssListVal Type - HiLink cssTextVal Type - HiLink cssVisualVal Type - HiLink cssBorderVal Type - HiLink cssBackgroundVal Type - HiLink cssFuncVal Function - HiLink cssAdvancedVal Function - - HiLink cssValueLength Number - HiLink cssValueInteger Number - HiLink cssValueNumber Number - HiLink cssValueAngle Number - HiLink cssValueTime Number - HiLink cssValueFrequency Number - delcommand HiLink -endif +syntax match stylusNewLineIndented "^\s\+" + \ nextgroup=stylusComment,stylusSelectorClass,stylusSelectorId,stylusSelectorCombinator,stylusSelectorElement,stylusSelectorAttribute,stylusSelectorReference,stylusSelectorPartialReference,stylusProperty,stylusVariable,stylusExplicitVariable,stylusInterpolation,stylusFunctionName,stylusUnitInt,stylusParenthesised,stylusOperatorReturn,stylusConditional,stylusAtRuleMedia,stylusAtRuleKeyframes,stylusAtRuleKeyframesOffset,stylusAtRuleNamespace,stylusAtRuleSupports,stylusAtRuleDocument,stylusAtRulePageMarginBoxTypes,stylusAtRuleViewport,stylusAtRuleExtends -" let b:current_syntax = "css" -" -if main_syntax == 'css' - unlet main_syntax -endif +" =============================================== +" ENCLOSURES +" =============================================== -" Vim syntax file -" Language: Stylus -" Maintainer: Marc Harter -" Filenames: *.styl, *.stylus -" Based On: Tim Pope (sass.vim) +syntax match stylusEnclosure "\(\[\|\]\|{\|}\|(\|)\)" + \ contained -syn case ignore +highlight def link stylusEnclosure SpecialChar -syn cluster stylusCssSelectors contains=cssTagName,cssSelector,cssPseudo -syn cluster stylusCssValues contains=cssValueLength,cssValueInteger,cssValueNumber,cssValueAngle,cssValueTime,cssValueFrequency,cssColorVal,cssCommonVal,cssFontVal,cssListVal,cssTextVal,cssVisualVal,cssBorderVal,cssBackgroundVal,cssFuncVal,cssAdvancedVal -syn cluster stylusCssProperties contains=cssBackgroundProp,cssTableProp,cssBorderProp,cssFontProp,cssColorProp,cssBoxProp,cssTextProp,cssListProp,cssVisualProp,cssAdvancedProp,cssCommonProp,cssSpecialProp +" =============================================== +" VARIABLES +" =============================================== -syn match stylusVariable "$\?[[:alnum:]_-]\+" -syn match stylusVariableAssignment "\%([[:alnum:]_-]\+\s*\)\@<==" nextgroup=stylusCssAttribute,stylusVariable skipwhite +syntax match stylusVariable "\<\(\w\|-\|\$\)*\>" + \ contained + \ nextgroup=stylusColor,stylusUnitInt,stylusUnitFloat,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusOperatorAssignment,stylusPropertyLookup,stylusParenthesised,stylusOperatorAdditive,stylusOperatorMultiplicative,stylusSubscript,stylusOperatorRelational,stylusOperatorLogical,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorVarDefinition,stylusOperatorTernary,stylusImportant,stylusFunctionName,stylusConditional,stylusHashDotGetter + \ skipwhite -syn match stylusProperty "\%([{};]\s*\|^\)\@<=\%([[:alnum:]-]\|#{[^{}]*}\)\+:" contains=@stylusCssProperties,@stylusCssSelectors skipwhite nextgroup=stylusCssAttribute contained containedin=cssDefineBlock -syn match stylusProperty "^\s*\zs\s\%(\%([[:alnum:]-]\|#{[^{}]*}\)\+[ :]\|:[[:alnum:]-]\+\)"hs=s+1 contains=@stylusCssProperties,@stylusCssSelectors skipwhite nextgroup=stylusCssAttribute -syn match stylusProperty "^\s*\zs\s\%(:\=[[:alnum:]-]\+\s*=\)"hs=s+1 contains=@stylusCssProperties,@stylusCssSelectors skipwhite nextgroup=stylusCssAttribute +syntax match stylusExplicitVariable "\$\(\w\|-\|\$\)*\>" + \ contained + \ nextgroup=stylusColor,stylusUnitInt,stylusUnitFloat,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusOperatorAssignment,stylusPropertyLookup,stylusParenthesised,stylusOperatorAdditive,stylusOperatorMultiplicative,stylusSubscript,stylusOperatorRelational,stylusOperatorLogical,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorVarDefinition,stylusOperatorTernary,stylusImportant,stylusFunctionName,stylusConditional,stylusHashDotGetter,stylusOptional + \ skipwhite -syn match stylusCssAttribute +\%("\%([^"]\|\\"\)*"\|'\%([^']\|\\'\)*'\|#{[^{}]*}\|[^{};]\)*+ contained contains=@stylusCssValues,cssImportant,stylusFunction,stylusVariable,stylusControl,stylusUserFunction,stylusInterpolation,cssString,stylusComment,cssComment +syntax match stylusExplicitVariable "\<arguments\|block\>" + \ contained + \ nextgroup=stylusColor,stylusUnitInt,stylusUnitFloat,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorAdditive,stylusOperatorMultiplicative,stylusSubscript,stylusOperatorRelational,stylusOperatorLogical,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorVarDefinition,stylusOperatorTernary,stylusImportant,stylusFunctionName,stylusConditional,stylusHashDotGetter + \ skipwhite -syn match stylusInterpolation %{[[:alnum:]_-]\+}% +highlight def link stylusExplicitVariable Identifier -syn match stylusFunction "\<\%(red\|green\|blue\|alpha\|dark\|light\)\>(\@=" contained -syn match stylusFunction "\<\%(hue\|saturation\|lightness\|push\|unshift\|typeof\|unit\|match\)\>(\@=" contained -syn match stylusFunction "\<\%(hsla\|hsl\|rgba\|rgb\|lighten\|darken\)\>(\@=" contained -syn match stylusFunction "\<\%(abs\|ceil\|floor\|round\|min\|max\|even\|odd\|sum\|avg\|sin\|cos\|join\)\>(\@=" contained -syn match stylusFunction "\<\%(desaturate\|saturate\|invert\|unquote\|quote\|s\)\>(\@=" contained -syn match stylusFunction "\<\%(operate\|length\|warn\|error\|last\|p\|\)\>(\@=" contained -syn match stylusFunction "\<\%(opposite-position\|image-size\|add-property\)\>(\@=" contained +" =============================================== +" OPERATORS +" =============================================== -syn keyword stylusVariable null true false arguments -syn keyword stylusControl if else unless for in return +" Unary +syntax match stylusOperatorUnary "\([-+\!\~]\+\|\<not\>\)" + \ contained + \ nextgroup=stylusVariable,stylusExplicitVariable,stylusUnitInt,stylusUnitFloat,stylusParenthesised,stylusPropertyLookup,stylusOperatorUnary,stylusBoolean,stylusFunctionName + \ skipwhite -syn match stylusImport "@\%(import\|require\)" nextgroup=stylusImportList -syn match stylusImportList "[^;]\+" contained contains=cssString.*,cssMediaType,cssURL +highlight def link stylusOperatorUnary Operator -syn match stylusAmpersand "&" -syn match stylusClass "[[:alnum:]_-]\+" contained -syn match stylusClassChar "\.[[:alnum:]_-]\@=" nextgroup=stylusClass -syn match stylusEscape "^\s*\zs\\" -syn match stylusId "[[:alnum:]_-]\+" contained -syn match stylusIdChar "#[[:alnum:]_-]\@=" nextgroup=stylusId +" Additive +syntax match stylusOperatorAdditive "[-+]" + \ contained + \ nextgroup=stylusVariable,stylusExplicitVariable,stylusUnitInt,stylusUnitFloat,stylusUnitName,stylusParenthesised,stylusPropertyLookup,stylusColor,stylusFunctionName + \ skipwhite -syn region stylusComment start="//" end="$" contains=cssTodo,@Spell fold +highlight def link stylusOperatorAdditive Operator -hi def link stylusComment Comment -hi def link stylusVariable Identifier -hi def link stylusControl PreProc -hi def link stylusFunction Function -hi def link stylusInterpolation Delimiter +" Multiplicative +syntax match stylusOperatorMultiplicative "\([/\%]\|\*\{1,2}\)" + \ contained + \ nextgroup=stylusVariable,stylusExplicitVariable,stylusUnitInt,stylusUnitFloat,stylusParenthesised,stylusPropertyLookup,stylusFunctionName + \ skipwhite +highlight def link stylusOperatorMultiplicative Operator -hi def link stylusAmpersand Character -hi def link stylusClass Type -hi def link stylusClassChar Special -hi def link stylusEscape Special -hi def link stylusId Identifier -hi def link stylusIdChar Special +" Ternary +syntax match stylusOperatorTernary "[:?]" + \ contained + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusBoolean,stylusFunctionName + \ skipwhite -let b:current_syntax = "stylus" +highlight def link stylusOperatorTernary Operator + +" Assignment +syntax match stylusOperatorAssignment "[/\*+-:?]\==" + \ contained + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusBoolean,stylusFunctionName,stylusHash,stylusAtRuleBlock + \ skipwhite + +highlight def link stylusOperatorAssignment Operator + +" Relational +syntax match stylusOperatorRelational "\(=\{2}\|\<is\>\(\s\<not\>\)\=\|\!=\|\<isnt\>\|>=\|<=\|>\|<\)" + \ contained + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusVariable,stylusExplicitVariable,stylusParenthesised,stylusPropertyLookup,stylusColor,stylusBoolean,stylusFunctionName + \ skipwhite + +highlight def link stylusOperatorRelational Operator + +" Logical +syntax match stylusOperatorLogical "\(&&\|||\|\<and\>\|\<or\>\)" + \ contained + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusColor,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusBoolean,stylusFunctionName + \ skipwhite + +highlight def link stylusOperatorLogical Operator + +" Existence +syntax match stylusOperatorExistence "\<in\>" + \ contained + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusBoolean,stylusFunctionName + \ skipwhite + +highlight def link stylusOperatorExistence Operator + +" Instance +syntax match stylusOperatorInstance "\<is a\>" + \ contained + \ skipwhite + +highlight def link stylusOperatorInstance Operator + +" Variable definition +syntax match stylusOperatorVarDefinition "\<is defined\>" + \ contained + \ nextgroup=stylusOperatorLogical,stylusOperatorTernary,stylusFunctionName + \ skipwhite + +highlight def link stylusOperatorVarDefinition Operator + +" Return +syntax match stylusOperatorReturn "\<return\>" + \ contained + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusBoolean,stylusFunctionName + \ skipwhite + +highlight def link stylusOperatorReturn Operator + +" Comma +syntax match stylusComma /,\(\s\=\(\a\w\{-}:\|\('\|"\).\{-}\('\|"\):\)\)\@!/ + \ containedin=ALLBUT,stylusString,stylusComment,stylusHash,stylusAtRuleMediaComma + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusUnitName,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusBoolean,stylusFunctionName + \ skipwhite + +" Range +syntax match stylusOperatorRange "\.\.\.\=" + \ contained + \ nextgroup=stylusUnitInt,stylusVariable,stylusExplicitVariable,stylusFunctionName + +highlight def link stylusOperatorRange Operator + +" =============================================== +" CONDITIONALS +" =============================================== + +syntax match stylusConditional "\<\(if\|else\|unless\|for\)\>" + \ contained + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusUnitName,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusBoolean,stylusFunctionName,stylusConditional + \ skipwhite + +highlight def link stylusConditional Conditional + +" =============================================== +" SPRINTF +" =============================================== + +syntax match stylusSprintfPlaceholder "%s" + \ contained + +highlight def link stylusSprintfPlaceholder Operator + +syntax match stylusSprintfDefinition "%" + \ contained + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusBoolean,stylusFunctionName + \ skipwhite + +highlight def link stylusSprintfDefinition Operator + +" =============================================== +" SUBSCRIPT +" =============================================== + +syntax region stylusSubscript matchgroup=stylusEnclosure start="\[" end="\]" + \ contained + \ contains=stylusExplicitVariable,stylusVariable,stylusUnitInt,stylusParenthesised,stylusPropertyLookup,stylusFunctionName + \ keepend + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorAdditive,stylusOperatorMultiplicative,stylusOperatorRelational,stylusOperatorLogical,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorTernary,stylusImportant,stylusFunctionName,stylusConditional,stylusOperatorAssignment,stylusHashDotGetter + \ oneline + \ skipwhite + +" =============================================== +" UNITS +" =============================================== + +syntax match stylusUnitInt "[-+]\=\d\+%\=" + \ contained + \ nextgroup=stylusOperatorRange,stylusUnitInt,stylusUnitFloat,stylusUnitName,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorAdditive,stylusOperatorMultiplicative,stylusOperatorRelational,stylusOperatorLogical,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorTernary,stylusImportant,stylusFunctionName,stylusConditional + \ skipwhite + +syntax match stylusUnitInt "\<PI\>" + \ contained + \ nextgroup=stylusOperatorRange,stylusUnitInt,stylusUnitFloat,stylusUnitName,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorAdditive,stylusOperatorMultiplicative,stylusOperatorRelational,stylusOperatorLogical,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorTernary,stylusImportant,stylusFunctionName,stylusConditional + \ skipwhite + +highlight def link stylusUnitInt Number + +syntax match stylusUnitFloat "[-+]\=\d\=\.\d\+%\=" + \ contained + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusUnitName,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorAdditive,stylusOperatorMultiplicative,stylusOperatorRelational,stylusOperatorLogical,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorTernary,stylusImportant,stylusFunctionName,stylusConditional + \ skipwhite + +highlight def link stylusUnitFloat Number + +execute 'syntax match stylusUnitName "\(\<\|\d\@<=\)\(' . join(g:css_units, '\|') . '\)\>" + \ contained + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorAdditive,stylusOperatorMultiplicative,stylusOperatorRelational,stylusOperatorLogical,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorTernary,stylusImportant,stylusFunctionName,stylusConditional + \ skipwhite' + +highlight def link stylusUnitName Number + +" Resolve 'in' unit name and operator conflict +syntax match stylusOperatorExistence "\s\@<=\<in\>" + \ contained + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusColor,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusBoolean,stylusFunctionName + \ skipwhite + +" =============================================== +" BOOLEAN +" =============================================== + +syntax match stylusBoolean "\<\(true\|false\|null\)\>" + \ contained + \ nextgroup=stylusOperatorRelational,stylusOperatorAssignment,stylusOperatorLogical,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorTernary,stylusFunctionName,stylusConditional + \ skipwhite + +highlight def link stylusBoolean Boolean + +" =============================================== +" SELECTORS +" =============================================== + +" HTML or SVG elements +execute 'syn match stylusSelectorElement "\<\(' . join(g:html_elements, '\|') . '\)\(\>\|#\@=\)" + \ contained + \ keepend + \ nextgroup=stylusSelectorClass,stylusSelectorId,stylusSelectorCombinator,stylusSelectorElement,stylusSelectorAttribute,stylusSelectorPseudo,stylusSelectorReference,stylusSelectorPartialReference,stylusInterpolationSelectors,stylusOptional + \ oneline + \ skipwhite' + +syn match stylusSelectorElement "\(^\|\s\)\@<=\*\($\|\s\)\@=" + \ contained + \ keepend + \ nextgroup=stylusSelectorClass,stylusSelectorId,stylusSelectorCombinator,stylusSelectorElement,stylusSelectorAttribute,stylusSelectorPseudo,stylusSelectorReference,stylusSelectorPartialReference,stylusInterpolationSelectors,stylusOptional + \ oneline + \ skipwhite + +highlight def link stylusSelectorElement Statement + +" CSS Class +syntax region stylusSelectorClass start="\." skip="\w-\@=" end="\(\w\|-+\)\(\W\|$\)\@=" + \ contained + \ keepend + \ nextgroup=stylusSelectorClass,stylusSelectorId,stylusSelectorCombinator,stylusSelectorElement,stylusSelectorAttribute,stylusSelectorPseudo,stylusSelectorReference,stylusSelectorPartialReference,stylusInterpolationSelectors,stylusOptional,stylusOptional + \ oneline + \ skipwhite + +syntax match stylusSelectorClass "\.{\@=" + \ contained + \ nextgroup=stylusInterpolationSelectors + +highlight def link stylusSelectorClass Identifier + +" CSS Id +syntax region stylusSelectorId start="#" skip="\w-\@=" end="\(\w\|-+\)\(\W\|$\)\@=" + \ contained + \ keepend + \ nextgroup=stylusSelectorClass,stylusSelectorId,stylusSelectorCombinator,stylusSelectorElement,stylusSelectorAttribute,stylusSelectorPseudo,stylusSelectorReference,stylusSelectorPartialReference,stylusInterpolationSelectors,stylusOptional + \ oneline + \ skipwhite + +syntax match stylusSelectorId "#{\@=" + \ contained + \ nextgroup=stylusInterpolationSelectors + +highlight def link stylusSelectorId Identifier + +" Attribute selectors +syntax match stylusSelectorAttributeOperator "\(=\|\~=\||=\|\^=\|\$=\|\*=\)" + \ contained + +highlight def link stylusSelectorAttributeOperator Operator + +syntax region stylusSelectorAttribute matchgroup=stylusEnclosure start="\[" skip="{.\{-}}" end="\]" + \ contained + \ contains=stylusSelectorAttributeOperator,stylusInterpolation + \ keepend + \ nextgroup=stylusSelectorClass,stylusSelectorId,stylusSelectorCombinator,stylusSelectorElement,stylusSelectorAttribute,stylusSelectorPseudo,stylusSelectorReference,stylusSelectorPartialReference,stylusInterpolationSelectors,stylusOptional + \ oneline + \ skipwhite + +highlight def link stylusSelectorAttribute Type + +" Parent reference +syntax match stylusSelectorReference "\(&\|\~/\|\(\.\./\)\+\|/\)" + \ contained + \ nextgroup=stylusSelectorClass,stylusSelectorId,stylusSelectorCombinator,stylusSelectorElement,stylusSelectorAttribute,stylusSelectorPseudo,stylusSelectorPartialReference,stylusInterpolationSelectors,stylusOptional + \ skipwhite + +highlight def link stylusSelectorReference Statement + +" Partial reference +syntax region stylusSelectorPartialReference matchgroup=stylusSelectorReference start="\^\[\@=" skip="{.\{-}}" matchgroup=NONE end="\]" + \ contained + \ contains=stylusEnclosure,stylusUnitInt,stylusInterpolation + \ keepend + \ nextgroup=stylusSelectorClass,stylusSelectorId,stylusSelectorCombinator,stylusSelectorElement,stylusSelectorAttribute,stylusSelectorPseudo,stylusSelectorReference,stylusSelectorPartialReference,stylusInterpolationSelectors,stylusOptional + \ oneline + \ skipwhite + +syntax region stylusSelectorClass start="\(&\|\~/\|\(\.\./\)\+\|/\)" skip="\w[-()]\@=" end="\(\w\|(\|)\)\(\W\|$\)\@=" + \ contained + \ contains=stylusSelectorReference + \ keepend + \ nextgroup=stylusSelectorClass,stylusSelectorId,stylusSelectorCombinator,stylusSelectorElement,stylusSelectorAttribute,stylusSelectorPseudo,stylusSelectorReference,stylusSelectorPartialReference,stylusInterpolationSelectors,stylusOptional + \ oneline + \ skipwhite + +" CSS pseudo classes and elements +execute 'syntax match stylusSelectorPseudo ":\(' . join(g:css_pseudo, '\|') . '\)-\@!" + \ contained + \ nextgroup=stylusSelectorClass,stylusSelectorId,stylusSelectorCombinator,stylusSelectorElement,stylusSelectorAttribute,stylusSelectorReference,stylusSelectorPartialReference,stylusInterpolationSelectors,stylusSelectorPseudo,stylusOptional + \ skipwhite' + +syntax match stylusSelectorPseudo ":\(\(first\|last\|only\)-\(child\|of-type\)\)" + \ contained + \ nextgroup=stylusSelectorClass,stylusSelectorId,stylusSelectorCombinator,stylusSelectorElement,stylusSelectorAttribute,stylusSelectorReference,stylusSelectorPartialReference,stylusInterpolationSelectors,stylusSelectorPseudo,stylusOptional + \ skipwhite + +syntax match stylusSelectorPseudo ":not(.\{-})" + \ contained + \ contains=stylusSelectorElement,stylusEnclosure,stylusInterpolationSelectors + \ nextgroup=stylusSelectorClass,stylusSelectorId,stylusSelectorCombinator,stylusSelectorElement,stylusSelectorAttribute,stylusSelectorReference,stylusSelectorPartialReference,stylusInterpolationSelectors,stylusSelectorPseudo,stylusOptional + \ skipwhite + +syntax match stylusSelectorPseudo ":lang(.\{-})" + \ contained + \ contains=stylusEnclosure,stylusInterpolationSelectors + \ nextgroup=stylusSelectorClass,stylusSelectorId,stylusSelectorCombinator,stylusSelectorElement,stylusSelectorAttribute,stylusSelectorReference,stylusSelectorPartialReference,stylusInterpolationSelectors,stylusSelectorPseudo,stylusOptional + \ skipwhite + +syntax match stylusSelectorPseudo ":\(nth-last-\|nth-\)\(child\|of-type\)(.\{-})" + \ contained + \ contains=stylusUnitInt,stylusEnclosure,stylusInterpolationSelectors + \ nextgroup=stylusSelectorClass,stylusSelectorId,stylusSelectorCombinator,stylusSelectorElement,stylusSelectorAttribute,stylusSelectorReference,stylusSelectorPartialReference,stylusInterpolationSelectors,stylusSelectorPseudo,stylusOptional + \ skipwhite + +syntax match stylusSelectorPseudo /::\=\(first-\(line\|letter\)\|before\|after\|selection\|placeholder\)/ + \ contained + \ nextgroup=stylusSelectorClass,stylusSelectorId,stylusSelectorCombinator,stylusSelectorElement,stylusSelectorAttribute,stylusSelectorReference,stylusSelectorPartialReference,stylusInterpolationSelectors,stylusSelectorPseudo,stylusOptional + \ skipwhite + +highlight def link stylusSelectorPseudo Define + +" CSS Selector operators +syntax match stylusSelectorCombinator "[>\~+|,]" + \ contained + \ nextgroup=stylusSelectorClass,stylusSelectorId,stylusSelectorElement,stylusSelectorAttribute,stylusSelectorReference,stylusSelectorPartialReference,stylusInterpolationSelectors,stylusExplicitVariable + \ skipwhite + +highlight def link stylusSelectorCombinator Operator + +" =============================================== +" PROPERTIES +" =============================================== + +execute 'syntax match stylusProperty "\<\(' . join(g:css_single_props, '\|') . '\)\>-\@!:\=" + \ contained + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusInterpolationProperties,stylusFunctionName + \ skipwhite' + +execute 'syntax match stylusProperty "\<\(' . join(g:css_multi_props, '\|') . '\)\>-\@!:\=" + \ contained + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusInterpolationProperties,stylusFunctionName + \ skipwhite' + +execute 'syntax match stylusProperty "\<\(' . join(g:svg_props, '\|') . '\)\>-\@!:\=" + \ contained + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusInterpolationProperties,stylusFunctionName + \ skipwhite' + +syntax match stylusProperty "\(-webkit-\|-moz-\|-o-\|-ms-\|-khtml-\)\(\w\|-\)*:\=" + \ contained + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusInterpolationProperties,stylusFunctionName + \ skipwhite + +highlight def link stylusProperty Type + +" =============================================== +" PROPERTY LOOKUP +" =============================================== + +execute 'syntax match stylusPropertyLookup "@\(' . join(g:css_props, '\|') . '\)\>-\@!" + \ contained + \ nextgroup=stylusColor,stylusUnitInt,stylusUnitFloat,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorAdditive,stylusOperatorMultiplicative,stylusOperatorRelational,stylusOperatorLogical,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorTernary,stylusImportant,stylusFunctionName,stylusConditional + \ skipwhite' + +execute 'syntax match stylusPropertyLookup "@\(' . join(g:svg_props, '\|') . '\)\>-\@!" + \ contained + \ nextgroup=stylusColor,stylusUnitInt,stylusUnitFloat,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorAdditive,stylusOperatorMultiplicative,stylusOperatorRelational,stylusOperatorLogical,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorTernary,stylusImportant,stylusFunctionName,stylusConditional + \ skipwhite' + +syntax match stylusPropertyLookup "@\(-webkit-\|-moz-\|-o-\|-ms-\|-khtml-\)\(\w\|-\)*" + \ contained + \ nextgroup=stylusColor,stylusUnitInt,stylusUnitFloat,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorAdditive,stylusOperatorMultiplicative,stylusOperatorRelational,stylusOperatorLogical,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorTernary,stylusImportant,stylusFunctionName,stylusConditional + \ skipwhite + +highlight def link stylusPropertyLookup Type + +" =============================================== +" VALUES +" =============================================== + +execute 'syntax match stylusValues "\<\(' . join(g:css_values, '\|') . '\)\>-\@!" + \ contained + \ nextgroup=stylusColor,stylusUnitInt,stylusUnitFloat,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorTernary,stylusImportant,stylusFunctionName + \ skipwhite' + +execute 'syntax match stylusValues "\<\(' . join(g:css_animatable_props, '\|') . '\)\>-\@!" + \ contained + \ nextgroup=stylusColor,stylusUnitInt,stylusUnitFloat,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorTernary,stylusImportant,stylusFunctionName + \ skipwhite' + +highlight def link stylusValues PreCondit + +" =============================================== +" COLORS +" =============================================== + +" Named +execute 'syntax match stylusColor "\<\(' . join(g:css_colors, '\|') . '\)\>-\@!" + \ contained + \ nextgroup=stylusColor,stylusUnitInt,stylusUnitFloat,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusOperatorRelational,stylusOperatorLogical,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorTernary,stylusOperatorAdditive,stylusImportant,stylusFunctionName,stylusConditional + \ skipwhite' + +syntax match stylusColor "\<transparent\>" + \ contained + \ nextgroup=stylusColor,stylusUnitInt,stylusUnitFloat,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusOperatorRelational,stylusOperatorLogical,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorTernary,stylusOperatorAdditive,stylusImportant,stylusFunctionName,stylusConditional + \ skipwhite + +" Hexadecimal +syntax match stylusColor "#\x\{3,6\}\>" + \ contained + \ nextgroup=stylusColor,stylusUnitInt,stylusUnitFloat,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusOperatorRelational,stylusOperatorLogical,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorTernary,stylusOperatorAdditive,stylusImportant,stylusFunctionName,stylusConditional + \ skipwhite + +highlight stylusColor term=underline ctermfg=133 guifg=#b169b2 + +" =============================================== +" FONT +" =============================================== + +" Highlight generic font families +syntax match stylusFont "\<\(serif\|sans-serif\|monospace\)\>" + \ contained + \ nextgroup=stylusColor,stylusUnitInt,stylusUnitFloat,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorTernary,stylusImportant,stylusFunctionName,stylusConditional + \ skipwhite + +highlight def link stylusFont Directory + +" =============================================== +" Explicitly point out that the word before assignment operator is a variable +syntax match stylusVariable "\<\(\w\|-\)*\(\s\=[:?]\==[^=]\)\@=" + \ contained + \ nextgroup=stylusOperatorAssignment + \ skipwhite +" =============================================== + +" =============================================== +" IMPORTANT +" =============================================== + +syntax match stylusImportant "!important" + \ contained + +highlight def link stylusImportant Special + +" =============================================== +" INTERPOLATION +" =============================================== + +" Prepend is always a property +syntax match stylusProperty "\(\w\|-\)\+{\@=" + \ contained + \ nextgroup=stylusInterpolationProperties + +syntax region stylusInterpolation matchgroup=stylusEnclosure start="{" end="}" + \ contained + \ contains=stylusVariable,stylusExplicitVariable,stylusOperatorUnary,stylusUnitInt,stylusUnitFloat,stylusParenthesised,stylusConditional,stylusFunctionName + \ keepend + \ nextgroup=stylusSelectorClass,stylusSelectorId,stylusSelectorCombinator,stylusSelectorElement,stylusSelectorAttribute,stylusSelectorPseudo,stylusSelectorReference,stylusSelectorPartialReference,stylusUnitInt,stylusUnitFloat,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusInterpolationSelectorsTail,stylusInterpolationPropertiesTail,stylusFunctionName + \ oneline + \ skipwhite + +syntax region stylusInterpolationSelectors matchgroup=stylusEnclosure start="{" end="}" + \ contained + \ contains=stylusVariable,stylusExplicitVariable,stylusOperatorUnary,stylusUnitInt,stylusUnitFloat,stylusParenthesised,stylusConditional,stylusFunctionName + \ keepend + \ nextgroup=stylusSelectorClass,stylusSelectorId,stylusSelectorCombinator,stylusSelectorElement,stylusSelectorAttribute,stylusSelectorPseudo,stylusSelectorReference,stylusSelectorPartialReference,stylusInterpolationSelectorsTail + \ oneline + \ skipwhite + +syntax region stylusInterpolationProperties matchgroup=stylusEnclosure start="{" end="}" + \ contained + \ contains=stylusVariable,stylusExplicitVariable,stylusOperatorUnary,stylusUnitInt,stylusUnitFloat,stylusParenthesised,stylusConditional,stylusFunctionName + \ keepend + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusProperty,stylusInterpolationPropertiesTail,stylusFunctionName + \ oneline + \ skipwhite + +syntax match stylusInterpolationPropertiesTail "}\@<=\(\w\|-\)\+" + \ contained + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusProperty,stylusInterpolationProperties,stylusFunctionName + \ skipwhite + +highlight def link stylusInterpolationPropertiesTail Type + +" Tail is a selector by default +syntax match stylusInterpolationSelectorsTail "}\@<=\(\w\|-\)\+" + \ contained + \ nextgroup=stylusSelectorClass,stylusSelectorId,stylusSelectorCombinator,stylusSelectorElement,stylusSelectorAttribute,stylusSelectorPseudo,stylusSelectorReference,stylusSelectorPartialReference,stylusInterpolationSelectors + \ skipwhite + +highlight def link stylusInterpolationSelectorsTail Identifier + +" Tail is a property if followed by anything +syntax match stylusInterpolationPropertiesTail "}\@<=\(\w\|-\)\+:\=\s\S\@=" + \ contained + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusProperty,stylusInterpolationProperties,stylusFunctionName + \ skipwhite + +" Tail is a selector if followed by .#[]$~^& +syntax match stylusInterpolationSelectorsTail "}\@<=\(\w\|-\)\+:\=\s[\.#\[~^&+|,>]\@=" + \ contained + \ nextgroup=stylusSelectorClass,stylusSelectorId,stylusSelectorCombinator,stylusSelectorElement,stylusSelectorAttribute,stylusSelectorPseudo,stylusSelectorReference,stylusSelectorPartialReference,stylusInterpolationSelectors + \ skipwhite + +" Tail is a property if followed by float number +syntax match stylusInterpolationPropertiesTail "}\@<=\(\w\|-\)\+:\=\s\(\.\d\)\@=" + \ contained + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusProperty,stylusInterpolationProperties,stylusFunctionName + \ skipwhite + +" Tail is a property if followed by hex color +syntax match stylusInterpolationPropertiesTail "}\@<=\(\w\|-\)\+:\=\s\(#\x\{3,6}\)\@=" + \ contained + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusProperty,stylusInterpolationProperties,stylusFunctionName + \ skipwhite + +execute 'syntax match stylusInterpolationSelectorsTail "}\@<=\(\w\|-\)\+:\=\s\(' . join(g:html_elements, '\|') . '\)\@=" + \ contained + \ nextgroup=stylusSelectorClass,stylusSelectorId,stylusSelectorCombinator,stylusSelectorElement,stylusSelectorAttribute,stylusSelectorPseudo,stylusSelectorReference,stylusSelectorPartialReference,stylusInterpolationSelectors + \ skipwhite' + +" =============================================== +" MIXINS & FUNCTIONS +" =============================================== + +syntax match stylusFunctionBlock "+" + \ contained + +highlight def link stylusFunctionBlock Operator + +syntax match stylusFunctionRest "\w\@<=\.\.\." + \ contained + +highlight def link stylusFunctionRest Operator + +syntax match stylusFunctionName "\(\<\|+\)\(\w\|\$\)\(-\|\w\|\$\)\{-}(\@=" + \ contained + \ contains=stylusFunctionBlock + \ nextgroup=stylusFunctionProps + +syntax match stylusFunctionName "@\{-}(\@=" + \ contained + \ contains=stylusFunctionBlock + \ nextgroup=stylusFunctionProps + +highlight def link stylusFunctionName Function + +syntax region stylusFunctionProps matchgroup=stylusEnclosure start="\S\@<=(" end=")" + \ contained + \ contains=stylusOperatorUnary,stylusVariable,stylusExplicitVariable,stylusUnitInt,stylusUnitFloat,stylusUnitName,stylusColor,stylusFunctionName,stylusFunctionRest,stylusValues + \ nextgroup=stylusColor,stylusUnitInt,stylusUnitFloat,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorTernary,stylusImportant,stylusFunctionName,stylusSubscript,stylusConditional,stylusOperatorRelational + \ skipwhite + + +" =============================================== +" PARENTHESISED EXPRESSIONS +" =============================================== + +syntax region stylusParenthesised matchgroup=stylusEnclosure start="\W\@<=(" skip=/["'].\{-}["']/ end=")" + \ contained + \ contains=stylusColor,stylusUnitInt,stylusUnitFloat,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorAdditive,stylusOperatorMultiplicative,stylusOperatorRelational,stylusOperatorLogical,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorTernary,stylusImportant,stylusFunctionName,stylusConditional + \ keepend + \ nextgroup=stylusColor,stylusUnitInt,stylusUnitFloat,stylusUnitName,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorAdditive,stylusOperatorMultiplicative,stylusOperatorRelational,stylusOperatorLogical,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorTernary,stylusImportant,stylusFunctionName,stylusConditional + \ oneline + \ skipwhite + +" Resolve '%' unit name and operator conflict +syntax match stylusUnitName ")\@<=%" + \ contained + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorAdditive,stylusOperatorMultiplicative,stylusOperatorRelational,stylusOperatorLogical,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorTernary,stylusImportant,stylusFunctionName,stylusConditional + \ skipwhite +" =============================================== +" STRINGS +" =============================================== + +syntax region stylusString start=/\('\|"\)/ end=/\('\|"\)/ + \ containedin=ALLBUT,stylusComment,stylusHash,stylusHashStringKey + \ contains=stylusSprintfPlaceholder + \ keepend + \ nextgroup=stylusColor,stylusUnitInt,stylusUnitFloat,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusOperatorAdditive,stylusOperatorRelational,stylusOperatorLogical,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorTernary,stylusSprintfDefinition,stylusImportant,stylusFunctionName,stylusConditional + \ oneline + \ skipwhite + +highlight def link stylusString String + +" =============================================== +" HASHES +" =============================================== + +syntax match stylusHashKey "\a\w\{-}:" + \ contained + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusBoolean,stylusFunctionName,stylusHash,stylusString + \ skipwhite + +highlight def link stylusHashKey NonText + +syntax region stylusHashStringKey start=/\('\|"\)/ end=/\('\|"\):/ + \ contained + \ keepend + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusBoolean,stylusFunctionName,stylusHash,stylusString + \ oneline + \ skipwhite + +highlight def link stylusHashStringKey String + +syntax match stylusHashDotGetter "\S\@<=\." + \ contained + \ nextgroup=stylusHashIdent + +highlight def link stylusHashDotGetter Operator + +syntax match stylusHashComma "," + \ contained + \ nextgroup=stylusHashKey,stylusHashStringKey + \ skipwhite + +syntax match stylusHashIdent "\<\(\w\|-\|\$\)*\>" + \ contained + \ nextgroup=stylusColor,stylusUnitInt,stylusUnitFloat,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusOperatorAssignment,stylusPropertyLookup,stylusParenthesised,stylusOperatorAdditive,stylusOperatorMultiplicative,stylusSubscript,stylusOperatorRelational,stylusOperatorLogical,stylusOperatorExistence,stylusOperatorInstance,stylusOperatorVarDefinition,stylusOperatorTernary,stylusImportant,stylusFunctionName,stylusConditional,stylusHashDotGetter + \ skipwhite + +highlight def link stylusHashIdent NonText + +syntax region stylusHash matchgroup=stylusEnclosure start="{" end="}" + \ contained + \ contains=stylusHashKey,stylusHashStringKey,stylusHash,stylusHashComma + \ skipwhite + +" =============================================== +" @ RULES +" =============================================== + +syntax match stylusAtRuleImport "@\(import\|require\)\>" + \ containedin=ALLBUT,stylusString,stylusComment + \ nextgroup=stylusFunctionName,stylusVariable,stylusExplicitVariable + \ skipwhite + +highlight def link stylusAtRuleImport Macro + +syntax match stylusAtRuleMedia "@media\>" + \ contained + \ nextgroup=stylusAtRuleMediaType,stylusAtRuleMediaFeatureExpression + \ skipwhite + +highlight def link stylusAtRuleMedia Macro + +syntax match stylusAtRuleMediaType "\<\(all\|print\|screen\|speech\)\>" + \ contained + \ nextgroup=stylusAtRuleMediaType,stylusAtRuleMediaFeatureExpression,stylusAtRuleMediaLogical + \ skipwhite + +highlight def link stylusAtRuleMediaType Macro + +syntax match stylusAtRuleMediaLogical "\<\(and\|not\|only\)\>" + \ contained + \ nextgroup=stylusAtRuleMediaType,stylusAtRuleMediaFeatureExpression,stylusAtRuleMediaLogical + \ skipwhite + +highlight def link stylusAtRuleMediaLogical Operator + +syntax region stylusAtRuleMediaFeatureExpression matchgroup=stylusEnclosure start="(" end=")" + \ contained + \ contains=stylusAtRuleMediaFeature,stylusInterpolationProperties,stylusInterpolationPropertiesTail + \ nextgroup=stylusAtRuleMediaComma,stylusAtRuleMediaLogical + \ oneline + \ skipwhite + +execute 'syntax match stylusAtRuleMediaFeature "\(min-\|max-\)\=\(' . join(g:css_media_features, '\|') . '\)\>:" + \ contained + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusInterpolationProperties,stylusFunctionName + \ skipwhite' + +syntax match stylusAtRuleMediaFeature "\(\w\|-\)\+{\@=" + \ contained + \ nextgroup=stylusInterpolationProperties + +syntax match stylusAtRuleMediaFeature "}\@<=:" + \ contained + \ nextgroup=stylusUnitInt,stylusUnitFloat,stylusColor,stylusValues,stylusFont,stylusVariable,stylusExplicitVariable,stylusPropertyLookup,stylusParenthesised,stylusOperatorUnary,stylusInterpolationProperties,stylusFunctionName + \ skipwhite + +highlight def link stylusAtRuleMediaFeature Type + +syntax match stylusAtRuleMediaComma "," + \ contained + \ nextgroup=stylusAtRuleMediaFeatureExpression + \ skipwhite + +syntax match stylusAtRuleFont "@font-face\>" + \ containedin=ALLBUT,stylusString,stylusComment + +highlight def link stylusAtRuleFont Macro -" vim:set sw=2: +syntax match stylusAtRuleKeyframes "@\(-\(o\|webkit\|moz\)-\)\=keyframesi\>" + \ contained + \ nextgroup=stylusAtRuleKeyframesName,stylusInterpolationSelectors + \ skipwhite + +highlight def link stylusAtRuleKeyframes Macro + +syntax match stylusAtRuleKeyframesName "\<\(\w\|-\|\$\)*\>" + \ contained + \ nextgroup=stylusInterpolationSelectors + \ skipwhite + +highlight def link stylusAtRuleKeyframesName Identifier + +syntax match stylusAtRuleKeyframesOffset "\d\{1,3}%" + \ contained + +syntax match stylusAtRuleKeyframesOffset "\<\(from\|to\)\>" + \ contained + +highlight def link stylusAtRuleKeyframesOffset Macro + +syntax match stylusAtRuleNamespace "@namespace\>" + \ contained + \ nextgroup=stylusAtRuleNamespacePrefix,stylusAtRuleNamespaceUrl + \ skipwhite + +highlight def link stylusAtRuleNamespace Macro + +syntax match stylusAtRuleNamespacePrefix "\<\(\w\|-\|\$\)*\>" + \ contained + \ nextgroup=stylusAtRuleNamespaceUrl + \ skipwhite + +highlight def link stylusAtRuleNamespacePrefix Macro + +syntax match stylusAtRuleNamespaceUrl "\<url(\@=" + \ contained + \ nextgroup=stylusAtRuleNamespaceUrlAdress + +highlight def link stylusAtRuleNamespaceUrl Function + +syntax region stylusAtRuleNamespaceUrlAdress matchgroup=stylusEnclosure start="(" end=")" + \ contained + +highlight def link stylusAtRuleNamespaceUrlAdress String + +syntax match stylusAtRuleSupports "@supports\>" + \ contained + \ nextgroup=stylusAtRuleSupportsLogic,stylusAtRuleSupportsDeclaration + \ skipwhite + +highlight def link stylusAtRuleSupports Macro + +syntax region stylusAtRuleSupportsDeclaration matchgroup=stylusEnclosure start="(" end=")" + \ contained + \ contains=stylusProperty,stylusAtRuleSupportsLogic,stylusAtRuleSupportsDeclaration + \ nextgroup=stylusAtRuleSupportsLogic,stylusAtRuleSupportsDeclaration + \ oneline + \ skipwhite + +syntax match stylusAtRuleSupportsLogic "\<\(and\|not\|or\)\>" + \ contained + \ nextgroup=stylusAtRuleSupportsLogic,stylusAtRuleSupportsDeclaration + \ skipwhite + +highlight def link stylusAtRuleSupportsLogic Operator + +syntax match stylusAtRuleDocument "@document\>" + \ contained + \ nextgroup=stylusAtRuleDocumentFunc + \ skipwhite + +highlight def link stylusAtRuleDocument Macro + +syntax match stylusAtRuleDocumentFunc "\<\(url\|url-prefix\|domain\|regexp\)(\@=" + \ contained + \ nextgroup=stylusAtRuleNamespaceUrlAdress + +highlight def link stylusAtRuleDocumentFunc Function + +syntax match stylusAtRulePage "@page\>" + \ contained + \ nextgroup=stylusAtRulePagePseudo + \ skipwhite + +highlight def link stylusAtRulePage Macro + +syntax match stylusAtRulePagePseudo ":\(left\|right\|first\|blank\)\>" + \ contained + +highlight def link stylusAtRulePagePseudo Macro + +syntax match stylusAtRulePageMarginBoxTypes "@\(top-left-corner\|top-left\|top-center\|top-right\|top-right-corner\|bottom-left-corner\|bottom-left\|bottom-center\|bottom-right\|bottom-right-corner\|left-top\|left-middle\|left-bottom\|right-top\|right-middle\|right-bottom\)\>" + \ contained + +highlight def link stylusAtRulePageMarginBoxTypes Macro + +syntax match stylusAtRuleViewport "@viewport\>" + \ contained + \ skipwhite + +highlight def link stylusAtRuleViewport Macro + +syntax match stylusAtRuleBlock "@block\>" + \ contained + +highlight def link stylusAtRuleBlock Macro + +syntax match stylusAtRuleExtends "@extends\=\>" + \ contained + \ nextgroup=stylusSelectorClass,stylusSelectorId,stylusSelectorCombinator,stylusSelectorElement,stylusSelectorAttribute,stylusSelectorPseudo,stylusSelectorReference,stylusSelectorPartialReference,stylusInterpolationSelectors,stylusExplicitVariable + \ skipwhite + +highlight def link stylusAtRuleExtends Macro + +syntax match stylusOptional "!optional" + \ contained + \ nextgroup=stylusSelectorClass,stylusSelectorId,stylusSelectorCombinator,stylusSelectorElement,stylusSelectorAttribute,stylusSelectorPseudo,stylusSelectorReference,stylusSelectorPartialReference,stylusInterpolationSelectors,stylusExplicitVariable + \ skipwhite + +highlight def link stylusOptional Special +" =============================================== +" COMMENTS +" =============================================== + +" Single-line +syntax region stylusComment start="//" end="$" + \ containedin=ALLBUT,stylusString + \ keepend + \ oneline + +" Multi-line +syntax region stylusComment start="/\*" end="\*/" + \ containedin=ALLBUT,stylusString + \ keepend + +highlight def link stylusComment Comment + +" =============================================== + +let b:current_syntax = "stylus" |