Skip to content

Feature request: set options(cli.code_theme) #87

Description

@rossellhayes

If cli::code_highlight() is called in RStudio with an unrecognized theme (i.e. a non-builtin theme), it signals a warning and doesn't highlight the code:

cli::code_highlight("1 + 1")
#> [1] "1 + 1"
#> Warning message:
#> In code_theme_default_rstudio() :
#>   cli does not know this RStudio theme: a11y-dark {rsthemes}

This can be avoided by setting options("cli.code_theme"). Here's an example for the theme "base16 Gruvbox dark, soft {rsthemes}":

options(cli.code_theme = list(
  reserved = "#D3869B",
  number = "#FE8019",
  null = "#D65D0E",
  operator = "#8EC07C",
  call = NULL,
  string = "#B8BB26",
  comment = "#BDAE93",
  bracket = list(
    "#8EC07C",
    "#83A598",
    "#FABD2F",
    "#FE8019",
    "#FB4934",
    "#B8BB26",
    "#D3869B"
  )
))

Is it possible to use data from rsthemes to set options("cli.code_theme") when calling use_theme_*()?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions