citadel

My dotfiles, scripts and nix configs
git clone git://jb55.com/citadel
Log | Files | Refs | README | LICENSE

less.vim (15139B)


      1 " Vim syntax file
      2 " Language:	LESS Cascading Style Sheets
      3 " Maintainer:	Leaf Corcoran <leafot@gmail.com>
      4 " Modifier:	Bryan J Swift <bryan@bryanjswift.com>
      5 " URL: 		http://leafo.net/lessphp/vim/less.vim
      6 " URL:		http://gist.github.com/161047
      7 " Last Change:	2009 August 4
      8 " LESS by Leaf Corcoran
      9 " CSS2 by Nikolai Weibull
     10 " Full CSS2, HTML4 support by Yeti
     11 
     12 " For version 5.x: Clear all syntax items
     13 " For version 6.x: Quit when a syntax file was already loaded
     14 if !exists("main_syntax")
     15   if version < 600
     16     syntax clear
     17   elseif exists("b:current_syntax")
     18   finish
     19 endif
     20   let main_syntax = 'less'
     21 endif
     22 
     23 syn case ignore
     24 
     25 
     26 
     27 syn keyword cssTagName abbr acronym address applet area a b base
     28 syn keyword cssTagName basefont bdo big blockquote body br button
     29 syn keyword cssTagName caption center cite code col colgroup dd del
     30 syn keyword cssTagName dfn dir div dl dt em fieldset font form frame
     31 syn keyword cssTagName frameset h1 h2 h3 h4 h5 h6 head hr html img i
     32 syn keyword cssTagName iframe img input ins isindex kbd label legend li
     33 syn keyword cssTagName link map menu meta noframes noscript ol optgroup
     34 syn keyword cssTagName option p param pre q s samp script select small
     35 syn keyword cssTagName span strike strong style sub sup tbody td
     36 syn keyword cssTagName textarea tfoot th thead title tr tt ul u var
     37 syn match cssTagName "\<table\>"
     38 syn match cssTagName "\*"
     39 
     40 syn match cssTagName "@page\>" nextgroup=cssDefinition
     41 
     42 syn match cssSelectorOp "[+>.]"
     43 syn match cssSelectorOp2 "[~|]\?=" contained
     44 syn region cssAttributeSelector matchgroup=cssSelectorOp start="\[" end="]" transparent contains=cssUnicodeEscape,cssSelectorOp2,cssStringQ,cssStringQQ
     45 
     46 try
     47 syn match cssIdentifier "#[A-Za-zÀ-ÿ_@][A-Za-zÀ-ÿ0-9_@-]*"
     48 catch /^.*/
     49 syn match cssIdentifier "#[A-Za-z_@][A-Za-z0-9_@-]*"
     50 endtry
     51 
     52 syn match cssMedia "@media\>" nextgroup=cssMediaType skipwhite skipnl
     53 syn keyword cssMediaType contained screen print aural braile embosed handheld projection ty tv all nextgroup=cssMediaComma,cssMediaBlock skipwhite skipnl
     54 syn match cssMediaComma "," nextgroup=cssMediaType skipwhite skipnl
     55 syn region cssMediaBlock transparent matchgroup=cssBraces start='{' end='}' contains=cssTagName,cssError,cssComment,cssDefinition,cssURL,cssUnicodeEscape,cssIdentifier
     56 
     57 syn match cssValueInteger "[-+]\=\d\+"
     58 syn match cssValueNumber "[-+]\=\d\+\(\.\d*\)\="
     59 syn match cssValueLength "[-+]\=\d\+\(\.\d*\)\=\(%\|mm\|cm\|in\|pt\|pc\|em\|ex\|px\)"
     60 
     61 syn match cssValueAngle contained "[-+]\=\d\+\(\.\d*\)\=\(deg\|grad\|rad\)"
     62 syn match cssValueTime contained "+\=\d\+\(\.\d*\)\=\(ms\|s\)"
     63 syn match cssValueFrequency contained "+\=\d\+\(\.\d*\)\=\(Hz\|kHz\)"
     64 
     65 syn match cssFontDescriptor "@font-face\>" nextgroup=cssFontDescriptorBlock skipwhite skipnl
     66 syn region cssFontDescriptorBlock contained transparent matchgroup=cssBraces start="{" end="}" contains=cssComment,cssError,cssUnicodeEscape,cssFontProp,cssFontAttr,cssCommonAttr,cssStringQ,cssStringQQ,cssFontDescriptorProp,cssValue.*,cssFontDescriptorFunction,cssUnicodeRange,cssFontDescriptorAttr
     67 syn match cssFontDescriptorProp contained "\<\(unicode-range\|unit-per-em\|panose-1\|cap-height\|x-height\|definition-src\)\>"
     68 syn keyword cssFontDescriptorProp contained src stemv stemh slope ascent descent widths bbox baseline centerline mathline topline
     69 syn keyword cssFontDescriptorAttr contained all
     70 syn region cssFontDescriptorFunction contained matchgroup=cssFunctionName start="\<\(uri\|url\|local\|format\)\s*(" end=")" contains=cssStringQ,cssStringQQ oneline keepend
     71 syn match cssUnicodeRange contained "U+[0-9A-Fa-f?]\+"
     72 syn match cssUnicodeRange contained "U+\x\+-\x\+"
     73 
     74 syn keyword cssColor contained aqua black blue fuchsia gray green lime maroon navy olive purple red silver teal yellow
     75 " FIXME: These are actually case-insentivie too, but (a) specs recommend using
     76 " mixed-case (b) it's hard to highlight the word `Background' correctly in
     77 " all situations
     78 syn case match
     79 syn keyword cssColor contained ActiveBorder ActiveCaption AppWorkspace ButtonFace ButtonHighlight ButtonShadow ButtonText CaptionText GrayText Highlight HighlightText InactiveBorder InactiveCaption InactiveCaptionText InfoBackground InfoText Menu MenuText Scrollbar ThreeDDarkShadow ThreeDFace ThreeDHighlight ThreeDLightShadow ThreeDShadow Window WindowFrame WindowText Background
     80 syn case ignore
     81 syn match cssColor contained "\<transparent\>"
     82 syn match cssColor contained "\<white\>"
     83 syn match cssColor contained "#[0-9A-Fa-f]\{3\}\>"
     84 syn match cssColor contained "#[0-9A-Fa-f]\{6\}\>"
     85 "syn match cssColor contained "\<rgb\s*(\s*\d\+\(\.\d*\)\=%\=\s*,\s*\d\+\(\.\d*\)\=%\=\s*,\s*\d\+\(\.\d*\)\=%\=\s*)"
     86 syn region cssURL contained matchgroup=cssFunctionName start="\<url\s*(" end=")" oneline keepend
     87 syn region cssFunction contained matchgroup=cssFunctionName start="\<\(rgb\|clip\|attr\|counter\|rect\)\s*(" end=")" oneline keepend
     88 
     89 syn match cssImportant contained "!\s*important\>"
     90 
     91 syn keyword cssCommonAttr contained auto none inherit
     92 syn keyword cssCommonAttr contained top bottom
     93 syn keyword cssCommonAttr contained medium normal
     94 
     95 syn match cssFontProp contained "\<font\>\(-\(family\|style\|variant\|weight\|size\(-adjust\)\=\|stretch\)\>\)\="
     96 syn match cssFontAttr contained "\<\(sans-\)\=\<serif\>"
     97 syn match cssFontAttr contained "\<small\>\(-\(caps\|caption\)\>\)\="
     98 syn match cssFontAttr contained "\<x\{1,2\}-\(large\|small\)\>"
     99 syn match cssFontAttr contained "\<message-box\>"
    100 syn match cssFontAttr contained "\<status-bar\>"
    101 syn match cssFontAttr contained "\<\(\(ultra\|extra\|semi\|status-bar\)-\)\=\(condensed\|expanded\)\>"
    102 syn keyword cssFontAttr contained cursive fantasy monospace italic oblique
    103 syn keyword cssFontAttr contained bold bolder lighter larger smaller
    104 syn keyword cssFontAttr contained icon menu
    105 syn match cssFontAttr contained "\<caption\>"
    106 syn keyword cssFontAttr contained large smaller larger
    107 syn keyword cssFontAttr contained narrower wider
    108 
    109 syn keyword cssColorProp contained color
    110 syn match cssColorProp contained "\<background\(-\(color\|image\|attachment\|position\)\)\="
    111 syn keyword cssColorAttr contained center scroll fixed
    112 syn match cssColorAttr contained "\<repeat\(-[xy]\)\=\>"
    113 syn match cssColorAttr contained "\<no-repeat\>"
    114 
    115 syn match cssTextProp "\<\(\(word\|letter\)-spacing\|text\(-\(decoration\|transform\|align\|index\|shadow\)\)\=\|vertical-align\|unicode-bidi\|line-height\)\>"
    116 syn match cssTextAttr contained "\<line-through\>"
    117 syn match cssTextAttr contained "\<text-indent\>"
    118 syn match cssTextAttr contained "\<\(text-\)\=\(top\|bottom\)\>"
    119 syn keyword cssTextAttr contained underline overline blink sub super middle
    120 syn keyword cssTextAttr contained capitalize uppercase lowercase center justify baseline sub super
    121 
    122 syn match cssBoxProp contained "\<\(margin\|padding\|border\)\(-\(top\|right\|bottom\|left\)\)\=\>"
    123 syn match cssBoxProp contained "\<border-\(\(\(top\|right\|bottom\|left\)-\)\=\(width\|color\|style\)\)\=\>"
    124 syn match cssBoxProp contained "\<\(width\|z-index\)\>"
    125 syn match cssBoxProp contained "\<\(min\|max\)-\(width\|height\)\>"
    126 syn keyword cssBoxProp contained width height float clear overflow clip visibility
    127 syn keyword cssBoxAttr contained thin thick both
    128 syn keyword cssBoxAttr contained dotted dashed solid double groove ridge inset outset
    129 syn keyword cssBoxAttr contained hidden visible scroll collapse
    130 
    131 syn keyword cssGeneratedContentProp contained content quotes
    132 syn match cssGeneratedContentProp contained "\<counter-\(reset\|increment\)\>"
    133 syn match cssGeneratedContentProp contained "\<list-style\(-\(type\|position\|image\)\)\=\>"
    134 syn match cssGeneratedContentAttr contained "\<\(no-\)\=\(open\|close\)-quote\>"
    135 syn match cssAuralAttr contained "\<lower\>"
    136 syn match cssGeneratedContentAttr contained "\<\(lower\|upper\)-\(roman\|alpha\|greek\|latin\)\>"
    137 syn match cssGeneratedContentAttr contained "\<\(hiragana\|katakana\)\(-iroha\)\=\>"
    138 syn match cssGeneratedContentAttr contained "\<\(decimal\(-leading-zero\)\=\|cjk-ideographic\)\>"
    139 syn keyword cssGeneratedContentAttr contained disc circle square hebrew armenian georgian
    140 syn keyword cssGeneratedContentAttr contained inside outside
    141 
    142 syn match cssPagingProp contained "\<page\(-break-\(before\|after\|inside\)\)\=\>"
    143 syn keyword cssPagingProp contained size marks inside orphans widows
    144 syn keyword cssPagingAttr contained landscape portrait crop cross always avoid
    145 
    146 syn keyword cssUIProp contained cursor
    147 syn match cssUIProp contained "\<outline\(-\(width\|style\|color\)\)\=\>"
    148 syn match cssUIAttr contained "\<[ns]\=[ew]\=-resize\>"
    149 syn keyword cssUIAttr contained default crosshair pointer move wait help
    150 syn keyword cssUIAttr contained thin thick
    151 syn keyword cssUIAttr contained dotted dashed solid double groove ridge inset outset
    152 syn keyword cssUIAttr contained invert
    153 
    154 syn match cssRenderAttr contained "\<marker\>"
    155 syn match cssRenderProp contained "\<\(display\|marker-offset\|unicode-bidi\|white-space\|list-item\|run-in\|inline-table\)\>"
    156 syn keyword cssRenderProp contained position top bottom direction
    157 syn match cssRenderProp contained "\<\(left\|right\)\>"
    158 syn keyword cssRenderAttr contained block inline compact
    159 syn match cssRenderAttr contained "\<table\(-\(row-gorup\|\(header\|footer\)-group\|row\|column\(-group\)\=\|cell\|caption\)\)\=\>"
    160 syn keyword cssRenderAttr contained static relative absolute fixed
    161 syn keyword cssRenderAttr contained ltr rtl embed bidi-override pre nowrap
    162 syn match cssRenderAttr contained "\<bidi-override\>"
    163 
    164 syn match cssAuralProp contained "\<\(pause\|cue\)\(-\(before\|after\)\)\=\>"
    165 syn match cssAuralProp contained "\<\(play-during\|speech-rate\|voice-family\|pitch\(-range\)\=\|speak\(-\(punctuation\|numerals\)\)\=\)\>"
    166 syn keyword cssAuralProp contained volume during azimuth elevation stress richness
    167 syn match cssAuralAttr contained "\<\(x-\)\=\(soft\|loud\)\>"
    168 syn keyword cssAuralAttr contained silent
    169 syn match cssAuralAttr contained "\<spell-out\>"
    170 syn keyword cssAuralAttr contained non mix
    171 syn match cssAuralAttr contained "\<\(left\|right\)-side\>"
    172 syn match cssAuralAttr contained "\<\(far\|center\)-\(left\|center\|right\)\>"
    173 syn keyword cssAuralAttr contained leftwards rightwards behind
    174 syn keyword cssAuralAttr contained below level above higher
    175 syn match cssAuralAttr contained "\<\(x-\)\=\(slow\|fast\)\>"
    176 syn keyword cssAuralAttr contained faster slower
    177 syn keyword cssAuralAttr contained male female child code digits continuous
    178 
    179 syn match cssTableProp contained "\<\(caption-side\|table-layout\|border-collapse\|border-spacing\|empty-cells\|speak-header\)\>"
    180 syn keyword cssTableAttr contained fixed collapse separate show hide once always
    181 
    182 
    183 
    184 syn match lessComment "//.*$" contains=@Spell
    185 syn match lessVariable "@[A-Za-z_-][A-Za-z0-9_-]*" contained
    186 syn region lessVariableDefinition start="^@" end=";" contains=css.*Attr,css.*Prop,cssComment,cssValue.*,cssColor,cssURL,cssImportant,cssStringQ,cssStringQQ,cssFunction,cssUnicodeEscape,cssDefinition,cssClassName,cssTagName,cssIdentifier,lessComment,lessVariable,lessFunction
    187 
    188 " captures both the definition and the call
    189 syn region lessFunction matchgroup=lessFuncDef start="@[A-Za-z_-][A-Za-z0-9_-]*(" end=")" contains=css.*Attr,css.*Prop,cssComment,cssValue.*,cssColor,cssURL,cssImportant,cssStringQ,cssStringQQ,cssFunction,cssUnicodeEscape,cssDefinition,cssClassName,cssTagName,cssIdentifier,lessComment,lessVariable,lessFunction
    190 
    191 
    192 
    193 
    194 
    195 " FIXME: This allows cssMediaBlock before the semicolon, which is wrong.
    196 syn region cssInclude start="@import" end=";" contains=cssComment,cssURL,cssUnicodeEscape,cssMediaType
    197 syn match cssBraces contained "[{}]"
    198 syn match cssError contained "{@<>"
    199 syn region cssDefinition transparent matchgroup=cssBraces start='{' end='}' contains=css.*Attr,css.*Prop,cssComment,cssValue.*,cssColor,cssURL,cssImportant,cssStringQ,cssStringQQ,cssFunction,cssUnicodeEscape,cssDefinition,cssClassName,cssTagName,cssIdentifier,lessComment,lessVariable,lessFunction
    200 " syn match cssBraceError "}"
    201 
    202 syn match cssPseudoClass ":\S*" contains=cssPseudoClassId,cssUnicodeEscape
    203 syn keyword cssPseudoClassId contained link visited active hover focus before after left right
    204 syn match cssPseudoClassId contained "\<first\(-\(line\|letter\|child\)\)\=\>"
    205 syn region cssPseudoClassLang matchgroup=cssPseudoClassId start=":lang(" end=")" oneline
    206 
    207 syn region cssComment start="/\*" end="\*/" contains=@Spell
    208 
    209 syn match cssUnicodeEscape "\\\x\{1,6}\s\?"
    210 syn match cssSpecialCharQQ +\\"+ contained
    211 syn match cssSpecialCharQ +\\'+ contained
    212 syn region cssStringQQ start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=cssUnicodeEscape,cssSpecialCharQQ
    213 syn region cssStringQ start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=cssUnicodeEscape,cssSpecialCharQ
    214 syn match cssClassName "\.[A-Za-z][A-Za-z0-9_-]\+"
    215 
    216 
    217 
    218 
    219 if main_syntax == "css"
    220   syn sync minlines=10
    221 endif
    222 
    223 " Define the default highlighting.
    224 " For version 5.7 and earlier: only when not done already
    225 " For version 5.8 and later: only when an item doesn't have highlighting yet
    226 if version >= 508 || !exists("did_less_syn_inits")
    227   if version < 508
    228     let did_less_syn_inits = 1
    229     command -nargs=+ HiLink hi link <args>
    230   else
    231     command -nargs=+ HiLink hi def link <args>
    232   endif
    233 
    234   HiLink lessComment Comment
    235   HiLink lessVariable Special
    236   HiLink lessFuncDef Function
    237   HiLink cssComment Comment
    238   HiLink cssTagName Statement
    239   HiLink cssSelectorOp Special
    240   HiLink cssSelectorOp2 Special
    241   HiLink cssFontProp StorageClass
    242   HiLink cssColorProp storageClass
    243   HiLink cssTextProp StorageClass
    244   HiLink cssBoxProp StorageClass
    245   HiLink cssRenderProp StorageClass
    246   HiLink cssAuralProp StorageClass
    247   HiLink cssRenderProp StorageClass
    248   HiLink cssGeneratedContentProp StorageClass
    249   HiLink cssPagingProp StorageClass
    250   HiLink cssTableProp StorageClass
    251   HiLink cssUIProp StorageClass
    252   HiLink cssFontAttr Type
    253   HiLink cssColorAttr Type
    254   HiLink cssTextAttr Type
    255   HiLink cssBoxAttr Type
    256   HiLink cssRenderAttr Type
    257   HiLink cssAuralAttr Type
    258   HiLink cssGeneratedContentAttr Type
    259   HiLink cssPagingAttr Type
    260   HiLink cssTableAttr Type
    261   HiLink cssUIAttr Type
    262   HiLink cssCommonAttr Type
    263   HiLink cssPseudoClassId PreProc
    264   HiLink cssPseudoClassLang Constant
    265   HiLink cssValueLength Number
    266   HiLink cssValueInteger Number
    267   HiLink cssValueNumber Number
    268   HiLink cssValueAngle Number
    269   HiLink cssValueTime Number
    270   HiLink cssValueFrequency Number
    271   HiLink cssFunction Constant
    272   HiLink cssURL String
    273   HiLink cssFunctionName Function
    274   HiLink cssColor Constant
    275   HiLink cssIdentifier Function
    276   HiLink cssInclude Include
    277   HiLink cssImportant Special
    278   HiLink cssBraces SpecialChar
    279   HiLink cssBraceError Error
    280   HiLink cssError Error
    281   HiLink cssInclude Include
    282   HiLink cssUnicodeEscape Special
    283   HiLink cssStringQQ String
    284   HiLink cssStringQ String
    285   HiLink cssMedia Special
    286   HiLink cssMediaType Special
    287   HiLink cssMediaComma Normal
    288   HiLink cssFontDescriptor Special
    289   HiLink cssFontDescriptorFunction Constant
    290   HiLink cssFontDescriptorProp StorageClass
    291   HiLink cssFontDescriptorAttr Type
    292   HiLink cssUnicodeRange Constant
    293   HiLink cssClassName Function
    294   delcommand HiLink
    295 endif
    296 
    297 let b:current_syntax = "less"
    298 
    299 if main_syntax == 'less'
    300   unlet main_syntax
    301 endif
    302 
    303 
    304 " vim: ts=8
    305