uiwjs / react-codemirror

CodeMirror 6 component for React. @codemirror https://uiwjs.github.io/react-codemirror/
https://uiwjs.github.io/react-codemirror/
MIT License
1.69k stars 135 forks source link

Disable autocompletion keymap #630

Open ThatHackerDudeFromCyberspace opened 9 months ago

ThatHackerDudeFromCyberspace commented 9 months ago

Trying to just outright disable the autocompletion on enter keymap, however, I am unable to, tried the following:

<CodeMirror value="print('hi!')" extensions={[python()]} basicSetup={{completionKeymap: false, defaultKeymap: false}}></CodeMirror>

But tab and enter still indent and autocomplete respectively with no change

jaywcjlove commented 9 months ago

@Bluebotlabz

import { EditorState, EditorView, keymap } from "@codemirror/core";
import { autocompletion } from "@codemirror/autocomplete";

// Create an autocompletion plugin
const autocompletionPlugin = autocompletion();

// Create an empty keymap to disable autocompletion
const disableAutocompleteKeymap = keymap.of([]);

<CodeMirror 
    // ...
    extensions={[autocompletionPlugin, disableAutocompleteKeymap]}
/>