Skip to content

Add ggsql as a bundled language for input_code_editor#1291

Open
cpsievert wants to merge 9 commits intomainfrom
feat/ggsql-language
Open

Add ggsql as a bundled language for input_code_editor#1291
cpsievert wants to merge 9 commits intomainfrom
feat/ggsql-language

Conversation

@cpsievert
Copy link
Collaborator

@cpsievert cpsievert commented Mar 7, 2026

Summary

  • Adds ggsql as a first-class language in prism-code-editor, so input_code_editor(language="ggsql") works natively
  • The grammar extends SQL with ggsql-specific tokens: clause keywords (VISUALISE, DRAW, SCALE, etc.), geom types, aesthetic names, theme names, project types, and an extended SQL function list
  • Grammar derived from the TextMate grammar

Files changed

  • inst/lib/prism-code-editor/prism/languages/ggsql.js — new Prism grammar file that imports sql.js and extends it
  • tools/yarn_install.R — added "ggsql" to code_editor_bundled_languages
  • R/versions.R — added "ggsql" to the generated allowlist

Test plan

  • devtools::load_all(); shinyApp(page_fluid(input_code_editor("test", language = "ggsql", value = "SELECT * FROM t VISUALISE x AS x DRAW point")), function(input, output, session) {}) — verify VISUALISE, DRAW, point get distinct highlighting

🤖 Generated with Claude Code

cpsievert and others added 4 commits March 7, 2026 09:59
Add ggsql (SQL + visualization grammar) as a first-class language in
prism-code-editor. The grammar extends SQL with ggsql-specific tokens:
clause keywords (VISUALISE, DRAW, SCALE, etc.), geom types, aesthetic
names, theme names, project types, and an extended SQL function list.

Derived from the TextMate grammar at:
https://github.com/posit-dev/ggsql/blob/main/ggsql-vscode/syntaxes/ggsql.tmLanguage.json

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Rscript tools/build_ggsql_grammar.R fetches the TextMate grammar from
posit-dev/ggsql, extracts token patterns, and generates the Prism
grammar file. The generated ggsql.js should be copied to py-shiny
after regeneration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Instead of hardcoding clause keywords, extract them from the begin
captures and keyword.other patterns of all *-clause repository entries.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cpsievert cpsievert force-pushed the feat/ggsql-language branch from d8e4bcd to f084f5a Compare March 7, 2026 15:59
@cpsievert cpsievert requested a review from gadenbuie March 9, 2026 16:10
cpsievert and others added 2 commits March 9, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant