add basic sample completion
This commit is contained in:
@ -34,13 +34,17 @@ import { EditorView } from "codemirror";
|
|||||||
import { toposTheme } from "./themes/toposTheme";
|
import { toposTheme } from "./themes/toposTheme";
|
||||||
import { javascript } from "@codemirror/lang-javascript";
|
import { javascript } from "@codemirror/lang-javascript";
|
||||||
import { inlineHoveringTips } from "./documentation/inlineHelp";
|
import { inlineHoveringTips } from "./documentation/inlineHelp";
|
||||||
import { toposCompletions } from "./documentation/inlineHelp";
|
import { toposCompletions, soundCompletions } from "./documentation/inlineHelp";
|
||||||
import { javascriptLanguage } from "@codemirror/lang-javascript"
|
import { javascriptLanguage } from "@codemirror/lang-javascript"
|
||||||
|
|
||||||
export const jsCompletions = javascriptLanguage.data.of({
|
export const jsCompletions = javascriptLanguage.data.of({
|
||||||
autocomplete: toposCompletions
|
autocomplete: toposCompletions
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const toposSoundCompletions = javascriptLanguage.data.of({
|
||||||
|
autocomplete: soundCompletions
|
||||||
|
})
|
||||||
|
|
||||||
export const editorSetup: Extension = (() => [
|
export const editorSetup: Extension = (() => [
|
||||||
highlightActiveLineGutter(),
|
highlightActiveLineGutter(),
|
||||||
highlightSpecialChars(),
|
highlightSpecialChars(),
|
||||||
@ -91,7 +95,7 @@ export const installEditor = (app: Editor) => {
|
|||||||
app.withLineNumbers.of(lines),
|
app.withLineNumbers.of(lines),
|
||||||
app.fontSize.of(fontModif),
|
app.fontSize.of(fontModif),
|
||||||
app.hoveringCompartment.of(app.settings.tips ? inlineHoveringTips : []),
|
app.hoveringCompartment.of(app.settings.tips ? inlineHoveringTips : []),
|
||||||
app.completionsCompartment.of(app.settings.completions ? jsCompletions : []),
|
app.completionsCompartment.of(app.settings.completions ? [jsCompletions, toposSoundCompletions] : []),
|
||||||
editorSetup,
|
editorSetup,
|
||||||
toposTheme,
|
toposTheme,
|
||||||
app.chosenLanguage.of(javascript()),
|
app.chosenLanguage.of(javascript()),
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
import { hoverTooltip } from "@codemirror/view";
|
import { hoverTooltip } from "@codemirror/view";
|
||||||
import { type EditorView } from "@codemirror/view";
|
import { type EditorView } from "@codemirror/view";
|
||||||
import { CompletionContext } from "@codemirror/autocomplete"
|
import { CompletionContext } from "@codemirror/autocomplete"
|
||||||
|
// @ts-ignore
|
||||||
|
import { soundMap } from "superdough";
|
||||||
|
|
||||||
|
|
||||||
interface InlineCompletion {
|
interface InlineCompletion {
|
||||||
@ -996,3 +998,21 @@ export const toposCompletions = (context: CompletionContext) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const soundCompletions = (context: CompletionContext) => {
|
||||||
|
let map = soundMap.get();
|
||||||
|
delete map._base;
|
||||||
|
let match = context.matchBefore(/sound\(/);
|
||||||
|
if (match) {
|
||||||
|
let from = match.from + "sound(".length;
|
||||||
|
return {
|
||||||
|
from,
|
||||||
|
options: Object.keys(map).map(key => ({
|
||||||
|
label: key,
|
||||||
|
type: map[key].data.type,
|
||||||
|
apply: `"${key}"`
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user