osoco / sublimetext-grails

Grails support for Sublime Text
75 stars 21 forks source link

Skriptlet highlighting in GSP #7

Closed tom-metz closed 10 years ago

tom-metz commented 11 years ago

There are 2 issues with scriptlet code in GSP

  1. There is no "groovy" syntax highlighting in the scriptlet code. This is a small problem.
  2. The code of the scriptlet is not visually different from HTML code, if the scriptlet is used in HTML attribute, e.g. in custom tag parameter:
<mytag value="${example.size()}" />
gcrick commented 10 years ago
  1. You are right that there is no groovy syntax highlighting when a scriptlet is inside an HTML attribute. I'll try to take a look at that. There is highlighting for scriptlets outside of HTML attributes and in grails tag attributes though.
  2. Other than the broken case mentioned above, this is a question of changing your color scheme. For example, when used in a grails tag attribute, the symbols ${} get the scope "punctuation.section.embedded.groovy", so you could modify your color scheme to show them differently. Maybe in the future we will look at providing a basic color scheme with the plugin, to be used as a sample.
tom-metz commented 10 years ago

ad 2. That's strange, I have a working syntax highlighting for Groovy code. I'll try to dig into it a little bit more :-)

gcrick commented 10 years ago

I think this problem should be fixed in the latest version (1.0.1). Please re-open if you still see the issue after updating.

tom-metz commented 10 years ago

Very nice improvement!

I just found, that there is different color for the scriptlet in tag attribute and out of it, but that's very low priority ;-)

You can look at the images in attachement, see the difference between ST and IntelliJ Idea.

st2_groovy_syntax_highlight_in_gsp_20131023

idea_groovy_syntax_highlight_in_gsp_20131023

gcrick commented 10 years ago

Thanks for the feedback! I noticed that problem too, but I decided to leave it as is. It seems to be more of a colour scheme issue really. The cause is that scriptlets inside of tag attributes get extra scope selectors (as they should), for example to indicate that they are inside double or single quotes. The default colour schemes happen to provide colours for those scopes, so the result ends up looking different depending on where it is located. It is possible to edit a color scheme so that it works the way you want. For example, I just did a fast test with the Twilight theme. One way to get what you want would be to delete the definition for the scope "string constant", change the color of the scope "string source" to #FFFFFF, and add a new definition:

<dict>
    <key>name</key>
    <string>Groovy</string>
    <key>scope</key>
    <string>punctuation.definition.embedded</string>
    <key>settings</key>
    <dict>
        <key>fontStyle</key>
        <string></string>
        <key>foreground</key>
        <string>#f00</string><!-- Bright red, yikes! -->
    </dict>
</dict>
tom-metz commented 10 years ago

You're welcome, it's great, when someone makes anything more for the community! :-) I am not so deep in the ST, but this will force to start ;-) The autocompletion for dynamic finders is a challenge ;-)