diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2017-02-02 23:23:52 +0100 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2017-02-02 23:23:52 +0100 |
commit | 6e9529be4e0c2b0b42e5eb51fad1c34bae6f56fc (patch) | |
tree | 4bdaa1decc2241814e5de4de04d3ee39df4b3684 /syntax | |
parent | 462bb76e06c9efa66cc4bae098dcc5497dd1069d (diff) | |
download | vim-polyglot-2.14.0.tar.gz vim-polyglot-2.14.0.zip |
Change scss provider to cakebaker, closes #173v2.14.0
Diffstat (limited to '')
-rw-r--r-- | syntax/sass.vim | 110 | ||||
-rw-r--r-- | syntax/scss.vim | 227 |
2 files changed, 214 insertions, 123 deletions
diff --git a/syntax/sass.vim b/syntax/sass.vim deleted file mode 100644 index b4df8a84..00000000 --- a/syntax/sass.vim +++ /dev/null @@ -1,110 +0,0 @@ -if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'haml') == -1 - -" Vim syntax file -" Language: Sass -" Maintainer: Tim Pope <vimNOSPAM@tpope.org> -" Filenames: *.sass -" Last Change: 2010 Aug 09 - -if exists("b:current_syntax") - finish -endif - -runtime! syntax/css.vim - -syn case ignore - -syn cluster sassCssProperties contains=cssFontProp,cssFontDescriptorProp,cssColorProp,cssTextProp,cssBoxProp,cssGeneratedContentProp,cssPagingProp,cssUIProp,cssRenderProp,cssAuralProp,cssTableProp -syn cluster sassCssAttributes contains=css.*Attr,sassEndOfLineComment,scssComment,cssValue.*,cssColor,cssURL,sassDefault,cssImportant,cssError,cssStringQ,cssStringQQ,cssFunction,cssUnicodeEscape,cssRenderProp - -syn region sassDefinition matchgroup=cssBraces start="{" end="}" contains=TOP - -syn match sassProperty "\%([{};]\s*\|^\)\@<=\%([[:alnum:]-]\|#{[^{}]*}\)\+\s*:" contains=css.*Prop skipwhite nextgroup=sassCssAttribute contained containedin=sassDefinition -syn match sassProperty "^\s*\zs\s\%(\%([[:alnum:]-]\|#{[^{}]*}\)\+\s*:\|:[[:alnum:]-]\+\)"hs=s+1 contains=css.*Prop skipwhite nextgroup=sassCssAttribute -syn match sassProperty "^\s*\zs\s\%(:\=[[:alnum:]-]\+\s*=\)"hs=s+1 contains=css.*Prop skipwhite nextgroup=sassCssAttribute -syn match sassCssAttribute +\%("\%([^"]\|\\"\)*"\|'\%([^']\|\\'\)*'\|#{[^{}]*}\|[^{};]\)*+ contained contains=@sassCssAttributes,sassVariable,sassFunction,sassInterpolation -syn match sassDefault "!default\>" contained -syn match sassVariable "!\%(important\>\|default\>\)\@![[:alnum:]_-]\+" -syn match sassVariable "$[[:alnum:]_-]\+" -syn match sassVariableAssignment "\%([!$][[:alnum:]_-]\+\s*\)\@<=\%(||\)\==" nextgroup=sassCssAttribute skipwhite -syn match sassVariableAssignment "\%([!$][[:alnum:]_-]\+\s*\)\@<=:" nextgroup=sassCssAttribute skipwhite - -syn match sassFunction "\<\%(rgb\|rgba\|red\|green\|blue\|mix\)\>(\@=" contained -syn match sassFunction "\<\%(hsl\|hsla\|hue\|saturation\|lightness\|adjust-hue\|lighten\|darken\|saturate\|desaturate\|grayscale\|complement\)\>(\@=" contained -syn match sassFunction "\<\%(alpha\|opacity\|rgba\|opacify\|fade-in\|transparentize\|fade-out\)\>(\@=" contained -syn match sassFunction "\<\%(unquote\|quote\)\>(\@=" contained -syn match sassFunction "\<\%(percentage\|round\|ceil\|floor\|abs\)\>(\@=" contained -syn match sassFunction "\<\%(type-of\|unit\|unitless\|comparable\)\>(\@=" contained - -syn region sassInterpolation matchgroup=sassInterpolationDelimiter start="#{" end="}" contains=@sassCssAttributes,sassVariable,sassFunction containedin=cssStringQ,cssStringQQ,cssPseudoClass,sassProperty - -syn match sassMixinName "[[:alnum:]_-]\+" contained nextgroup=sassCssAttribute -syn match sassMixin "^=" nextgroup=sassMixinName skipwhite -syn match sassMixin "\%([{};]\s*\|^\s*\)\@<=@mixin" nextgroup=sassMixinName skipwhite -syn match sassMixing "^\s\+\zs+" nextgroup=sassMixinName -syn match sassMixing "\%([{};]\s*\|^\s*\)\@<=@include" nextgroup=sassMixinName skipwhite -syn match sassExtend "\%([{};]\s*\|^\s*\)\@<=@extend" -syn match sassPlaceholder "\%([{};]\s*\|^\s*\)\@<=%" nextgroup=sassMixinName skipwhite - -syn match sassFunctionName "[[:alnum:]_-]\+" contained nextgroup=sassCssAttribute -syn match sassFunctionDecl "\%([{};]\s*\|^\s*\)\@<=@function" nextgroup=sassFunctionName skipwhite -syn match sassReturn "\%([{};]\s*\|^\s*\)\@<=@return" - -syn match sassEscape "^\s*\zs\\" -syn match sassIdChar "#[[:alnum:]_-]\@=" nextgroup=sassId -syn match sassId "[[:alnum:]_-]\+" contained -syn match sassClassChar "\.[[:alnum:]_-]\@=" nextgroup=sassClass -syn match sassClass "[[:alnum:]_-]\+" contained -syn match sassAmpersand "&" - -" TODO: Attribute namespaces -" TODO: Arithmetic (including strings and concatenation) - -syn region sassMediaQuery matchgroup=sassMedia start="@media" end="[{};]\@=\|$" contains=sassMediaOperators -syn keyword sassMediaOperators and not only contained -syn region sassCharset start="@charset" end=";\|$" contains=scssComment,cssStringQ,cssStringQQ,cssURL,cssUnicodeEscape,cssMediaType -syn region sassInclude start="@import" end=";\|$" contains=scssComment,cssStringQ,cssStringQQ,cssURL,cssUnicodeEscape,cssMediaType -syn region sassDebugLine end=";\|$" matchgroup=sassDebug start="@debug\>" contains=@sassCssAttributes,sassVariable,sassFunction -syn region sassWarnLine end=";\|$" matchgroup=sassWarn start="@warn\>" contains=@sassCssAttributes,sassVariable,sassFunction -syn region sassControlLine matchgroup=sassControl start="@\%(if\|else\%(\s\+if\)\=\|while\|for\|each\)\>" end="[{};]\@=\|$" contains=sassFor,@sassCssAttributes,sassVariable,sassFunction -syn keyword sassFor from to through in contained - -syn keyword sassTodo FIXME NOTE TODO OPTIMIZE XXX contained -syn region sassComment start="^\z(\s*\)//" end="^\%(\z1 \)\@!" contains=sassTodo,@Spell -syn region sassCssComment start="^\z(\s*\)/\*" end="^\%(\z1 \)\@!" contains=sassTodo,@Spell -syn match sassEndOfLineComment "//.*" contains=sassComment,sassTodo,@Spell - -hi def link sassEndOfLineComment sassComment -hi def link sassCssComment sassComment -hi def link sassComment Comment -hi def link sassDefault cssImportant -hi def link sassVariable Identifier -hi def link sassFunction Function -hi def link sassMixing PreProc -hi def link sassMixin PreProc -hi def link sassPlaceholder PreProc -hi def link sassExtend PreProc -hi def link sassFunctionDecl PreProc -hi def link sassReturn PreProc -hi def link sassTodo Todo -hi def link sassCharset PreProc -hi def link sassMedia PreProc -hi def link sassMediaOperators PreProc -hi def link sassInclude Include -hi def link sassDebug sassControl -hi def link sassWarn sassControl -hi def link sassControl PreProc -hi def link sassFor PreProc -hi def link sassEscape Special -hi def link sassIdChar Special -hi def link sassClassChar Special -hi def link sassInterpolationDelimiter Delimiter -hi def link sassAmpersand Character -hi def link sassId Identifier -hi def link sassClass Type - -let b:current_syntax = "sass" - -" vim:set sw=2: - -endif diff --git a/syntax/scss.vim b/syntax/scss.vim index cb3e0fe9..15b8359c 100644 --- a/syntax/scss.vim +++ b/syntax/scss.vim @@ -1,24 +1,225 @@ -if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'haml') == -1 +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'scss') == -1 " Vim syntax file -" Language: SCSS -" Maintainer: Tim Pope <vimNOSPAM@tpope.org> -" Filenames: *.scss -" Last Change: 2010 Jul 26 +" Language: SCSS (Sassy CSS) +" Author: Daniel Hofstetter (daniel.hofstetter@42dh.com) +" URL: https://github.com/cakebaker/scss-syntax.vim +" Last Change: 2015-04-22 +" Inspired by the syntax files for sass and css. Thanks to the authors of +" those files! -if exists("b:current_syntax") - finish +if !exists("main_syntax") + if exists("b:current_syntax") + finish + endif + let main_syntax = 'scss' endif -runtime! syntax/sass.vim +runtime! syntax/css.vim +runtime! syntax/css/*.vim -syn match scssComment "//.*" contains=sassTodo,@Spell -syn region scssComment start="/\*" end="\*/" contains=sassTodo,@Spell +syn case ignore -hi def link scssComment sassComment +" XXX fix for #20, can be removed once the patch is in vim's css.vim +syn match cssSpecialCharQQ +\\\\\|\\"+ contained +syn match cssSpecialCharQ +\\\\\|\\'+ contained -let b:current_syntax = "scss" +" XXX fix for #37 +if v:version < 704 + " replace the definition of cssBoxProp with the one from Vim 7.4 to prevent + " highlighting issues + syn clear cssBoxProp + syn match cssBoxProp contained "\<padding\(-\(top\|right\|bottom\|left\)\)\=\>" + syn match cssBoxProp contained "\<margin\(-\(top\|right\|bottom\|left\)\)\=\>" + syn match cssBoxProp contained "\<overflow\(-\(x\|y\|style\)\)\=\>" + syn match cssBoxProp contained "\<rotation\(-point\)\=\>" +endif + +" override @font-face blocks to allow scss elements inside +syn region cssFontDescriptorBlock contained transparent matchgroup=cssBraces start="{" end="}" contains=cssError,cssUnicodeEscape,cssFontProp,cssFontAttr,cssCommonAttr,cssStringQ,cssStringQQ,cssFontDescriptorProp,cssValue.*,cssFontDescriptorFunction,cssUnicodeRange,cssFontDescriptorAttr,@comment,scssDefinition,scssFunction,scssVariable,@scssControl,scssDebug,scssError,scssWarn + +syn region scssDefinition matchgroup=cssBraces start='{' end='}' contains=cssString.*,cssInclude,cssFontDescriptor,scssAtRootStatement,@comment,scssDefinition,scssProperty,scssSelector,scssVariable,scssImport,scssExtend,scssInclude,scssInterpolation,scssFunction,@scssControl,scssWarn,scssError,scssDebug,scssReturn containedin=cssMediaBlock fold + +syn match scssSelector _^\zs\([^:@]\|:[^ ]\|['"].*['"]\)\+{\@=_ contained contains=@scssSelectors +syn match scssSelector "^\s*\zs\([^:@{]\|:[^ ]\|['"].*['"]\)\+\_$" contained contains=@scssSelectors +" fix for #54 to recognize a multiline selector containing a string interpolation +syn match scssSelector "^\zs\([^:@]\|:[^ ]\)\+#{.*}[^;{]\+\_$" contained contains=@scssSelectors +syn cluster scssSelectors contains=@comment,cssSelectorOp,cssTagName,cssPseudoClass,cssAttributeSelector,scssSelectorChar,scssAmpersand,scssInterpolation + +syn match scssProperty "\([[:alnum:]-]\)\+\s*\(:\)\@=" contained contains=css.*Prop,cssVendor containedin=cssMediaBlock nextgroup=scssAttribute,scssAttributeWithNestedDefinition +syn match scssAttribute ":[^;]*\ze\(;\|}\)" contained contains=css.*Attr,cssValue.*,cssColor,cssFunction,cssString.*,cssURL,scssFunction,scssInterpolation,scssVariable + +syn match scssAttributeWithNestedDefinition ": [^#]*{\@=" nextgroup=scssNestedDefinition contained contains=css.*Attr,cssValue.*,scssVariable +syn region scssNestedDefinition matchgroup=cssBraces start="{" end="}" contained contains=@comment,scssProperty,scssNestedProperty + +" CSS properties from https://developer.mozilla.org/en-US/docs/Web/CSS/Reference +" align +syn keyword scssNestedProperty contained content items self nextgroup=scssAttribute +" animation +syn keyword scssNestedProperty contained delay direction duration fill-mode iteration-count name play-state timing-function nextgroup=scssAttribute +" background +syn keyword scssNestedProperty contained attachment clip color image origin position repeat size nextgroup=scssAttribute +" border +syn keyword scssNestedProperty contained bottom bottom-color bottom-left-radius bottom-right-radius bottom-style bottom-width nextgroup=scssAttribute +syn keyword scssNestedProperty contained collapse color nextgroup=scssAttribute +syn keyword scssNestedProperty contained image image-outset image-repeat image-slice image-source image-width nextgroup=scssAttribute +syn keyword scssNestedProperty contained left left-color left-style left-width nextgroup=scssAttribute +syn keyword scssNestedProperty contained radius nextgroup=scssAttribute +syn keyword scssNestedProperty contained right right-color right-style right-width nextgroup=scssAttribute +syn keyword scssNestedProperty contained spacing style nextgroup=scssAttribute +syn keyword scssNestedProperty contained top top-color top-left-radius top-right-radius top-style top-width nextgroup=scssAttribute +syn keyword scssNestedProperty contained width nextgroup=scssAttribute +" box +syn keyword scssNestedProperty contained decoration-break shadow sizing nextgroup=scssAttribute +" break +syn keyword scssNestedProperty contained after before inside nextgroup=scssAttribute +" column +syn keyword scssNestedProperty contained count fill gap rule rule-color rule-style rule-width span width nextgroup=scssAttribute +" counter +syn keyword scssNestedProperty contained increment reset nextgroup=scssAttribute +" flex +syn keyword scssNestedProperty contained basis direction flow grow shrink wrap nextgroup=scssAttribute +" font +syn keyword scssNestedProperty contained family feature-settings kerning language-override size size-adjust stretch style synthesis nextgroup=scssAttribute +syn keyword scssNestedProperty contained variant variant-alternates variant-caps variant-east-asian variant-ligatures variant-numeric variant-position nextgroup=scssAttribute +syn keyword scssNestedProperty contained weight nextgroup=scssAttribute +" image +syn keyword scssNestedProperty contained rendering resolution orientation nextgroup=scssAttribute +" list +syn keyword scssNestedProperty contained style style-image style-position style-type nextgroup=scssAttribute +" margin/padding +syn keyword scssNestedProperty contained bottom left right top nextgroup=scssAttribute +" max/min +syn keyword scssNestedProperty contained height width nextgroup=scssAttribute +" nav +syn keyword scssNestedProperty contained down index left right up nextgroup=scssAttribute +" object +syn keyword scssNestedProperty contained fit position nextgroup=scssAttribute +" outline +syn keyword scssNestedProperty contained color offset style width nextgroup=scssAttribute +" overflow +syn keyword scssNestedProperty contained wrap x y nextgroup=scssAttribute +" page +syn keyword scssNestedProperty contained break-after break-before break-inside nextgroup=scssAttribute +" text +syn keyword scssNestedProperty contained align align-last combine-horizontal nextgroup=scssAttribute +syn keyword scssNestedProperty contained decoration decoration-color decoration-line decoration-style nextgroup=scssAttribute +syn keyword scssNestedProperty contained indent orientation overflow rendering shadow transform underline-position nextgroup=scssAttribute +" transform +syn keyword scssNestedProperty contained origin style nextgroup=scssAttribute +" transition +syn keyword scssNestedProperty contained delay duration property timing-function nextgroup=scssAttribute +" unicode +syn keyword scssNestedProperty contained bidi range nextgroup=scssAttribute +" word +syn keyword scssNestedProperty contained break spacing wrap nextgroup=scssAttribute + +syn region scssInterpolation matchgroup=scssInterpolationDelimiter start="#{" end="}" contains=cssValue.*,cssColor,cssString.*,scssFunction,scssVariable containedin=cssComment,cssInclude,cssPseudoClassFn,cssPseudoClassLang,cssString.*,cssURL,scssFunction + +" ignores the url() function so it can be handled by css.vim +syn region scssFunction contained matchgroup=scssFunctionName start="\<\(url(\)\@!\([[:alnum:]-_]\)\+\s*(" skip=+([^)]*)+ end=")" keepend extend containedin=cssInclude,cssMediaType +syn match scssParameterList ".*" contained containedin=cssFunction,scssFunction contains=css.*Attr,cssColor,cssString.*,cssValue.*,scssBoolean,scssFunction,scssInterpolation,scssMap,scssNull,scssVariable + +syn match scssVariable "$[[:alnum:]_-]\+" containedin=cssFunction,scssFunction,cssInclude,cssMediaBlock,cssMediaType nextgroup=scssVariableAssignment skipwhite +syn match scssVariableAssignment ":" contained nextgroup=scssVariableValue skipwhite +syn region scssVariableValue start="" end="\ze[;)]" contained contains=css.*Attr,cssValue.*,cssColor,cssFunction,cssString.*,cssURL,scssBoolean,scssDefault,scssFunction,scssInterpolation,scssNull,scssVariable,scssMap,scssGlobal,scssAmpersand,@comment +syn match scssGlobal "!global" contained + +syn keyword scssNull null contained +syn keyword scssBoolean true false contained +syn keyword scssBooleanOp and or not contained -" vim:set sw=2: +syn match scssMixin "^@mixin" nextgroup=scssMixinName skipwhite +syn match scssMixinName "[[:alnum:]_-]\+" contained nextgroup=scssDefinition,scssMixinParams +syn region scssMixinParams contained contains=css.*Attr,cssColor,cssValue.*,cssString.*,cssUrl,cssBoxProp,cssDimensionProp,@comment,scssBoolean,scssNull,scssVariable,scssFunction start="(" end=")" extend +syn match scssInclude "@include" nextgroup=scssMixinName skipwhite containedin=cssMediaBlock +syn match scssContent "@content" contained containedin=scssDefinition + +syn match scssFunctionDefinition "^@function" nextgroup=scssFunctionNameWithWhitespace skipwhite +syn match scssFunctionNameWithWhitespace "[[:alnum:]_-]\+\s*" contained contains=scssFunctionName nextgroup=scssFunctionParams +syn match scssFunctionName "[[:alnum:]_-]\+" contained +syn region scssFunctionParams contained start="(" end=")" nextgroup=scssFunctionBody contains=scssVariable skipwhite +syn region scssFunctionBody contained matchgroup=cssBraces start="{" end="}" contains=cssString.*,cssValue.*,@scssControl,scssBooleanOp,scssComment,scssVariable,scssReturn,scssFunction,scssDebug,scssError,scssWarn,scssDefinition,scssInterpolation fold +syn match scssReturn "@return" contained +syn match scssExtend "@extend" nextgroup=scssExtendedSelector skipwhite containedin=cssMediaBlock +syn match scssExtendedSelector "[^;]\+" contained contains=cssTagName,cssPseudoClass,scssOptional,scssSelectorChar skipwhite +syn match scssOptional "!optional" contained +syn match scssImport "@import" nextgroup=scssImportList +syn match scssImportList "[^;]\+" contained contains=cssString.*,cssMediaType,cssURL + +syn match scssSelectorChar "\(#\|\.\|%\)\([[:alnum:]_-]\|#{.*}\)\@=" nextgroup=scssSelectorName containedin=cssMediaBlock,cssPseudoClassFn +syn match scssSelectorName "\([[:alnum:]_-]\|#{[^}]*}\)\+" contained contains=scssInterpolation + +syn match scssAmpersand "&" nextgroup=cssPseudoClass,scssSelectorName containedin=cssMediaBlock + +syn match scssDebug "@debug" nextgroup=scssOutput +syn match scssWarn "@warn" nextgroup=scssOutput +syn match scssError "@error" nextgroup=scssOutput +syn match scssOutput "[^;]\+" contained contains=cssValue.*,cssString.*,scssFunction,scssVariable +syn match scssDefault "!default" contained + +syn match scssIf "@\=if" nextgroup=scssCondition +syn match scssCondition "[^{]\+" contained contains=cssValue.*,cssString.*,scssBoolean,scssBooleanOp,scssFunction,scssNull,scssVariable,scssAmpersand +syn match scssElse "@else" nextgroup=scssIf +syn match scssElse "@else\(\s*\({\|$\)\)\@=" +syn match scssWhile "@while" nextgroup=scssCondition +syn match scssFor "@for\s\+.*from\s\+.*\(to\|through\)\s\+[^{ ]\+" contains=cssValueNumber,scssFunction,scssVariable,scssForKeyword +syn match scssForKeyword "@for\|from\|to\|through" contained +syn region scssEach matchgroup=scssEachKeyword start="@each" end="in" contains=scssVariable nextgroup=scssCollection +syn region scssCollection start=" " end="\ze{" contained contains=scssFunction,scssMap,scssVariable +syn cluster scssControl contains=scssIf,scssElse,scssWhile,scssFor,scssEach + +syn region scssMap matchgroup=scssMapParens start="[^:alpha:]\=\zs(\ze\(\s*\n.*:\|.\+:\)" end=")" contains=@comment,scssMapKey extend +syn match scssMapKey "[^: ]\+\ze[:]" contained contains=css.*Attr,cssString.*,scssVariable nextgroup=scssMapValue +syn match scssMapValue "[^,)]\+\ze[,)]" contained contains=cssColor,css.*Prop,cssString.*,cssValueLength,scssBoolean,scssFunction,scssNull,scssVariable + +syn region scssAtRootStatement start="@at-root" end="\ze{" contains=@scssSelectors,scssAtRoot +syn match scssAtRoot "@at-root" contained +syn match scssAtRoot "(\zswith\(out\)\=\ze:" contained + +syn match scssComment "//.*$" contains=@Spell containedin=cssMediaBlock +syn cluster comment contains=cssComment,scssComment +syn match scssStickyCommentChar "^\/\*\zs!" contained containedin=cssComment +syn keyword scssTodo TODO FIXME NOTE OPTIMIZE XXX contained containedin=@comment + +hi def link scssNestedProperty cssProp +hi def link scssVariable Identifier +hi def link scssGlobal Special +hi def link scssNull Constant +hi def link scssBoolean Constant +hi def link scssBooleanOp Operator +hi def link scssMixin PreProc +hi def link scssMixinName Function +hi def link scssContent PreProc +hi def link scssFunctionDefinition PreProc +hi def link scssFunctionName Function +hi def link scssReturn Statement +hi def link scssInclude PreProc +hi def link scssExtend PreProc +hi def link scssOptional Special +hi def link scssComment Comment +hi def link scssStickyCommentChar Special +hi def link scssSelectorChar Special +hi def link scssSelectorName Identifier +hi def link scssAmpersand Character +hi def link scssDebug Debug +hi def link scssWarn Debug +hi def link scssError Debug +hi def link scssDefault Special +hi def link scssIf Conditional +hi def link scssElse Conditional +hi def link scssWhile Repeat +hi def link scssForKeyword Repeat +hi def link scssEachKeyword Repeat +hi def link scssInterpolationDelimiter Delimiter +hi def link scssImport Include +hi def link scssTodo Todo +hi def link scssAtRoot Keyword +hi def link scssMapParens Delimiter + +let b:current_syntax = "scss" +if main_syntax == 'scss' + unlet main_syntax +endif endif |