dbplyr icon indicating copy to clipboard operation
dbplyr copied to clipboard

feature request: Turn keyword highlighting off

Open eutwt opened this issue 3 years ago • 1 comments

I'd like keyword highlighting, but the dark blue is hard to read with a dark grey background. Would be nice if the option allowed specifying a color, but failing that I'd like to be able to turn it off.

library(dplyr, w = F)
library(testthat, w = F)
#> Warning: package 'testthat' was built under R version 4.1.2
con <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
copy_to(con, mtcars)
mtcars2 <- tbl(con, "mtcars")

local_reproducible_output(crayon = TRUE)
options(dbplyr_use_colour = FALSE)

mtcars2 %>% 
  select(mpg) %>% 
  show_query()
#> <SQL>
#> [34mSELECT[39m `mpg`
#> [34mFROM[39m `mtcars`

Created on 2022-08-13 by the reprex package (v2.0.1.9000)

My workaround for now is below, but it would be nice if there was an option

style_kw <- function(x) {
  if (dbplyr:::dbplyr_use_colour()) {
    # use `br_blue` which is more legible for a dark theme
    cli::col_br_blue(x)
  } else {
    x
  }
}
 
assignInNamespace(
  "style_kw", 
  style_kw,
  asNamespace("dbplyr")
)

eutwt avatar Aug 13 '22 16:08 eutwt

Totally makes sense! 👍

mgirlich avatar Aug 16 '22 08:08 mgirlich