Skip to content

Commit 8ec4885

Browse files
committed
Add SQLDialect.configureLanguage method
FEATURE: The new `SQLDialect.configureLanguage` method can be used to configure the language (and it's syntax node props) used by a dialect. See https://discuss.codemirror.net/t/code-folding-for-postgresql-doesnt-work-as-expected/7993/14
1 parent 7997522 commit 8ec4885

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/sql.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {continuedIndent, indentNodeProp, foldNodeProp, LRLanguage, LanguageSuppo
22
import {Extension} from "@codemirror/state"
33
import {Completion, CompletionSource} from "@codemirror/autocomplete"
44
import {styleTags, tags as t} from "@lezer/highlight"
5+
import {ParserConfig} from "@lezer/lr"
56
import {parser as baseParser} from "./sql.grammar"
67
import {tokens, Dialect, tokensFor, SQLKeywords, SQLTypes, dialect} from "./tokens"
78
import {completeFromSchema, completeKeywords} from "./complete"
@@ -102,6 +103,12 @@ export class SQLDialect {
102103
/// Returns the language for this dialect as an extension.
103104
get extension() { return this.language.extension }
104105

106+
/// Reconfigure the parser used by this dialect. Returns a new
107+
/// dialect object.
108+
configureLanguage(options: ParserConfig, name?: string) {
109+
return new SQLDialect(this.dialect, this.language.configure(options, name), this.spec)
110+
}
111+
105112
/// Define a new dialect.
106113
static define(spec: SQLDialectSpec) {
107114
let d = dialect(spec, spec.keywords, spec.types, spec.builtin)

0 commit comments

Comments
 (0)