Skip to content

Commit c3d0872

Browse files
committed
extend js with p5 js
1 parent 9cbbd8b commit c3d0872

File tree

4 files changed

+191
-789
lines changed

4 files changed

+191
-789
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { LanguageSupport } from '@codemirror/language';
2+
import { javascript } from '@codemirror/lang-javascript';
3+
4+
function testCompletions(context) {
5+
const word = context.matchBefore(/\w*/);
6+
if (word.from === word.to && !context.explicit) return null;
7+
8+
return {
9+
from: word.from,
10+
options: [
11+
{ label: 'connie', type: 'keyword' },
12+
{ label: 'rachel', type: 'variable', info: '(World)' },
13+
{ label: 'claire', type: 'text', apply: '⠁⭒*.✩.*⭒⠁', detail: 'macro' }
14+
]
15+
};
16+
}
17+
18+
export default function p5JavaScript() {
19+
const jsLang = javascript();
20+
return new LanguageSupport(jsLang.language, [
21+
jsLang.extension,
22+
jsLang.language.data.of({
23+
autocomplete: testCompletions
24+
})
25+
]);
26+
}

client/modules/IDE/components/Editor/stateUtils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import {
4040
abbreviationTracker
4141
} from '@emmetio/codemirror6-plugin';
4242

43-
import { javascript } from '@codemirror/lang-javascript';
4443
import { css } from '@codemirror/lang-css';
4544
import { html } from '@codemirror/lang-html';
4645
import { json } from '@codemirror/lang-json';
@@ -51,6 +50,7 @@ import { HTMLHint } from 'htmlhint';
5150
import { CSSLint } from 'csslint';
5251
import { emmetConfig } from '@emmetio/codemirror6-plugin';
5352

53+
import p5JavaScript from './p5Javascript';
5454
import tidyCodeWithPrettier from './tidier';
5555

5656
// ----- TODOS -----
@@ -87,7 +87,7 @@ function getFileLanguage(fileName) {
8787

8888
switch (fileMode) {
8989
case 'javascript':
90-
return javascript;
90+
return p5JavaScript;
9191
case 'css':
9292
return css;
9393
case 'html':

0 commit comments

Comments
 (0)