Closed EliotVU closed 11 years ago
Thank you very much for your help!
I see that it's much better organized now, but I don't see any operator highlighting. I see you added them to a group, but they aren't assigned to a color. But don't ask me how to do that, as I've always taken the .tmLanguage file from someone else ;-)
Please remove the UnrealScript.sublime-completions file from your request, as it is not needed (see my comment). Then I can merge this.
also, I've noticed that the green color is assigned to some virtual void stuff inside cpptext which I don't find really important. It would be good if this color was used elsewhere.
Ok removed. Now hopefully I did that right cause honestly I have no idea :D
Yeah you can change the key name to constant if you want it colored like constants but that felt wrong so I made up a name to let you decide something.
I really don't have an idea where I would change that, could you do that?
For the colors, I think we could try to mimic some other sublime highlighting files. This on is the standard python highlighting and I quite like it.
That's user defined by choosing a Color Scheme. Which defines colors for syntax rules based on its name(I think so)
Like currently the operators have this name
The same has to be done correctly for any other syntax definition such as the control flow or literals like true/false, but this is my first time editing such files so I don't know all these things just yet.
Yes, that's right, but I think it should work well out of the box with the default theme. And as this file does only take care of the colors (mostly), I think it doesn't matter if an operator is defined constant if it looks good. But as said before, I really know nothing about those syntax definition files either. But I've found a plugin a while ago that might be helpful when creating those files: https://github.com/SublimeText/AAAPackageDev
Anyway, I will just merge this and if you like you can always update it further. Again, thanks a lot for your help.
Alright. How about this
This new language file won't work out of the box with the default theme as the new groups aren't supported by it. A tmLanguage file must also have a corresponding tmTheme file. Since Monokai.tmTheme doesn't support these added groups or operators it doesn't know what colors they should be.
I like the fact that the keywords are better organized along with operator detection (nice job figuring that out, Eliot), but we'll have to create our own .tmTheme file to go along with it. It's not hard to do. For example modifier keywords would look like this:
<!-- modifier keywords -->
<dict>
<key>name</key>
<string>Keyword</string>
<key>scope</key>
<string>keyword.modifier</string> <!-- notice how this matches the language file -->
<key>settings</key>
<dict>
<key>foreground</key>
<string>#05623f</string> <!-- ugly green color -->
</dict>
</dict>
I don't think it's any big deal as the themes can be changed very easily. Our new theme would show up in Preferences > Color Scheme > UnrealScriptIDE. As long as you put that in the readme, people will know which one to use.
We could probably get away with doing this:
"if you change punctuation to constant then the set Color Scheme will highlight it as a whatever constant is configured to."
But I'm not sure if that would be the best way to go about it.
I figured out that you can include a syntax specific settings file inside your plugin that would change the theme automatically when a certain syntax is used. So a custom theme might be the best solution after all.
I was against it in the first place, because I didn't wanted the user to change some settings on his own. But now that I've found out how this would be possible it's no problem anymore. Also with this solution you'd still be able to use a different theme if you wished.
So if you want to include your modified Monokai theme, please create a new folder called "Themes" inside the root of this project and save your theme file there as "Monokai - UnrealScript.tmTheme" This way we could include more themes that support UnrealScript in the future. Then I'll go ahead and create the settings file that would specify this as the default theme for UnrealScript.
Maybe I don't understand this as well as I thought. Monokai.tmTheme has no setting for operator highlighting and yet, if you open a python file the operators are highlighted. I have no idea how that is being done. There are several groups in the Python.tmLanguage file that aren't in the Monokai.tmTheme as well, such as keyword.operator.
Maybe this is of interest:
"Naming scopes isn’t obvious sometimes. Check the Textmate online manual for guidance on scope names. It is important to re-use the basic categories outlined there if you want to achieve the highest compatibility with existing colors.
Colors have hardcoded scope names in them. They could not possibly include every scope name you can think of, so they target the standard ones plus some rarer ones on occasion. This means that two colors using the same syntax definition may render the text differently!
Bear in mind too that you should use the scope name that best suits your needs or preferences. It’d be perfectly fine to assign a scope like constant.numeric to anything other than a number if you have a good reason to do so."
found from: https://sublime-text-unofficial-documentation.readthedocs.org/en/latest/extensibility/syntaxdefs.html
So maybe assigning some scopes to some groups that actually make no sense, but give a nicer color is the right solution after all.
and the textmate manual mentioned in the quote is located here: http://manual.macromates.com/en/language_grammars#language_grammars
These language files seam to be a huge topic..
As title says :+1: