Hi all,
Is it possible to fix the YAML inline-hash syntax highlighting? Working with Symfony, it's very common to have inline hashes in the routing.yml file. They look something like:
feed_enhanced: url: /recently-added.xml param: { module: feed, action: enhanced }
The YAML bundle considers "feed, action: enhanced" to be a value for "module:" where "action:" should be a new key.
Is there a fix? I've briefly looked at fixing it, but I'm not familiar enough with the TM syntax definition to figure this out on my own.
Thanks, -- -Jacob
Found a fix, along with a fix for comments at the end of lines not being highlighted correctly:
Index: Syntaxes/YAML.plist =================================================================== --- Syntaxes/YAML.plist (revision 10988) +++ Syntaxes/YAML.plist (working copy) @@ -118,7 +118,7 @@ </dict> </dict> <key>match</key> - <string>(?:(?:(-\s*)?(\w+\s*(:)))|(-))\s*([A-Za-z0-9_].*)\s*$</ string> + <string>(?:(?:(-\s*)?(\w+\s*(:)))|(-))\s*([^,{}&#]+)\s*</string> <key>name</key> <string>string.unquoted.yaml</string> </dict>
Basically, I changed it from defining an unquoted string as "a leading word or digit or underscore followed by anything to the eol" to "anything that isn't in [,{}&#] and stop when you run out of chars"
It probably regresses some syntax highlighting, but nothing that I can obviously see or am concerned with.
On Dec 8, 2008, at 10:07 AM, Jacob Coby wrote:
Hi all,
Is it possible to fix the YAML inline-hash syntax highlighting? Working with Symfony, it's very common to have inline hashes in the routing.yml file. They look something like:
feed_enhanced: url: /recently-added.xml param: { module: feed, action: enhanced }
The YAML bundle considers "feed, action: enhanced" to be a value for "module:" where "action:" should be a new key.
Is there a fix? I've briefly looked at fixing it, but I'm not familiar enough with the TM syntax definition to figure this out on my own.
Thanks,
-Jacob
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
-- Jacob Coby Office: (336) 505-4320 jcoby@portallabs.com
On Dec 8, 2008, at 12:07 PM, Jacob Coby wrote:
Basically, I changed it from defining an unquoted string as "a leading word or digit or underscore followed by anything to the eol" to "anything that isn't in [,{}&#] and stop when you run out of chars"
It probably regresses some syntax highlighting, but nothing that I can obviously see or am concerned with.
Just committed this change, still a lot of missing items in the YAML bundle but that helped it some. Thanks!
On Dec 10, 2008, at 1:22 AM, Michael Sheets wrote:
On Dec 8, 2008, at 12:07 PM, Jacob Coby wrote:
Basically, I changed it from defining an unquoted string as "a leading word or digit or underscore followed by anything to the eol" to "anything that isn't in [,{}&#] and stop when you run out of chars"
It probably regresses some syntax highlighting, but nothing that I can obviously see or am concerned with.
Just committed this change, still a lot of missing items in the YAML bundle but that helped it some. Thanks!
Thanks.
I've updated it since the last email because it wasn't highlighting lists correctly.
Index: Syntaxes/YAML.plist =================================================================== --- Syntaxes/YAML.plist (revision 10988) +++ Syntaxes/YAML.plist (working copy) @@ -118,7 +118,7 @@ </dict> </dict> <key>match</key> - <string>(?:(?:(-\s*)?(\w+\s*(:)))|(-))\s*([A-Za-z0-9_].*)\s*$</ string> + <string>(?:(?:(-\s*)?(\w+\s*(:)))|(-))\s*([^,{}&#[]]+)\s*</ string> <key>name</key> <string>string.unquoted.yaml</string> </dict>
-- Jacob Coby
On Dec 11, 2008, at 2:59 AM, Michael Sheets wrote:
On Dec 10, 2008, at 8:10 AM, Jacob Coby wrote:
Thanks.
I've updated it since the last email because it wasn't highlighting lists correctly.
Just committed this, thanks again.
One more, this time to separate hash keys from unquoted strings. It basically treats everything as an unquoted string unless it matches some other rule. I don't know if I used the correct scope or name, but it seems to work better otherwise. There is still a need to add the document separator "---" and control codes "!"
Index: Syntaxes/YAML.plist =================================================================== --- Syntaxes/YAML.plist (revision 11005) +++ Syntaxes/YAML.plist (working copy) @@ -91,34 +91,33 @@ <dict> <key>captures</key> <dict> - <key>1</key> - <dict> - <key>name</key> - <string>punctuation.definition.entry.yaml</string> - </dict> <key>2</key> <dict> <key>name</key> - <string>entity.name.tag.yaml</string> + <string>keyword.hashkey.yaml</string> </dict> <key>3</key> <dict> <key>name</key> - <string>punctuation.separator.key-value.yaml</string> + <string>source.yaml</string> </dict> - <key>4</key> + </dict> + <key>match</key> + <string>\s*(-?)\s*([\w-_]+)\s*(:)\s*</string> + <key>name</key> + <string>keyword.yaml</string> + </dict> + <dict> + <key>captures</key> + <dict> + <key>1</key> <dict> <key>name</key> - <string>punctuation.definition.entry.yaml</string> - </dict> - <key>5</key> - <dict> - <key>name</key> <string>string.unquoted.yaml</string> </dict> </dict> <key>match</key> - <string>(?:(?:(-\s*)?(\w+\s*(:)))|(-))\s*([^,{}&#[]]+)\s*</ string> + <string>([^,{}&#[]"]+)</string> <key>name</key> <string>string.unquoted.yaml</string> </dict>
-- Jacob Coby