-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathp5JavaScript.js
More file actions
28 lines (24 loc) · 757 Bytes
/
p5JavaScript.js
File metadata and controls
28 lines (24 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { LanguageSupport } from '@codemirror/language';
import { javascript } from '@codemirror/lang-javascript';
import { p5Hinter } from '../../../../utils/p5-hinter';
import { p5CompletionPreview } from './p5CompletionPreview';
import contextAwareHinter from '../../../../utils/contextAwareHinter';
function addCompletions(context) {
const word = context.matchBefore(/\w*/);
if (!word && !context.explicit) {
return null;
}
return contextAwareHinter(context, {
hints: p5Hinter
});
}
export default function p5JavaScript() {
const jsLang = javascript();
return new LanguageSupport(jsLang.language, [
jsLang.extension,
jsLang.language.data.of({
autocomplete: addCompletions
}),
p5CompletionPreview()
]);
}