Skip to content

Commit 28163bc

Browse files
committed
allow passing CompletionSection to keywordsSection
1 parent 97244b5 commit 28163bc

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/complete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export function completeFromSchema(schema: SQLNamespace,
204204
}
205205
}
206206

207-
export function completeKeywords(keywords: {[name: string]: number}, upperCase: boolean, section?: string, mapper?: (keywords: Completion[]) => Completion[]) {
207+
export function completeKeywords(keywords: {[name: string]: number}, upperCase: boolean, section?: string | CompletionSection, mapper?: (keywords: Completion[]) => Completion[]) {
208208
let completions: Completion[] = Object.keys(keywords).map(keyword => ({
209209
label: upperCase ? keyword.toUpperCase() : keyword,
210210
type: keywords[keyword] == Type ? "type" : keywords[keyword] == Keyword ? "keyword" : "variable",

src/sql.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {continuedIndent, indentNodeProp, foldNodeProp, LRLanguage, LanguageSupport} from "@codemirror/language"
22
import {Extension} from "@codemirror/state"
3-
import {Completion, CompletionSource} from "@codemirror/autocomplete"
3+
import {Completion, CompletionSection, CompletionSource} from "@codemirror/autocomplete"
44
import {styleTags, tags as t} from "@lezer/highlight"
55
import {parser as baseParser} from "./sql.grammar"
66
import {tokens, Dialect, tokensFor, SQLKeywords, SQLTypes, dialect} from "./tokens"
@@ -150,19 +150,19 @@ export interface SQLConfig {
150150
/// When set to true, keyword completions will be upper-case.
151151
upperCaseKeywords?: boolean,
152152
/// When given, keyword completions will be placed in this section.
153-
keywordsSection?: string,
153+
keywordsSection?: string | CompletionSection,
154154
/// When given, keyword completions will be mapped using this function.
155155
keywordsMapper?: (keywords: Completion[]) => Completion[]
156156
}
157157

158158
/// Returns a completion source that provides keyword completion for
159159
/// the given SQL dialect.
160-
export function keywordCompletionSource(dialect: SQLDialect, upperCase = false, section?: string, mapper?: (keywords: Completion[]) => Completion[]): CompletionSource {
160+
export function keywordCompletionSource(dialect: SQLDialect, upperCase = false, section?: string | CompletionSection, mapper?: (keywords: Completion[]) => Completion[]): CompletionSource {
161161
return completeKeywords(dialect.dialect.words, upperCase, section, mapper)
162162
}
163163

164164
/// FIXME remove on 1.0 @internal
165-
export function keywordCompletion(dialect: SQLDialect, upperCase = false, section?: string, mapper?: (keywords: Completion[]) => Completion[]): Extension {
165+
export function keywordCompletion(dialect: SQLDialect, upperCase = false, section?: string | CompletionSection, mapper?: (keywords: Completion[]) => Completion[]): Extension {
166166
return dialect.language.data.of({
167167
autocomplete: keywordCompletionSource(dialect, upperCase, section, mapper)
168168
})

0 commit comments

Comments
 (0)