styled-components / vim-styled-components

Vim bundle for http://styled-components.com based javascript files.
300 stars 24 forks source link

Style `&` #1

Closed fleischie closed 7 years ago

fleischie commented 7 years ago

Make & symbol highlight differently than plain old strings.

fleischie commented 7 years ago

I'm closing this issue for now, as I don't actually see a benefit from doing this. :roll_eyes:

If this should come up again, the solution would be something like this:

syn match styledAmpersand contained "&"
if version >= 508 || !exists("did_styled_components_syn_inits")
  if version < 508
    let did_styled_components_syn_inits = 1
    command -nargs=+ HiLink hi link <args>
  else
    command -nargs=+ HiLink hi def link <args>
  endif

  HiLink styledAmpersand Special    " or whatever

  delcommand HiLink
endif

syntax region cssDefinition matchGroup=cssBraces start=+{+ end=+}+ contains=styledAmpersand
syntax region jsTemplateString start=+`+ skip=+\\\(`\|$\)+ end=+`+ contains=styledAmpersand