crystal-lang-tools / sublime-crystal

Crystal syntax highlighting for Sublime Text
Other
86 stars 18 forks source link

Support for ECR #46

Open shobhitic opened 6 years ago

shobhitic commented 6 years ago

Currently, the .ecr files are being shown as Plain Text files. I couldn't find a way to syntax highlight there. I think it should be a part of official crystal sublime package.

sardaukar commented 4 years ago

I got it to work (kinda), but not sure how to make it into a package. Just save this

%YAML 1.2
---
file_extensions:
  - ecr
scope: text.html.ruby

contexts:
  main:
    - match: ''
      push: 'scope:text.html.basic'
      with_prototype:
        - match: "<%+#"
          scope: punctuation.definition.comment.ecr
          push:
            - meta_scope: comment.block.ecr
            - match: "%>"
              pop: true
        - match: "<%+(?!>)[-=]?"
          scope: punctuation.section.embedded.crystal
          push:
            - meta_scope: source.crystal.embedded.html
            - match: "-?%>"
              scope: punctuation.section.embedded.crystal
              pop: true
            - match: (#).*?(?=-?%>)
              scope: comment.line.number-sign.crystal
              captures:
                1: punctuation.definition.comment.crystal
            - include: "Crystal.sublime-syntax"

as ECR.sublime-syntax on your User packages folder.

plambert commented 6 months ago

This also works for me; it's not perfect but way better than nothing. :)