Ctrl+Space for autocomplete

I’m very new to CodeMirror.
I can’t make ctrl+space for autocomplete to use local variable, function parameter or any other “named” parts in code to autocomplete. When I hit ctrl+space, it does offer : “class definition”, “for loop”, etc. which works well, but in this example:


it behave as a any normal IDE.
my code is the following:
import {EditorState} from “@codemirror/state”;
import {EditorView} from “@codemirror/view”;
import {javascript} from “@codemirror/lang-javascript”
import {basicSetup} from “@codemirror/basic-setup”

let divTest = document.createElement(‘div’);
let editorState = EditorState.create({doc: “let x = 5;”, extensions:[basicSetup,javascript()]});
let myView = new EditorView({
state: editorState,
parent: divTest
});
furthermore, it doesn’t allow auto-complete of any built-in javascript function, such as console.log();

Thank you for your help.

The JavaScript package doesn’t come with any completion sources for variables yet. You could do something crude like the website demo which take global variables from the environment in the meantime.

1 Like