JetBrains / colorSchemeTool

Apache License 2.0
467 stars 82 forks source link

Having problems converting a file #50

Open carlca opened 11 months ago

carlca commented 11 months ago

I've narrowed down the operation of the tool by limiting the contents of the vscThemes folder to the one file mojo.json. I also altered convert.sh to having the following line at the end...

python2 colorSchemeTool.py "$FILE" "$IJ_OUTDIR$BASE.icls" >> ./colorSchemeTool.log

when I run the script, the initial conversion to tmtheme appears to work, however, the conversion to .icls fails. Here is the error message...

~/Code/colorSchemeTool  sh ./convert.sh
converting ./vscThemes/mojo.json to ./tmThemes/mojo.tmTheme ...
converting ./tmThemes/mojo.tmTheme to ./intellijThemes/mojo.icls ...
Traceback (most recent call last):
  File "colorSchemeTool.py", line 926, in <module>
    all_settings, used_scopes = load_textmate_scheme(sys.argv[1])
  File "colorSchemeTool.py", line 774, in load_textmate_scheme
    themeDict = plistlib.load(f)
AttributeError: 'module' object has no attribute 'load'

I've attached the file to be converted. If you can work out what's wrong, that would be great. Failing that could I ask you if you could produce the mojo.icls file yourself and send it back to me πŸ™πŸ½

mojo.json

carlca commented 11 months ago

It turns out that Python 3 is the required version. I've narrowed the problem down to a failure in the load function of plistlib.py...

def load(fp, *, fmt=None, dict_type=dict):
    """Read a .plist file. 'fp' should be a readable and binary file object.
    Return the unpacked root object (which usually is a dictionary).
    """
    if fmt is None:
        header = fp.read(32)
        fp.seek(0)
        for info in _FORMATS.values():
            if info['detect'](header):
                P = info['parser']
                break

        else:
            raise InvalidFileException()

    else:
        P = _FORMATS[fmt]['parser']

    p = P(dict_type=dict_type)
    return p.parse(fp)

The function is raising a InvalidFileException exception which suggests that the problem may lie in the vscToTm.js script. However, the .tmtheme file produced is passing the plutil plist validation tool...

carlca commented 11 months ago

I've sorted out the problem. It may be that the original VSCode .json file was missing some info, but the intermediate .tmTheme file certainly was missing some crucial lines...

The highlighted lines were missing...

    <key>name</key>
    <string>Dark-</string>
    <key>settings</key>
    <array>
      <dict>
        <key>settings</key>
        <dict>
          <key>background</key>     # MISSING      
          <string>#1e1e1e</string>  # MISSING      
          <key>caret</key>          # MISSING      
          <string>#7070FF</string>  # MISSING      
          <key>foreground</key>     # MISSING      
          <string>#D0D0FF</string>  # MISSING      
          <key>invisibles</key>     # MISSING      
          <string>#404040</string>  # MISSING      
          <key>selection</key>
          <string>#007ACC40</string>
          <key>lineHighlight</key>
          <string>#1E1E1E</string>
        </dict>
      </dict>
      <dict>

...with the result that the isDark function was causing thee process to crash. So I transplanted some lines from a working .tmTheme file, commented out the first half of convert,sh and got a nice new mojo.icls file which was then easy to tweak to taste πŸ˜ƒ

ilxqx commented 10 months ago

Hi, I have encountered the same problem. I really don't know how to do it. Can you please help me convert a vscode theme? Here is the json content of this theme(Very grateful):

{
    "type": "light",
    "colors": {
        "focusBorder": "#ffaa33b3",
        "foreground": "#8a9199",
        "widget.shadow": "#00000026",
        "selection.background": "#035bd626",
        "icon.foreground": "#8a9199",
        "errorForeground": "#e65050",
        "descriptionForeground": "#8a9199",
        "textBlockQuote.background": "#f3f4f5",
        "textLink.foreground": "#ffaa33",
        "textLink.activeForeground": "#ffaa33",
        "textPreformat.foreground": "#5c6166",
        "button.background": "#ffaa33",
        "button.foreground": "#804a00",
        "button.hoverBackground": "#f9a52e",
        "button.secondaryBackground": "#8a919933",
        "button.secondaryForeground": "#5c6166",
        "button.secondaryHoverBackground": "#8a919980",
        "dropdown.background": "#fcfcfc",
        "dropdown.foreground": "#8a9199",
        "dropdown.border": "#8a919945",
        "input.background": "#fcfcfc",
        "input.border": "#8a919945",
        "input.foreground": "#5c6166",
        "input.placeholderForeground": "#8a919980",
        "inputOption.activeBorder": "#f4a0284d",
        "inputOption.activeBackground": "#ffaa3333",
        "inputOption.activeForeground": "#f4a028",
        "inputValidation.errorBackground": "#fcfcfc",
        "inputValidation.errorBorder": "#e65050",
        "inputValidation.infoBackground": "#f8f9fa",
        "inputValidation.infoBorder": "#55b4d4",
        "inputValidation.warningBackground": "#f8f9fa",
        "inputValidation.warningBorder": "#f2ae49",
        "scrollbar.shadow": "#6b7d8f00",
        "scrollbarSlider.background": "#8a919966",
        "scrollbarSlider.hoverBackground": "#8a919999",
        "scrollbarSlider.activeBackground": "#8a9199b3",
        "badge.background": "#ffaa3333",
        "badge.foreground": "#f4a028",
        "progressBar.background": "#ffaa33",
        "list.activeSelectionBackground": "#56728f1f",
        "list.activeSelectionForeground": "#5c6166",
        "list.focusBackground": "#56728f1f",
        "list.focusForeground": "#5c6166",
        "list.focusOutline": "#56728f1f",
        "list.highlightForeground": "#ffaa33",
        "list.deemphasizedForeground": "#e65050",
        "list.hoverBackground": "#56728f1f",
        "list.inactiveSelectionBackground": "#6b7d8f1f",
        "list.inactiveSelectionForeground": "#8a9199",
        "list.invalidItemForeground": "#8a91994d",
        "list.errorForeground": "#e65050",
        "tree.indentGuidesStroke": "#8a919959",
        "listFilterWidget.background": "#f3f4f5",
        "listFilterWidget.outline": "#ffaa33",
        "listFilterWidget.noMatchesOutline": "#e65050",
        "list.filterMatchBackground": "#ddcaef73",
        "list.filterMatchBorder": "#ecd9ff73",
        "activityBar.background": "#fcfcfc",
        "activityBar.foreground": "#8a9199cc",
        "activityBar.inactiveForeground": "#8a919999",
        "activityBar.border": "#6b7d8f1f",
        "activityBar.activeBorder": "#ffaa33",
        "activityBarBadge.background": "#ffaa33",
        "activityBarBadge.foreground": "#f8f9fa",
        "sideBar.background": "#f8f9fa",
        "sideBar.border": "#6b7d8f1f",
        "sideBarTitle.foreground": "#8a9199",
        "sideBarSectionHeader.background": "#f8f9fa",
        "sideBarSectionHeader.foreground": "#8a9199",
        "sideBarSectionHeader.border": "#6b7d8f1f",
        "minimap.background": "#fcfcfc",
        "minimap.selectionHighlight": "#035bd626",
        "minimap.errorHighlight": "#e65050",
        "minimap.findMatchHighlight": "#ecd9ff",
        "minimapGutter.addedBackground": "#6cbf43",
        "minimapGutter.modifiedBackground": "#478acc",
        "minimapGutter.deletedBackground": "#ff7383",
        "editorGroup.border": "#6b7d8f1f",
        "editorGroup.background": "#f3f4f5",
        "editorGroupHeader.noTabsBackground": "#f8f9fa",
        "editorGroupHeader.tabsBackground": "#f8f9fa",
        "editorGroupHeader.tabsBorder": "#6b7d8f1f",
        "tab.activeBackground": "#fcfcfc",
        "tab.activeForeground": "#5c6166",
        "tab.border": "#6b7d8f1f",
        "tab.activeBorder": "#fcfcfc",
        "tab.activeBorderTop": "#ffaa33",
        "tab.unfocusedActiveBorderTop": "#8a9199",
        "tab.inactiveBackground": "#f8f9fa",
        "tab.inactiveForeground": "#8a9199",
        "tab.unfocusedActiveForeground": "#8a9199",
        "tab.unfocusedInactiveForeground": "#8a9199",
        "editor.background": "#fcfcfc",
        "editor.foreground": "#5c6166",
        "editorLineNumber.foreground": "#8a919966",
        "editorLineNumber.activeForeground": "#8a9199cc",
        "editorCursor.foreground": "#ffaa33",
        "editor.inactiveSelectionBackground": "#035bd612",
        "editor.selectionBackground": "#035bd626",
        "editor.selectionHighlightBackground": "#6cbf4326",
        "editor.selectionHighlightBorder": "#6cbf4300",
        "editor.wordHighlightBackground": "#478acc14",
        "editor.wordHighlightStrongBackground": "#6cbf4314",
        "editor.wordHighlightBorder": "#478acc80",
        "editor.wordHighlightStrongBorder": "#6cbf4380",
        "editor.findMatchBackground": "#ecd9ff",
        "editor.findMatchBorder": "#ecd9ff",
        "editor.findMatchHighlightBackground": "#ecd9ff73",
        "editor.findMatchHighlightBorder": "#ddcaef73",
        "editor.findRangeHighlightBackground": "#ecd9ff40",
        "editor.rangeHighlightBackground": "#ecd9ff33",
        "editor.lineHighlightBackground": "#8a91991a",
        "editorLink.activeForeground": "#ffaa33",
        "editorWhitespace.foreground": "#8a919966",
        "editorIndentGuide.background": "#8a91992e",
        "editorIndentGuide.activeBackground": "#8a919959",
        "editorRuler.foreground": "#8a91992e",
        "editorCodeLens.foreground": "#787b8099",
        "editorBracketMatch.background": "#8a91994d",
        "editorBracketMatch.border": "#8a91994d",
        "editor.snippetTabstopHighlightBackground": "#6cbf4333",
        "editorOverviewRuler.border": "#6b7d8f1f",
        "editorOverviewRuler.modifiedForeground": "#478acc",
        "editorOverviewRuler.addedForeground": "#6cbf43",
        "editorOverviewRuler.deletedForeground": "#ff7383",
        "editorOverviewRuler.errorForeground": "#e65050",
        "editorOverviewRuler.warningForeground": "#ffaa33",
        "editorOverviewRuler.bracketMatchForeground": "#8a9199b3",
        "editorOverviewRuler.wordHighlightForeground": "#478acc66",
        "editorOverviewRuler.wordHighlightStrongForeground": "#6cbf4366",
        "editorOverviewRuler.findMatchForeground": "#ecd9ff",
        "editorError.foreground": "#e65050",
        "editorWarning.foreground": "#ffaa33",
        "editorGutter.modifiedBackground": "#478acccc",
        "editorGutter.addedBackground": "#6cbf43cc",
        "editorGutter.deletedBackground": "#ff7383cc",
        "diffEditor.insertedTextBackground": "#6cbf431f",
        "diffEditor.removedTextBackground": "#ff73831f",
        "diffEditor.diagonalFill": "#6b7d8f1f",
        "editorWidget.background": "#f8f9fa",
        "editorWidget.border": "#6b7d8f1f",
        "editorHoverWidget.background": "#f8f9fa",
        "editorHoverWidget.border": "#6b7d8f1f",
        "editorSuggestWidget.background": "#f3f4f5",
        "editorSuggestWidget.border": "#6b7d8f1f",
        "editorSuggestWidget.highlightForeground": "#ffaa33",
        "editorSuggestWidget.selectedBackground": "#56728f1f",
        "debugExceptionWidget.border": "#6b7d8f1f",
        "debugExceptionWidget.background": "#f3f4f5",
        "editorMarkerNavigation.background": "#f3f4f5",
        "peekView.border": "#56728f1f",
        "peekViewTitle.background": "#56728f1f",
        "peekViewTitleDescription.foreground": "#8a9199",
        "peekViewTitleLabel.foreground": "#5c6166",
        "peekViewEditor.background": "#f8f9fa",
        "peekViewEditor.matchHighlightBackground": "#ecd9ff73",
        "peekViewEditor.matchHighlightBorder": "#ddcaef73",
        "peekViewResult.background": "#f8f9fa",
        "peekViewResult.fileForeground": "#5c6166",
        "peekViewResult.lineForeground": "#8a9199",
        "peekViewResult.matchHighlightBackground": "#ecd9ff73",
        "peekViewResult.selectionBackground": "#56728f1f",
        "panel.background": "#f8f9fa",
        "panel.border": "#6b7d8f1f",
        "panelTitle.activeBorder": "#ffaa33",
        "panelTitle.activeForeground": "#5c6166",
        "panelTitle.inactiveForeground": "#8a9199",
        "statusBar.background": "#f8f9fa",
        "statusBar.foreground": "#8a9199",
        "statusBar.border": "#6b7d8f1f",
        "statusBar.debuggingBackground": "#ed9366",
        "statusBar.debuggingForeground": "#fcfcfc",
        "statusBar.noFolderBackground": "#f3f4f5",
        "statusBarItem.activeBackground": "#8a919933",
        "statusBarItem.hoverBackground": "#8a919933",
        "statusBarItem.prominentBackground": "#6b7d8f1f",
        "statusBarItem.prominentHoverBackground": "#00000030",
        "statusBarItem.remoteBackground": "#ffaa33",
        "statusBarItem.remoteForeground": "#804a00",
        "titleBar.activeBackground": "#f8f9fa",
        "titleBar.activeForeground": "#5c6166",
        "titleBar.inactiveBackground": "#f8f9fa",
        "titleBar.inactiveForeground": "#8a9199",
        "titleBar.border": "#6b7d8f1f",
        "extensionButton.prominentForeground": "#804a00",
        "extensionButton.prominentBackground": "#ffaa33",
        "extensionButton.prominentHoverBackground": "#f9a52e",
        "pickerGroup.border": "#6b7d8f1f",
        "pickerGroup.foreground": "#8a919980",
        "debugToolBar.background": "#f3f4f5",
        "debugIcon.breakpointForeground": "#ed9366",
        "debugIcon.breakpointDisabledForeground": "#ed936680",
        "debugConsoleInputIcon.foreground": "#ffaa33",
        "welcomePage.tileBackground": "#f8f9fa",
        "welcomePage.tileShadow": "#00000026",
        "welcomePage.progress.background": "#8a91991a",
        "welcomePage.buttonBackground": "#ffaa3366",
        "walkThrough.embeddedEditorBackground": "#f3f4f5",
        "gitDecoration.modifiedResourceForeground": "#478accb3",
        "gitDecoration.deletedResourceForeground": "#ff7383b3",
        "gitDecoration.untrackedResourceForeground": "#6cbf43b3",
        "gitDecoration.ignoredResourceForeground": "#8a919980",
        "gitDecoration.conflictingResourceForeground": "",
        "gitDecoration.submoduleResourceForeground": "#a37accb3",
        "settings.headerForeground": "#5c6166",
        "settings.modifiedItemIndicator": "#478acc",
        "keybindingLabel.background": "#8a91991a",
        "keybindingLabel.foreground": "#5c6166",
        "keybindingLabel.border": "#5c61661a",
        "keybindingLabel.bottomBorder": "#5c61661a",
        "terminal.background": "#f8f9fa",
        "terminal.foreground": "#5c6166",
        "terminal.ansiBlack": "#000000",
        "terminal.ansiRed": "#ea6c6d",
        "terminal.ansiGreen": "#6cbf43",
        "terminal.ansiYellow": "#eca944",
        "terminal.ansiBlue": "#3199e1",
        "terminal.ansiMagenta": "#9e75c7",
        "terminal.ansiCyan": "#46ba94",
        "terminal.ansiWhite": "#c7c7c7",
        "terminal.ansiBrightBlack": "#686868",
        "terminal.ansiBrightRed": "#f07171",
        "terminal.ansiBrightGreen": "#86b300",
        "terminal.ansiBrightYellow": "#f2ae49",
        "terminal.ansiBrightBlue": "#399ee6",
        "terminal.ansiBrightMagenta": "#a37acc",
        "terminal.ansiBrightCyan": "#4cbf99",
        "terminal.ansiBrightWhite": "#d1d1d1"
    },
    "tokenColors": [
        {
            "settings": {
                "background": "#f8f9fa",
                "foreground": "#5c6166"
            }
        },
        {
            "name": "Comment",
            "scope": [
                "comment"
            ],
            "settings": {
                "fontStyle": "italic",
                "foreground": "#787b8099"
            }
        },
        {
            "name": "String",
            "scope": [
                "string",
                "constant.other.symbol"
            ],
            "settings": {
                "foreground": "#86b300"
            }
        },
        {
            "name": "Regular Expressions and Escape Characters",
            "scope": [
                "string.regexp",
                "constant.character",
                "constant.other"
            ],
            "settings": {
                "foreground": "#4cbf99"
            }
        },
        {
            "name": "Number",
            "scope": [
                "constant.numeric"
            ],
            "settings": {
                "foreground": "#a37acc"
            }
        },
        {
            "name": "Built-in constants",
            "scope": [
                "constant.language"
            ],
            "settings": {
                "foreground": "#a37acc"
            }
        },
        {
            "name": "Variable",
            "scope": [
                "variable",
                "variable.parameter.function-call"
            ],
            "settings": {
                "foreground": "#5c6166"
            }
        },
        {
            "name": "Member Variable",
            "scope": [
                "variable.member"
            ],
            "settings": {
                "foreground": "#f07171"
            }
        },
        {
            "name": "Language variable",
            "scope": [
                "variable.language"
            ],
            "settings": {
                "fontStyle": "italic",
                "foreground": "#55b4d4"
            }
        },
        {
            "name": "Storage",
            "scope": [
                "storage"
            ],
            "settings": {
                "foreground": "#fa8d3e"
            }
        },
        {
            "name": "Keyword",
            "scope": [
                "keyword"
            ],
            "settings": {
                "foreground": "#fa8d3e"
            }
        },
        {
            "name": "Operators",
            "scope": [
                "keyword.operator"
            ],
            "settings": {
                "foreground": "#ed9366"
            }
        },
        {
            "name": "Separators like ; or ,",
            "scope": [
                "punctuation.separator",
                "punctuation.terminator"
            ],
            "settings": {
                "foreground": "#5c6166b3"
            }
        },
        {
            "name": "Punctuation",
            "scope": [
                "punctuation.section"
            ],
            "settings": {
                "foreground": "#5c6166"
            }
        },
        {
            "name": "Accessor",
            "scope": [
                "punctuation.accessor"
            ],
            "settings": {
                "foreground": "#ed9366"
            }
        },
        {
            "name": "JavaScript/TypeScript interpolation punctuation",
            "scope": [
                "punctuation.definition.template-expression"
            ],
            "settings": {
                "foreground": "#fa8d3e"
            }
        },
        {
            "name": "Ruby interpolation punctuation",
            "scope": [
                "punctuation.section.embedded"
            ],
            "settings": {
                "foreground": "#fa8d3e"
            }
        },
        {
            "name": "Interpolation text",
            "scope": [
                "meta.embedded"
            ],
            "settings": {
                "foreground": "#5c6166"
            }
        },
        {
            "name": "Types fixes",
            "scope": [
                "source.java storage.type",
                "source.haskell storage.type",
                "source.c storage.type"
            ],
            "settings": {
                "foreground": "#399ee6"
            }
        },
        {
            "name": "Inherited class type",
            "scope": [
                "entity.other.inherited-class"
            ],
            "settings": {
                "foreground": "#55b4d4"
            }
        },
        {
            "name": "Lambda arrow",
            "scope": [
                "storage.type.function"
            ],
            "settings": {
                "foreground": "#fa8d3e"
            }
        },
        {
            "name": "Java primitive variable types",
            "scope": [
                "source.java storage.type.primitive"
            ],
            "settings": {
                "foreground": "#55b4d4"
            }
        },
        {
            "name": "Function name",
            "scope": [
                "entity.name.function"
            ],
            "settings": {
                "foreground": "#f2ae49"
            }
        },
        {
            "name": "Function arguments",
            "scope": [
                "variable.parameter",
                "meta.parameter"
            ],
            "settings": {
                "foreground": "#a37acc"
            }
        },
        {
            "name": "Function call",
            "scope": [
                "variable.function",
                "variable.annotation",
                "meta.function-call.generic",
                "support.function.go"
            ],
            "settings": {
                "foreground": "#f2ae49"
            }
        },
        {
            "name": "Library function",
            "scope": [
                "support.function",
                "support.macro"
            ],
            "settings": {
                "foreground": "#f07171"
            }
        },
        {
            "name": "Imports and packages",
            "scope": [
                "entity.name.import",
                "entity.name.package"
            ],
            "settings": {
                "foreground": "#86b300"
            }
        },
        {
            "name": "Entity name",
            "scope": [
                "entity.name"
            ],
            "settings": {
                "foreground": "#399ee6"
            }
        },
        {
            "name": "Tag",
            "scope": [
                "entity.name.tag",
                "meta.tag.sgml"
            ],
            "settings": {
                "foreground": "#55b4d4"
            }
        },
        {
            "name": "JSX Component",
            "scope": [
                "support.class.component"
            ],
            "settings": {
                "foreground": "#399ee6"
            }
        },
        {
            "name": "Tag start/end",
            "scope": [
                "punctuation.definition.tag.end",
                "punctuation.definition.tag.begin",
                "punctuation.definition.tag"
            ],
            "settings": {
                "foreground": "#55b4d480"
            }
        },
        {
            "name": "Tag attribute",
            "scope": [
                "entity.other.attribute-name"
            ],
            "settings": {
                "foreground": "#f2ae49"
            }
        },
        {
            "name": "Library constant",
            "scope": [
                "support.constant"
            ],
            "settings": {
                "fontStyle": "italic",
                "foreground": "#ed9366"
            }
        },
        {
            "name": "Library class/type",
            "scope": [
                "support.type",
                "support.class",
                "source.go storage.type"
            ],
            "settings": {
                "foreground": "#55b4d4"
            }
        },
        {
            "name": "Decorators/annotation",
            "scope": [
                "meta.decorator variable.other",
                "meta.decorator punctuation.decorator",
                "storage.type.annotation"
            ],
            "settings": {
                "foreground": "#e6ba7e"
            }
        },
        {
            "name": "Invalid",
            "scope": [
                "invalid"
            ],
            "settings": {
                "foreground": "#e65050"
            }
        },
        {
            "name": "diff.header",
            "scope": [
                "meta.diff",
                "meta.diff.header"
            ],
            "settings": {
                "foreground": "#c594c5"
            }
        },
        {
            "name": "Ruby class methods",
            "scope": [
                "source.ruby variable.other.readwrite"
            ],
            "settings": {
                "foreground": "#f2ae49"
            }
        },
        {
            "name": "CSS tag names",
            "scope": [
                "source.css entity.name.tag",
                "source.sass entity.name.tag",
                "source.scss entity.name.tag",
                "source.less entity.name.tag",
                "source.stylus entity.name.tag"
            ],
            "settings": {
                "foreground": "#399ee6"
            }
        },
        {
            "name": "CSS browser prefix",
            "scope": [
                "source.css support.type",
                "source.sass support.type",
                "source.scss support.type",
                "source.less support.type",
                "source.stylus support.type"
            ],
            "settings": {
                "foreground": "#787b8099"
            }
        },
        {
            "name": "CSS Properties",
            "scope": [
                "support.type.property-name"
            ],
            "settings": {
                "fontStyle": "normal",
                "foreground": "#55b4d4"
            }
        },
        {
            "name": "Search Results Numbers",
            "scope": [
                "constant.numeric.line-number.find-in-files - match"
            ],
            "settings": {
                "foreground": "#787b8099"
            }
        },
        {
            "name": "Search Results Match Numbers",
            "scope": [
                "constant.numeric.line-number.match"
            ],
            "settings": {
                "foreground": "#fa8d3e"
            }
        },
        {
            "name": "Search Results Lines",
            "scope": [
                "entity.name.filename.find-in-files"
            ],
            "settings": {
                "foreground": "#86b300"
            }
        },
        {
            "scope": [
                "message.error"
            ],
            "settings": {
                "foreground": "#e65050"
            }
        },
        {
            "name": "Markup heading",
            "scope": [
                "markup.heading",
                "markup.heading entity.name"
            ],
            "settings": {
                "fontStyle": "bold",
                "foreground": "#86b300"
            }
        },
        {
            "name": "Markup links",
            "scope": [
                "markup.underline.link",
                "string.other.link"
            ],
            "settings": {
                "foreground": "#55b4d4"
            }
        },
        {
            "name": "Markup Italic",
            "scope": [
                "markup.italic"
            ],
            "settings": {
                "fontStyle": "italic",
                "foreground": "#f07171"
            }
        },
        {
            "name": "Markup Bold",
            "scope": [
                "markup.bold"
            ],
            "settings": {
                "fontStyle": "bold",
                "foreground": "#f07171"
            }
        },
        {
            "name": "Markup Bold/italic",
            "scope": [
                "markup.italic markup.bold",
                "markup.bold markup.italic"
            ],
            "settings": {
                "fontStyle": "bold italic"
            }
        },
        {
            "name": "Markup Code",
            "scope": [
                "markup.raw"
            ],
            "settings": {
                "background": "#5c616605"
            }
        },
        {
            "name": "Markup Code Inline",
            "scope": [
                "markup.raw.inline"
            ],
            "settings": {
                "background": "#5c61660f"
            }
        },
        {
            "name": "Markdown Separator",
            "scope": [
                "meta.separator"
            ],
            "settings": {
                "fontStyle": "bold",
                "background": "#5c61660f",
                "foreground": "#787b8099"
            }
        },
        {
            "name": "Markup Blockquote",
            "scope": [
                "markup.quote"
            ],
            "settings": {
                "foreground": "#4cbf99",
                "fontStyle": "italic"
            }
        },
        {
            "name": "Markup List Bullet",
            "scope": [
                "markup.list punctuation.definition.list.begin"
            ],
            "settings": {
                "foreground": "#f2ae49"
            }
        },
        {
            "name": "Markup added",
            "scope": [
                "markup.inserted"
            ],
            "settings": {
                "foreground": "#6cbf43"
            }
        },
        {
            "name": "Markup modified",
            "scope": [
                "markup.changed"
            ],
            "settings": {
                "foreground": "#478acc"
            }
        },
        {
            "name": "Markup removed",
            "scope": [
                "markup.deleted"
            ],
            "settings": {
                "foreground": "#ff7383"
            }
        },
        {
            "name": "Markup Strike",
            "scope": [
                "markup.strike"
            ],
            "settings": {
                "foreground": "#e6ba7e"
            }
        },
        {
            "name": "Markup Table",
            "scope": [
                "markup.table"
            ],
            "settings": {
                "background": "#5c61660f",
                "foreground": "#55b4d4"
            }
        },
        {
            "name": "Markup Raw Inline",
            "scope": [
                "text.html.markdown markup.inline.raw"
            ],
            "settings": {
                "foreground": "#ed9366"
            }
        },
        {
            "name": "Markdown - Line Break",
            "scope": [
                "text.html.markdown meta.dummy.line-break"
            ],
            "settings": {
                "background": "#787b8099",
                "foreground": "#787b8099"
            }
        },
        {
            "name": "Markdown - Raw Block Fenced",
            "scope": [
                "punctuation.definition.markdown"
            ],
            "settings": {
                "background": "#5c6166",
                "foreground": "#787b8099"
            }
        }
    ],
    "semanticHighlighting": true,
    "semanticTokenColors": {
        "parameter.label": "#5c6166"
    }
}
carlca commented 10 months ago

Does this file work... ? ilxqx.zip

You'll need to unzip it and the import it into your JetBrains IDE under: Settings -> Editor -> Color Scheme -> βš™οΈ

I don't know if the colours are correct - it seems very bright to me, but then my idea of a flamboyant colour scheme is grey on black πŸ˜‰

To explain briefly what I did:

The code in convert.sh does the job in two parts:

#!/bin/bash

VSC_FILES=./vscThemes/*.json
TM_OUTDIR=./tmThemes/

shopt -s nullglob

for FILE in $VSC_FILES
do
    FN="${FILE##*/}"
    DIR="${FILE:0:${#FILE} - ${#FN}}"
    BASE="${FN%.[^.]*}"
    EXT="${FN:${#BASE} + 1}"
    echo converting $DIR$FN to $TM_OUTDIR$BASE.tmTheme ...
    node vscToTm.js "$FILE" "$TM_OUTDIR$BASE.tmTheme" >> ./colorSchemeTool.log
done

TM_FILES=./tmThemes/*.tmTheme
IJ_OUTDIR=./intellijThemes/

shopt -s nullglob

for FILE in $TM_FILES
do
    FN="${FILE##*/}"
    DIR="${FILE:0:${#FILE} - ${#FN}}"
    BASE="${FN%.[^.]*}"
    EXT="${FN:${#BASE} + 1}"
    echo converting $DIR$FN to $IJ_OUTDIR$BASE.icls ...
    python3 colorSchemeTool.py "$FILE" "$IJ_OUTDIR$BASE.icls" >> ./colorSchemeTool.log
done

The first part takes the .json file in the vscThemes folder and uses the vscToTm.js javascript script to convert to a .thTheme file in the thThemes folder'.

The second part takes the .thTheme file and uses the colorSchemeTool.py script to convert the theme to an .icls file in the intellijThemes folder.

The problem was that the .thTheme file was being produced with one line missing...

<plist version="1.0">
  <dict>
    <key>name</key>
    <key>settings</key>
    <array>

It needed an extra line like so...

<plist version="1.0">
  <dict>
    <key>name</key>
    <string>Light-</string>
    <key>settings</key>
    <array>

I then commented out the first half of the convert.sh script and ran it again so that the .tmTheme file from before was preserved and the .icls file was produced.

I hope that helps πŸ˜ƒ

ilxqx commented 10 months ago

@carlca Thank you very much. It works very well, you are really awesome. Thanks for your detailed guidance and response. This theme is a theme that I really like. I like bright themes. Thank you for helping me to fulfill the requirement of using the vscode theme in Jetbrains IDE. Thanks again! πŸ‘πŸ‘πŸ‘

ilxqx commented 10 months ago

@carlca According to your guidance, I have found a way to fix it. 1、The first issue is the problem that the "name" attribute value is missing in the plist. The solution is to add a root property name in the JSON file of the theme, like this:

