package templates

import (
	"fmt"
	"text/template"
)

func GetSublimeThemeFileName(name string) string {
	return fmt.Sprintf("%s.tmTheme", name)
}

func GetSublimeThemeTemplate() (*template.Template, error) {
	return template.New("sublime_template").Parse(SublimeTemplate)
}

const SublimeTemplate = `<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- Autogenerated theme file: {{ .ID }}
============================================= 
Generated with https://github.com/benbusby/colorstorm -->
<plist version="1.0">
  <dict>
    <key>name</key>
    <string>{{ .Name }}</string>
    <key>settings</key>
    <array>
      <dict>
        <key>settings</key>
        <dict>
          <key>background</key>
          <string>{{ .Background }}</string>
          <key>caret</key>
          <string>{{ .Foreground }}</string>
          <key>foreground</key>
          <string>{{ .Foreground }}</string>

          <key>invisibles</key>
          <string>{{ .ForegroundAlt }}</string>
          <key>lineHighlight</key>
          <string>{{ .BackgroundAlt2 }}</string>
          <key>selection</key>
          <string>{{ .ForegroundAlt }}</string>
          <key>gutter</key>
          <string>{{ .BackgroundAlt1 }}</string>
          <key>gutterForeground</key>
          <string>{{ .ForegroundAlt }}</string>
        </dict>
      </dict>
      <dict>
        <key>name</key>
        <string>Comment</string>
        <key>scope</key>
        <string>comment</string>
        <key>settings</key>
        <dict>
          <key>foreground</key>
          <string>{{ .Comment }}</string>
          <key>background</key>
          <string>{{ .Background }}00</string>
        </dict>
      </dict>
      <dict>
        <key>name</key>
        <string>String</string>
        <key>scope</key>
        <string>string</string>
        <key>settings</key>
        <dict>
          <key>foreground</key>
          <string>{{ .String }}</string>
        </dict>
      </dict>
      <dict>
        <key>name</key>
        <string>Number</string>
        <key>scope</key>
        <string>constant.numeric</string>
        <key>settings</key>
        <dict>
          <key>foreground</key>
          <string>{{ .Number }}</string>
          <key>fontStyle</key>
          <string> underline</string>
        </dict>
      </dict>
      <dict>
        <key>name</key>
        <string>Built-in constant</string>
        <key>scope</key>
        <string>constant.language</string>
        <key>settings</key>
        <dict>
          <key>foreground</key>
          <string>{{ .Constant }}</string>
        </dict>
      </dict>
      <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>{{ .Constant }}</string>
        </dict>
      </dict>
      <dict>
        <key>name</key>
        <string>Variable</string>
        <key>scope</key>
        <string>variable</string>
        <key>settings</key>
        <dict>
          <key>foreground</key>
          <string>{{ .Foreground }}</string>
        </dict>
      </dict>
      <dict>
        <key>name</key>
        <string>Keyword</string>
        <key>scope</key>
        <string>keyword</string>
        <key>settings</key>
        <dict>
          <key>foreground</key>
          <string>{{ .Keyword }}</string>
        </dict>
      </dict>
      <dict>
        <key>name</key>
        <string>Storage</string>
        <key>scope</key>
        <string>storage</string>
        <key>settings</key>
        <dict>
          <key>fontStyle</key>
          <string></string>
          <key>foreground</key>
          <string>{{ .Keyword }}</string>
        </dict>
      </dict>
      <dict>
        <key>name</key>
        <string>Storage type</string>
        <key>scope</key>
        <string>storage.type</string>
        <key>settings</key>
        <dict>
          <key>fontStyle</key>
          <string>italic</string>
          <key>foreground</key>
          <string>{{ .Type }}</string>
        </dict>
      </dict>
      <dict>
        <key>name</key>
        <string>Class name</string>
        <key>scope</key>
        <string>entity.name.class</string>
        <key>settings</key>
        <dict>
          <key>foreground</key>
          <string>{{ .Function }}</string>
          <key>fontStyle</key>
          <string> underline</string>
        </dict>
      </dict>
      <dict>
        <key>name</key>
        <string>Inherited class</string>
        <key>scope</key>
        <string>entity.other.inherited-class</string>
        <key>settings</key>
        <dict>
          <key>fontStyle</key>
          <string>italic underline</string>
          <key>foreground</key>
          <string>{{ .Function }}</string>
        </dict>
      </dict>
      <dict>
        <key>name</key>
        <string>Function name</string>
        <key>scope</key>
        <string>entity.name.function</string>
        <key>settings</key>
        <dict>
          <key>foreground</key>
          <string>{{ .Foreground }}</string>
        </dict>
      </dict>
      <dict>
        <key>name</key>
        <string>Function argument</string>
        <key>scope</key>
        <string>variable.parameter</string>
        <key>settings</key>
        <dict>
          <key>fontStyle</key>
          <string>italic </string>
          <key>foreground</key>
          <string>{{ .Constant }}</string>
        </dict>
      </dict>
      <dict>
        <key>name</key>
        <string>Tag name</string>
        <key>scope</key>
        <string>entity.name.tag</string>
        <key>settings</key>
        <dict>
          <key>fontStyle</key>
          <string></string>
          <key>foreground</key>
          <string>{{ .Keyword }}</string>
        </dict>
      </dict>
      <dict>
        <key>name</key>
        <string>Tag attribute</string>
        <key>scope</key>
        <string>entity.other.attribute-name</string>
        <key>settings</key>
        <dict>
          <key>fontStyle</key>
          <string></string>
          <key>foreground</key>
          <string>{{ .Keyword }}</string>
        </dict>
      </dict>
      <dict>
        <key>name</key>
        <string>Library function</string>
        <key>scope</key>
        <string>support.function</string>
        <key>settings</key>
        <dict>
          <key>fontStyle</key>
          <string></string>
          <key>foreground</key>
          <string>{{ .Function }}</string>
        </dict>
      </dict>
      <dict>
        <key>name</key>
        <string>Library constant</string>
        <key>scope</key>
        <string>support.constant</string>
        <key>settings</key>
        <dict>
          <key>fontStyle</key>
          <string></string>
          <key>foreground</key>
          <string>{{ .Constant }}</string>
        </dict>
      </dict>
      <dict>
        <key>name</key>
        <string>Library class&#x2f;type</string>
        <key>scope</key>
        <string>support.type, support.class</string>
        <key>settings</key>
        <dict>
          <key>fontStyle</key>
          <string>italic</string>
          <key>foreground</key>
          <string>{{ .Type }}</string>
        </dict>
      </dict>
      <dict>
        <key>name</key>
        <string>Library variable</string>
        <key>scope</key>
        <string>support.other.variable</string>
        <key>settings</key>
        <dict>
          <key>fontStyle</key>
          <string></string>
          <key>foreground</key>
          <string>{{ .Foreground }}</string>
        </dict>
      </dict>
      <dict>
        <key>name</key>
        <string>Invalid</string>
        <key>scope</key>
        <string>invalid</string>
        <key>settings</key>
        <dict>
          <key>background</key>
          <string>#F92672</string>
          <key>fontStyle</key>
          <string></string>
          <key>foreground</key>
          <string>#F8F8F0</string>
        </dict>
      </dict>
      <dict>
        <key>name</key>
        <string>Invalid deprecated</string>
        <key>scope</key>
        <string>invalid.deprecated</string>
        <key>settings</key>
        <dict>
          <key>background</key>
          <string>#AE81FF</string>
          <key>foreground</key>
          <string>#F8F8F0</string>
        </dict>
      </dict>
    </array>
    <key>uuid</key>
    <string>{{ .ID }}</string>
    <key>colorSpaceName</key>
    <string>sRGB</string>
    <key>semanticClass</key>
    <string>theme.{{ .DarkOrLight }}.{{ .ID }}</string>
    <key>author</key>
    <string>{{ .Author }}</string>
  </dict>
</plist>
`
