Skip to content

Commit

Permalink
chore: add autocomplete for then statements
Browse files Browse the repository at this point in the history
  • Loading branch information
FilippoTrotter committed Sep 13, 2024
1 parent 5246da3 commit cc760ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions grammar/src/complete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ const fullStatementSnippets = fullStatementTemplates.map((x) => {
return snippetCompletion(x.label.replace(/''/g, () => `'\${${n++}:}'`), x);
});

export function completeGivenStatement(context: CompletionContext) {
export function completeStatement(context: CompletionContext) {
const line = context.state.doc.lineAt(context.pos);
let textBefore = context.state.sliceDoc(line.from, context.pos);
const triggerMatch = /G.*$/i.exec(textBefore);
const triggerMatch = /T.*$/i.exec(textBefore);

if (triggerMatch) {
const strings = textBefore.match(/'([^']*)'/g);
Expand Down
4 changes: 2 additions & 2 deletions grammar/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { parser } from "./syntax.grammar"
import { LRLanguage, LanguageSupport, HighlightStyle, syntaxHighlighting,} from "@codemirror/language"
import { styleTags, tags as t } from "@lezer/highlight"
import { completeGivenStatement } from "./complete"
import { completeStatement } from "./complete"

const syntax_colors = syntaxHighlighting(
HighlightStyle.define(
Expand Down Expand Up @@ -41,7 +41,7 @@ const syntax_colors = syntaxHighlighting(
})

const ac = SlangroomLanguage.data.of({
autocomplete: completeGivenStatement
autocomplete: completeStatement
})

export function Slangroom() {
Expand Down

0 comments on commit cc760ee

Please sign in to comment.