Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source markdown editor uses R code autocompletion and syntax highlighting for third-party knitr engines #12767

Open
4 tasks done
andresrcs opened this issue Feb 28, 2023 · 7 comments

Comments

@andresrcs
Copy link

andresrcs commented Feb 28, 2023

System details

RStudio Edition : Server
RStudio Version : 2022.12.1+365
OS Version      : Ubuntu 22.04.1 LTS
R Version       : 4.2.2

Steps to reproduce the problem

  • Create an Rmd document and add a code chunk with a third-party knitr engine
```{r}
#| echo: false

library(DBI)
library(prqlr)
con <- dbConnect(RSQLite::SQLite(), ":memory:")
dbWriteTable(con, "mtcars", mtcars)
```

```{prql}
#| connection: con

from mtcars
filter cyl > 6
select [cyl, mpg]
derive [mpg_int = round 0 mpg]
take 3
```

Describe the problem in detail

The code chunk has R code autocompletion and syntax highlighting (in source mode) even if I'm using a different language, PRQL.

Describe the behavior you expected

Ideally, I would like the code autocompletion and syntax highlighting to be extensible by third-party packages but I think at least it shouldn't have the same behavior as with R code.

  • I have read the guide for submitting good bug reports.
  • I have installed the latest version of RStudio, and confirmed that the issue still persists.
  • If I am reporting an RStudio crash, I have included a diagnostics report.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
@ronblum
Copy link
Contributor

ronblum commented Mar 6, 2023

Thanks @andresrcs! I can also reproduce this in RStudio Desktop 2022.07.2+576, so it's been this way for a while (if not always). Also, from what I can tell, this works correctly in visual mode

@ronblum ronblum added source editor and removed new New incoming issues, ready for initial review. labels Mar 6, 2023
@kevinushey
Copy link
Contributor

kevinushey commented Mar 6, 2023

See:

// Embed sql highlighting rules
Utils.embedRules(
this,
SqlHighlightRules,
"sql",
this.$reSqlChunkStartString,
this.$reChunkEndString,
["start", "listblock", "allowBlock"]
);

this.$reSqlChunkStartString = engineRegex("sql");

We could add 'prql' as a language for which we should use SQL-style highlighting. Would you be willing to submit a PR?

@eitsupi
Copy link

eitsupi commented Mar 7, 2023

We could add 'prql' as a language for which we should use SQL-style highlighting.

Thanks for suggestion.
However, the syntax of PRQL is quite different from that of SQL, so a separate definition file must be added.
https://prql-lang.org/book/internals/syntax-highlighting.html

As far as the source code is concerned, do we need Ace format files?
I looked into it and it looks like these can be converted from Textmate format files?
https://github.com/ajaxorg/ace/wiki/Importing-.tmtheme-and-.tmlanguage-Files-into-Ace

@github-actions
Copy link

github-actions bot commented Sep 4, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, per https://github.com/rstudio/rstudio/wiki/Issue-Grooming. Thank you for your contributions.

@github-actions github-actions bot added the stale Issues which have been closed automatically due to inactivitiy. label Sep 4, 2023
@eitsupi
Copy link

eitsupi commented Sep 4, 2023

unstale

@github-actions github-actions bot removed the stale Issues which have been closed automatically due to inactivitiy. label Sep 5, 2023
Copy link

github-actions bot commented Mar 3, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, per https://github.com/rstudio/rstudio/wiki/Issue-Grooming. Thank you for your contributions.

@github-actions github-actions bot added the stale Issues which have been closed automatically due to inactivitiy. label Mar 3, 2024
@eitsupi
Copy link

eitsupi commented Mar 3, 2024

unstale

@github-actions github-actions bot removed the stale Issues which have been closed automatically due to inactivitiy. label Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants