Add ggsql as a bundled language for input_code_editor#1291
Merged
Conversation
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>
d8e4bcd to
f084f5a
Compare
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gadenbuie
approved these changes
Apr 16, 2026
Member
gadenbuie
left a comment
There was a problem hiding this comment.
Looks good to me, just one comment about the translation script looking a little brittle
Address PR feedback: - Extract repeated token extraction into extract_token_group() with validation that fails loudly if upstream grammar structure changes - Use named `flags` argument in format_word_regex() calls - Use raw string templates for JS output blocks - Remove theme-clause support (removed upstream) - Regenerate ggsql.js against latest upstream grammar Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix accumulation bug: extract_token_group now collects words across all matching patterns instead of only keeping the last match (aesthetics went from 3 to 32 words) - Accept multiple repo keys so draw-clause and place-clause geoms are merged (adds `rect`) - Add scale type values (linear, log, viridis, etc.) - Add property names from scale/facet/project/label clauses Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Filter prism/languages copy with file.exists() so ggsql.js (which is generated locally, not from upstream) doesn't cause warnings. Add a reminder to regenerate ggsql.js after yarn_install.R runs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ggsqlas a first-class language in prism-code-editor, soinput_code_editor(language="ggsql")works nativelyFiles changed
inst/lib/prism-code-editor/prism/languages/ggsql.js— new Prism grammar file that importssql.jsand extends ittools/yarn_install.R— added"ggsql"tocode_editor_bundled_languagesR/versions.R— added"ggsql"to the generated allowlistTest 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