{
    "name": "Ayu Light",
    "type": "light",
    "tokenColors": ["...omitted"],
    "semanticHighlighting": true,
    "semanticTokenColors": {
        "parameter.label": "#5c6166"
    }
}

2、Python script error AttributeError: 'module' object has no attribute 'load' The solution is that the load method seems not to exist in plistlib in python 2.7, there is an alternative method called readPlist, so you can solve the problem by changing the function load_textmate_scheme as follows:

def load_textmate_scheme(tmtheme):
    print "Load theme: ", tmtheme
    print dir(plistlib)
    themeDict = None
    with open(tmtheme, 'rb') as f:
        themeDict = plistlib.readPlist(f) # Here is the original load changed to readPlist
    all_settings = themeDict['settings']
    used_scopes = set()
    #...omitted

Then run ./convert.sh again, and it will work perfectly. Thank you for the inspiration.

carlca commented 10 months ago

@ilxqx Hello again! I'm glad you got it working. Actually, your solution is better than mine because it addresses a problem with the initial .json file!

ilxqx commented 10 months ago

@ilxqx Hello again! I'm glad you got it working. Actually, your solution is better than mine because it addresses a problem with the initial .json file!

Thanks to your guidance. πŸ™

Pathadyl commented 2 months ago

Hi, I have encountered problems. I try both Python 3.11.3 and Python 2.7.16. I try to convert the "winter is coming" theme in JSON file to .icls file. Both have the error when converting from json to tm file is "Command not found". Help me to convert please. Here is the winteriscomming json file:

{ "name": "Winter Is Coming", "type": "dark", "tokenColors": [ { "settings": { "foreground": "#bce7ff" } }, { "scope": ["meta.paragraph.markdown", "string.other.link.description.title.markdown"], "settings": { "foreground": "#EEFFFF" } }, { "scope": ["entity.name.section.markdown", "punctuation.definition.heading.markdown"], "settings": { "foreground": "#5ABEB0" } }, { "scope": [ "punctuation.definition.string.begin.markdown", "punctuation.definition.string.end.markdown", "markup.quote.markdown" ], "settings": { "foreground": "#82AAFF" } }, { "scope": ["markup.quote.markdown"], "settings": { "fontStyle": "italic", "foreground": "#82AAFF" } }, { "scope": ["markup.bold.markdown", "punctuation.definition.bold.markdown"], "settings": { "fontStyle": "bold", "foreground": "#57cdff" } }, { "scope": ["markup.italic.markdown", "punctuation.definition.italic.markdown"], "settings": { "fontStyle": "italic", "foreground": "#C792EA" } }, { "scope": ["markup.inline.raw.string.markdown", "markup.fenced_code.block.markdown"], "settings": { "fontStyle": "italic", "foreground": "#f7ecb5" } }, { "scope": ["punctuation.definition.metadata.markdown"], "settings": { "foreground": "#f3b8c2" } }, { "scope": ["markup.underline.link.image.markdown", "markup.underline.link.markdown"], "settings": { "foreground": "#6dbdfa" } }, { "name": "Comment", "scope": "comment", "settings": { "fontStyle": "italic", "foreground": "#999999" } }, { "name": "Quotes", "scope": "punctuation.definition.string", "settings": { "foreground": "#6bff81" } }, { "name": "String", "scope": "string", "settings": { "foreground": "#bcf0c0" } }, { "name": "String Quoted", "scope": ["string.quoted", "variable.other.readwrite.js"], "settings": { "fontStyle": "", "foreground": "#bcf0c0" } }, { "name": "Number", "scope": "constant.numeric", "settings": { "foreground": "#8dec95" } }, { "name": "Boolean", "scope": "constant.language.boolean", "settings": { "foreground": "#8dec95" } }, { "name": "Constant", "scope": "constant", "settings": { "foreground": "#A170C6" } }, { "name": "Built-in constant", "scope": ["constant.language", "punctuation.definition.constant", "variable.other.constant"], "settings": { "foreground": "#92b6f4" } }, { "name": "User-defined constant", "scope": ["constant.character", "constant.other"], "settings": { "foreground": "#82AAFF" } }, { "name": "Variable", "scope": "variable", "settings": { "fontStyle": "italic", "foreground": "#a4ceee" } }, { "name": "JavaScript Other Variable", "scope": "variable.other.object.js", "settings": { "foreground": "#d6deeb", "fontStyle": "italic" } }, { "name": "TypeScript[React] Variables and Object Properties", "scope": [ "variable.other.readwrite.alias.ts", "variable.other.readwrite.alias.tsx", "variable.other.readwrite.ts", "variable.other.readwrite.tsx", "variable.other.object.ts", "variable.other.object.tsx", "variable.object.property.ts", "variable.object.property.tsx", "variable.other.ts", "variable.other.tsx", "variable.tsx", "variable.ts" ], "settings": { "foreground": "#d6deeb" } }, { "name": "TypeScript Classes", "scope": "meta.class entity.name.type.class.tsx", "settings": { "foreground": "#d29ffcff" } }, { "name": "TypeScript Entity Name Type", "scope": ["entity.name.type.tsx", "entity.name.type.module.tsx"], "settings": { "foreground": "#d29ffcff" } }, { "name": "TypeScript Method Declaration e.g. constructor", "scope": ["meta.method.declaration storage.type.ts", "meta.method.declaration storage.type.tsx"], "settings": { "foreground": "#a1bde6" } }, { "name": "Variable Property Other object property", "scope": ["variable.other.object.property"], "settings": { "foreground": "#f7ecb5", "fontStyle": "italic" } }, { "name": "Variable Instances", "scope": [ "variable.instance", "variable.other.instance", "variable.readwrite.instance", "variable.other.readwrite.instance", "variable.other.property" ], "settings": { "foreground": "#7fdbca" } }, { "name": "JavaScript Variable Other ReadWrite", "scope": ["variable.other.readwrite.js", "variable.parameter"], "settings": { "foreground": "#d7dbe0" } }, { "name": "Template Strings", "scope": "string.template meta.template.expression", "settings": { "foreground": "#c63ed3" } }, { "name": "Backtics(``) in Template Strings", "scope": "string.template punctuation.definition.string", "settings": { "foreground": "#fff" } }, { "name": "Storage", "scope": "storage", "settings": { "fontStyle": "", "foreground": "#6dbdfa" } }, { "name": "Keywords and Storage types", "scope": ["keyword", "storage.type", "storage.modifier", "variable.language.this"], "settings": { "foreground": "#00bff9", "fontStyle": "italic" } }, { "name": "Keywords operators", "scope": ["keyword.operator"], "settings": { "foreground": "#00bff9", "fontStyle": "italic" } }, { "name": "Storage", "scope": [ "storage", "meta.var.expr", "meta.class meta.method.declaration meta.var.expr storage.type.js", "storage.type.property.js", "storage.type.property.ts" ], "settings": { "foreground": "#c792ea", "fontStyle": "italic" } }, { "name": "JavaScript module imports and exports", "scope": [ "variable.other.meta.import.js", "meta.import.js variable.other", "variable.other.meta.export.js", "meta.export.js variable.other" ], "settings": { "foreground": "#d3eed6" } }, { "name": "Class name", "scope": "entity.name.class", "settings": { "foreground": "#f7ecb5" } }, { "name": "Inherited class", "scope": "entity.other.inherited-class", "settings": { "fontStyle": "", "foreground": "#4FB4D8" } }, { "name": "Variables, Let and Const", "scope": ["variable.other.readwrites", "meta.definition.variable"], "settings": { "fontStyle": "", "foreground": "#f7ecb5" } }, { "name": "Support Variable Property", "scope": "support.variable.property", "settings": { "foreground": "#7fdbca" } }, { "name": "Function name", "scope": "entity.name.function", "settings": { "fontStyle": "italic", "foreground": "#87aff4" } }, { "name": "Function argument", "scope": "variable.parameter", "settings": { "foreground": "#d7dbe0", "fontStyle": "" } }, { "name": "Tag name", "scope": "entity.name.tag", "settings": { "fontStyle": "", "foreground": "#6dbdfa" } }, { "name": "Entity Name Type", "scope": "entity.name.type", "settings": { "foreground": "#d29ffc" } }, { "name": "Tag attribute", "scope": "entity.other.attribute-name", "settings": { "fontStyle": "italic", "foreground": "#f7ecb5" } }, { "name": "Meta - Decorator", "scope": ["punctuation.decorator"], "settings": { "fontStyle": "italic", "foreground": "#f7ecb5" } }, { "name": "Punctuation/Brackets/Tags", "scope": ["punctuation.definition.block", "punctuation.definition.tag"], "settings": { "foreground": "#ffffff" } }, { "name": "Library function", "scope": "support.function", "settings": { "fontStyle": "", "foreground": "#f7ecb5" } }, { "name": "Library constant", "scope": "support.constant", "settings": { "fontStyle": "", "foreground": "#ec9cd2" } }, { "name": "Library class/type", "scope": ["support.type", "support.class"], "settings": { "foreground": "#7fdbca" } }, { "name": "Library variable", "scope": "support.other.variable", "settings": { "foreground": "#CBCDD2" } }, { "name": "Invalid", "scope": "invalid", "settings": { "fontStyle": " italic bold underline", "foreground": "#6dbdfa" } }, { "name": "Invalid deprecated", "scope": "invalid.deprecated", "settings": { "foreground": "#6dbdfa", "fontStyle": " bold italic underline" } }, { "name": "JSON Property Names", "scope": "support.type.property-name.json", "settings": { "foreground": "#91dacd" } }, { "name": "JSON Support Constants", "scope": "support.constant.json", "settings": { "foreground": "#addb67" } }, { "name": "JSON Property values (string)", "scope": "meta.structure.dictionary.value.json string.quoted.double", "settings": { "foreground": "#e0aff5" } }, { "name": "Strings in JSON values", "scope": "string.quoted.double.json punctuation.definition.string.json", "settings": { "foreground": "#80CBC4" } }, { "name": "Specific JSON Property values like null", "scope": "meta.structure.dictionary.json meta.structure.dictionary.value constant.language", "settings": { "foreground": "#f29fd8" } }, { "name": "[JSON] - Support", "scope": "source.json support", "settings": { "foreground": "#6dbdfa" } }, { "name": "[JSON] - String", "scope": ["source.json string", "source.json punctuation.definition.string"], "settings": { "foreground": "#ece7cd" } }, { "name": "Lists", "scope": "markup.list", "settings": { "foreground": "#6dbdfa" } }, { "name": "Headings", "scope": ["markup.heading punctuation.definition.heading", "entity.name.section"], "settings": { "fontStyle": "", "foreground": "#4FB4D8" } }, { "name": "Support", "scope": [ "text.html.markdown meta.paragraph meta.link.inline", "text.html.markdown meta.paragraph meta.link.inline punctuation.definition.string.begin.markdown", "text.html.markdown meta.paragraph meta.link.inline punctuation.definition.string.end.markdown" ], "settings": { "foreground": "#78bd65" } }, { "name": "[Markdown] text ", "scope": ["meta.paragraph.markdown"], "settings": { "foreground": "#ffffff" } }, { "name": "Quotes", "scope": "markup.quote", "settings": { "foreground": "#78bd65", "fontStyle": "italic" } }, { "name": "Link Url", "scope": "meta.link", "settings": { "foreground": "#78BD65" } }, { "name": "Dockerfile", "scope": "source.dockerfile", "settings": { "foreground": "#99d0f7" } } ], "colors": { "activityBar.background": "#011627", "activityBar.foreground": "#99d0f7", "activityBar.border": "#219fd544", "activityBarBadge.background": "#219fd5", "activityBarBadge.foreground": "#ffffff", "badge.background": "#219fd5", "badge.foreground": "#ffffff", "button.background": "#03648a", "button.foreground": "#ffffff", "button.hoverBackground": "#219fd5", "contrastActiveBorder": "#122d42", "contrastBorder": "#122d42", "foreground": "#d6deeb", "debugExceptionWidget.background": "#011627", "debugToolBar.background": "#022846", "diffEditor.insertedTextBackground": "#99b76d23", "diffEditor.insertedTextBorder": "#addb6733", "diffEditor.removedTextBackground": "#ef535033", "diffEditor.removedTextBorder": "#ef53504d", "editor.background": "#011627", "editor.foreground": "#a7dbf7", "editor.inactiveSelectionBackground": "#7e57c25a", "editor.hoverHighlightBackground": "#0c4994", "editor.lineHighlightBackground": "#0c499477", "editor.selectionBackground": "#103362", "editor.selectionHighlightBackground": "#103362", "editor.findMatchHighlightBackground": "#103362", "editor.rangeHighlightBackground": "#103362", "editor.wordHighlightBackground": "#103362", "editor.wordHighlightStrongBackground": "#103362", "editorBracketMatch.background": "#219fd54d", "editorOverviewRuler.currentContentForeground": "#7e57c2", "editorOverviewRuler.incomingContentForeground": "#7e57c2", "editorOverviewRuler.commonContentForeground": "#7e57c2", "editorCursor.foreground": "#219fd5", "editorError.foreground": "#ef5350", "editorGroup.border": "#219fd544", "editorGroupHeader.tabsBackground": "#011627", "editorGutter.background": "#011627", "editorHoverWidget.background": "#011627", "editorHoverWidget.border": "#5f7e97", "editorIndentGuide.activeBackground": "#C792EA", "editorIndentGuide.background": "#0e2c45", "editorLineNumber.foreground": "#219fd5", "editorSuggestWidget.background": "#2C3043", "editorSuggestWidget.border": "#2B2F40", "editorSuggestWidget.foreground": "#d6deeb", "editorSuggestWidget.highlightForeground": "#ffffff", "editorSuggestWidget.selectedBackground": "#5f7e97", "editorWarning.foreground": "#ffca28", "editorWhitespace.foreground": "#3B3A32", "editorWidget.background": "#0b2942", "editorWidget.border": "#262A39", "errorForeground": "#EF5350", "gitDecoration.modifiedResourceForeground": "#219fd5", "gitDecoration.untrackedResourceForeground": "#5ABEB0", "input.background": "#0b253a", "input.border": "#5f7e97", "input.foreground": "#ffffffcc", "input.placeholderForeground": "#5f7e97", "inputOption.activeBorder": "#ffffff", "inputValidation.errorBackground": "#ef5350", "inputValidation.errorBorder": "#ef5350", "inputValidation.infoBackground": "#219fd5", "inputValidation.infoBorder": "#219fd5", "inputValidation.warningBackground": "#f7ecb5", "inputValidation.warningBorder": "#f7ecb5", "inputValidation.warningForeground": "#000000", "list.activeSelectionBackground": "#219fd5", "list.inactiveSelectionBackground": "#0e293f", "list.inactiveSelectionForeground": "#5f7e97", "list.invalidItemForeground": "#975f94", "list.dropBackground": "#011627", "list.focusBackground": "#03648a", "list.focusForeground": "#ffffff", "list.highlightForeground": "#ffffff", "list.hoverBackground": "#011627", "list.hoverForeground": "#219fd5", "notifications.background": "#011627", "notifications.foreground": "#ffffffcc", "notificationLink.foreground": "#80CBC4", "notificationToast.border": "#219fd544", "panel.background": "#011627", "panel.border": "#219fd5", "panelTitle.activeBorder": "#5f7e97", "panelTitle.activeForeground": "#219fd5", "panelTitle.inactiveForeground": "#5f7e97", "peekView.border": "#f7ecb5", "peekViewEditor.background": "#011627", "peekViewResult.background": "#011627", "peekViewTitle.background": "#011627", "peekViewEditor.matchHighlightBackground": "#7e57c25a", "peekViewResult.matchHighlightBackground": "#7e57c25a", "peekViewResult.selectionBackground": "#2E3250", "peekViewResult.selectionForeground": "#cecece", "peekViewTitleDescription.foreground": "#697098", "peekViewTitleLabel.foreground": "#cecece", "pickerGroup.border": "#219fd544", "quickInput.list.focusBackground": "#219fd5", "scrollbar.shadow": "#010b14", "scrollbarSlider.activeBackground": "#084d8180", "scrollbarSlider.background": "#084d8180", "scrollbarSlider.hoverBackground": "#084d8180", "selection.background": "#4373c2", "sideBar.background": "#011627", "sideBar.border": "#219fd544", "sideBarSectionHeader.background": "#011627", "sideBar.foreground": "#7799bb", "sideBarTitle.foreground": "#7799bb", "sideBarSectionHeader.foreground": "#7799bb", "statusBar.background": "#219fd5", "statusBar.debuggingBackground": "#b15a91", "statusBar.noFolderBackground": "#011627", "statusBarItem.activeBackground": "#03648a", "statusBarItem.hoverBackground": "#03648a", "statusBarItem.prominentBackground": "#03648a", "statusBarItem.prominentHoverBackground": "#03648a", "tab.activeBackground": "#0b2942", "tab.activeForeground": "#d2dee7", "tab.inactiveBackground": "#010e1a", "tab.inactiveForeground": "#5f7e97", "tab.activeBorderTop": "#219fd5", "terminal.ansiBlack": "#011627", "textLink.foreground": "#219fd5", "textLink.activeForeground": "#98c8ed", "titleBar.activeBackground": "#112233", "titleBar.activeForeground": "#eeefff", "titleBar.border": "#303030", "titleBar.inactiveBackground": "#000a11", "walkThrough.embeddedEditorBackground": "#001111", "welcomePage.buttonBackground": "#011627", "welcomePage.buttonHoverBackground": "#011627", "widget.shadow": "#219fd5" } }

PanandSu commented 1 week ago

who can help me? i convert it,but find erros: python2.7

root@632bbdc3b7b8:/colorSchemeTool# ./convert.sh
converting ./vscThemes/eva.json to ./tmThemes/eva.tmTheme ...
converting ./tmThemes/eva.tmTheme to ./intellijThemes/eva.icls ...
Traceback (most recent call last):
  File "colorSchemeTool.py", line 926, in <module>
    all_settings, used_scopes = load_textmate_scheme(sys.argv[1])
  File "colorSchemeTool.py", line 774, in load_textmate_scheme
    themeDict = plistlib.load(f)
AttributeError: 'module' object has no attribute 'load'

this is my vscode theme json file: eva.json thanks a lot!