jbrooksuk/Oblivion

Better generation

jbrooksuk opened this issue · 18 comments

I'm currently working on a generator which takes a JSON file and generates a tmTheme file.

My thinking is that we can produce a template for Oblivion, then using a little bit of code we can tinker with the colours and produce variations of the theme that contain the same scopes and features as all of the others.

This script will be going into another repository, I'll add a link once it's done.

+1

It's very cool.
Currently is very difficult change a collor in theme.
A generator solve this problem.

Just need to find some time to work on this and we'll be generating them really quickly.

One of the benefits of doing this is that we can specify the colour palettes in JSON/YAML and instantly have the scheme updated across all variations. This is great if we modify a colour or we add an extra scope.

What you think about it:

<dict>
    <key>name</key>
    <string>User-defined constant</string>
    <key>scope</key>
    <string>constant.character, constant.other</string>
    <key>settings</key>
    <dict>
        <key>foreground</key>
        <string>#AE81FF</string>
    </dict>
</dict>
<dict>
    <key>name</key>
    <string>Variable</string>
    <key>scope</key>
    <string>variable</string>
    <key>settings</key>
    <dict>
        <key>foreground</key>
        <string>#6290C5</string>
        <key>fontStyle</key>
        <string></string>
    </dict>
</dict>

This block can be write as:

array:
    - name: User-defined constant
      scope: "constant.character, constant.other"
      settings: 
        foreground: "#AE81FF"
    - name: Variable
      scope: variable
      settings:
        foreground: "#6290C5"
        fontStyle: ""

YAML is really good!

We can use named color to a better writing.
I'm really excited with this.

What language do you use?

That looks awesome to me!

I'll be writing the generator with Node.js, so JavaScript. Originally I was going to do it in JSON, but YAML looks nicer for this. You can check my empty repository here.

I found this which generates PList from JSON. I can change the JSON bit to YAML and have everything running pretty smoothly.

TTheme is able to use JSON and YAML (untested with JSON). Although I'd prefer we use YAML to keep consistent.

What we need to do now is pull out the colours into a palette file. Then for each *.ttheme.js file, import that palette, change the colours.

I haven't worked out how we can do that with variables in the file though...

Nice!

I'm not a Node.JS programmer, but will try help in this tool!

Okay, open an issue on it if you need any help.

All we need is a PLIST to YAML converter now ;)

I've converted the tmTheme files into YAML. There is also a palette file now which we can use as the default colour scheme, then modify them based on the generator.

How do you generate a tmTheme from yaml?
I'm trying but have no response =/

I used an Xcode developer tool that converts to JSON.

plutil -convert json Oblivion.tmTheme -o Oblivion.json

Then I used an online tool for JSON to YAML.

Did you have any luck @hussani?

plutil in Ubuntu don't have a convert parameter.
But, it isn't a big problem. The TTheme converts the converted yaml to plist?

Ah right, plutil on OSX does have that parameter, is there another version?

Yes, TTheme should be doing that. Is it not?

plutil is a proprietary tool of Apple. I don't know a similar tool to linux.

I have this error when compile yaml to plist with Ttheme:
syntax error near 'token 'unexpected '('

The executed command is:
ttheme -o Oblivion-SodaDark.yml -c OblivionSodaDark.tmTheme

Can you send me a link to a Gist containing the YAML please?