Sublime Forum

Isn't it the time to move from tmTheme format to a YAML based color scheme definition

#1

Sublime gradually replaced most of old textmate formats with more modern file formats. But we’re still stuck with this old, verbose, and hard to maintain plist format for color schemes called tmTheme.

Using a YAML based format just like new sublime-syntax will reduce file size and improve maintainablity. Converting between old and new format should also be trivial using a scripting language.

7 Likes

API Suggestions
#2

Following the discussion regarding the structure of Packages at sublimehq/Packages#32, there also are:

  • *.tmMacro (not supported by ST according to @FichteFoll)
  • *.tmCommand (not supported by ST according to @FichteFoll)
  • *.tmDragCommand (not supported by ST according to @FichteFoll)
  • *.tmPreferences
  • *.tmSnippet
    • which has *.sublime-snippet as a replacement
    • however *.sublime-completions are treated differently by ST although they might seem similar
1 Like

Will there be a .sublime-something replacement for the .tmPreferences file format?
#3

Looking at the commit history, @wbond has converted remaining *.tmSnippet files to *.sublime-snippet just last week with commit sublimehq/Packages@8176421

1 Like

#4

I personally use https://github.com/FichteFoll/CSScheme to convert CSS to tmTheme files because CSS seems like a pretty good abstraction over what scope selectors already do. Another great advantage of it is that you can use CSS pre-processors like SCSS or stylus utilizing their variables and nested scopes as well as functions and imports.

Here’s a color scheme that I know which uses CSScheme to a great extend: https://github.com/alehandrof/Writerly

There’s also an issue on the repo requesting .sublime-theme support which also seems like a good idea when looking at its structure, but I don’t have any time for this currently.


The only “remaining” xml cofiguration files are:

2 Likes

#5

YAML for snippets would be a pain. Snippets need tabs and YAML needs spaces, resulting in mixed indentation, or trying to come up with space -> space translation or space -> tab -> space.

I’ve noodled some over tmTheme, tmPreferences, and XML in snippets, but I don’t have any solid thoughts yet.

0 Likes

Allow multiple snippets in same sublime-snippet file
Commenting snippets
#6

I think you misunderstood. The suggested format is basically a “plaintext snippet” with YAML frontmatter, i.e. everything after the second ^---$\n will be considered literal snippet content, and therefore does not require any YAML-specific considerations such as whitespace. This is common practice in some markdown parsers for example.
YAML is only used for the snippet metadata, i.e. tab trigger, name and scope selector. (In fact, SaneSnippets doesn’t even use a YAML parser but simple regular expressions.)

I added a few more examples to the github issue, but here is one that should show this more clearly:

---
description: Enumeration (annotated)
tabTrigger:  enum
scope:       text.tex.latex
---
\begin{enumerate}${1/(.+)/\[/}$1${1/(.+)/\]/}
    \item $0
\end{enumerate}

For comparison, this is the generated .sublime-snippet:

<snippet>
    <description>Enumeration (annotated)</description>
    <tabTrigger>enum</tabTrigger>
    <scope>text.tex.latex</scope>
    <content><![CDATA[
\begin{enumerate}${1/(.+)/\[/}$1${1/(.+)/\]/}
    \item $0
\end{enumerate}
]]></content>
</snippet>
12 Likes