mirror of
https://github.com/gradio-app/gradio.git
synced 2025-04-06 12:30:29 +08:00
Add SQL Support for gr.Code (#7328)
* add sql language support, Fixes https://github.com/gradio-app/gradio/issues/7316 * format * add missing languages * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com>
This commit is contained in:
parent
2244059cdb
commit
c1a7ea7c0c
6
.changeset/shaky-sloths-retire.md
Normal file
6
.changeset/shaky-sloths-retire.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
"@gradio/code": minor
|
||||
"gradio": minor
|
||||
---
|
||||
|
||||
feat:Add SQL Support for gr.Code
|
@ -29,6 +29,19 @@ class Code(Component):
|
||||
"dockerfile",
|
||||
"shell",
|
||||
"r",
|
||||
"sql",
|
||||
"sql-msSQL",
|
||||
"sql-mySQL",
|
||||
"sql-mariaDB",
|
||||
"sql-sqlite",
|
||||
"sql-cassandra",
|
||||
"sql-plSQL",
|
||||
"sql-hive",
|
||||
"sql-pgSQL",
|
||||
"sql-gql",
|
||||
"sql-gpSQL",
|
||||
"sql-sparkSQL",
|
||||
"sql-esper",
|
||||
None,
|
||||
]
|
||||
|
||||
@ -54,6 +67,19 @@ class Code(Component):
|
||||
"dockerfile",
|
||||
"shell",
|
||||
"r",
|
||||
"sql",
|
||||
"sql-msSQL",
|
||||
"sql-mySQL",
|
||||
"sql-mariaDB",
|
||||
"sql-sqlite",
|
||||
"sql-cassandra",
|
||||
"sql-plSQL",
|
||||
"sql-hive",
|
||||
"sql-pgSQL",
|
||||
"sql-gql",
|
||||
"sql-gpSQL",
|
||||
"sql-sparkSQL",
|
||||
"sql-esper",
|
||||
]
|
||||
| None = None,
|
||||
*,
|
||||
|
@ -1,5 +1,6 @@
|
||||
import type { Extension } from "@codemirror/state";
|
||||
import { StreamLanguage } from "@codemirror/language";
|
||||
import { sql } from "@codemirror/legacy-modes/mode/sql";
|
||||
|
||||
const possible_langs = [
|
||||
"python",
|
||||
@ -12,9 +13,26 @@ const possible_langs = [
|
||||
"yaml",
|
||||
"dockerfile",
|
||||
"shell",
|
||||
"r"
|
||||
"r",
|
||||
"sql"
|
||||
];
|
||||
|
||||
const sql_dialects = [
|
||||
"standardSQL",
|
||||
"msSQL",
|
||||
"mySQL",
|
||||
"mariaDB",
|
||||
"sqlite",
|
||||
"cassandra",
|
||||
"plSQL",
|
||||
"hive",
|
||||
"pgSQL",
|
||||
"gql",
|
||||
"gpSQL",
|
||||
"sparkSQL",
|
||||
"esper"
|
||||
] as const;
|
||||
|
||||
const lang_map: Record<string, (() => Promise<Extension>) | undefined> = {
|
||||
python: () => import("@codemirror/lang-python").then((m) => m.python()),
|
||||
markdown: async () => {
|
||||
@ -48,7 +66,20 @@ const lang_map: Record<string, (() => Promise<Extension>) | undefined> = {
|
||||
r: () =>
|
||||
import("@codemirror/legacy-modes/mode/r").then((m) =>
|
||||
StreamLanguage.define(m.r)
|
||||
)
|
||||
),
|
||||
sql: () =>
|
||||
import("@codemirror/legacy-modes/mode/sql").then((m) =>
|
||||
StreamLanguage.define(m.standardSQL)
|
||||
),
|
||||
...Object.fromEntries(
|
||||
sql_dialects.map((dialect) => [
|
||||
"sql-" + dialect,
|
||||
() =>
|
||||
import("@codemirror/legacy-modes/mode/sql").then((m) =>
|
||||
StreamLanguage.define(m[dialect])
|
||||
)
|
||||
])
|
||||
)
|
||||
} as const;
|
||||
|
||||
const alias_map: Record<string, string> = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user