Skip to contents

Convert a .tmTheme file representing a TextMate theme and write the equivalent Visual Studio Code or Positron theme file (.json).

convert_tm_to_positron_theme() is an alias for convert_tm_to_vs_theme().

Usage

convert_tm_to_vs_theme(
  path,
  outfile = tempfile(fileext = ".json"),
  name = NULL,
  author = NULL
)

convert_tm_to_positron_theme(
  path,
  outfile = tempfile(fileext = ".json"),
  name = NULL,
  author = NULL
)

Arguments

path

Path or URL to a TextMate theme file in .tmTheme format.

outfile

Path where the resulting file will be written. Defaults to a temporary file created with tempfile().

name

Theme name. If NULL, the name from the input file is used.

author

Theme author. If NULL, use the author from the input file, falling back to "rstudiothemes R package" if no author is listed.

Value

A character string containing the path to the .json theme file written to outfile.

See also

read_tm_theme() to inspect the input theme and read_vs_theme() to inspect the converted theme.

Theme file converters: convert_to_rstudio_theme(), convert_vs_to_tm_theme()

Examples

tmtheme <- system.file("ext/test.tmTheme",
  package = "rstudiothemes"
)
path <- convert_tm_to_vs_theme(tmtheme)

readLines(path) |>
  head(50) |>
  cat(sep = "\n")
#> {
#>   // Created with the rstudiothemes R package (c) dieghernan.
#>   // https://github.com/dieghernan/rstudiothemes
#>   "$schema": "vscode://schemas/color-theme",
#>   "name": "Testing RStudioTheme",
#>   "author": "rstudiothemes",
#>   "semanticHighlighting": true,
#>   "type": "dark",
#>   "tokenColors": [
#>     {
#>       "settings": {
#>         "foreground": "#DCE7FD"
#>       }
#>     },
#>     {
#>       "name": "comment",
#>       "scope": "comment",
#>       "settings": {
#>         "foreground": "#655E7F"
#>       }
#>     },
#>     {
#>       "name": "doctype",
#>       "scope": ["meta.tag.metadata.doctype", "meta.tag.sgml.doctype.html", "meta.tag.sgml.html"],
#>       "settings": {
#>         "foreground": "#655E7F"
#>       }
#>     },
#>     {
#>       "name": "punctuation",
#>       "scope": ["punctuation.definition.tag", "punctuation.separator"],
#>       "settings": {
#>         "foreground": "#DCE7FD"
#>       }
#>     },
#>     {
#>       "name": "namespace,",
#>       "scope": ["entity.name.type.namespace", "storage.modifier.import"],
#>       "settings": {
#>         "foreground": "#6A6872"
#>       }
#>     },
#>     {
#>       "name": "string",
#>       "scope": "string",
#>       "settings": {
#>         "foreground": "#93B4FF"
#>       }
#>     },
#>     {