mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-15 07:38:33 +00:00
add autocompletion extension from useMemo
This commit is contained in:
parent
8e6909478c
commit
5e09c3c318
@ -133,20 +133,24 @@ export default function CodeMirror({
|
||||
);
|
||||
|
||||
const extensions = useMemo(() => {
|
||||
let _extensions = [...staticExtensions];
|
||||
let bindings = {
|
||||
vim,
|
||||
emacs,
|
||||
};
|
||||
if (bindings[keybindings]) {
|
||||
return [...staticExtensions, bindings[keybindings]()];
|
||||
}
|
||||
return staticExtensions;
|
||||
}, [keybindings]);
|
||||
|
||||
const setAutoCompletion = (isAutoCompletionEnabled) =>
|
||||
isAutoCompletionEnabled
|
||||
? javascriptLanguage.data.of({ autocomplete: strudelAutocomplete })
|
||||
: autocompletion({ override: [] });
|
||||
if (bindings[keybindings]) {
|
||||
_extensions.push(bindings[keybindings]());
|
||||
}
|
||||
|
||||
if (isAutoCompletionEnabled) {
|
||||
_extensions.push(javascriptLanguage.data.of({ autocomplete: strudelAutocomplete }));
|
||||
} else {
|
||||
_extensions.push(autocompletion({ override: [] }));
|
||||
}
|
||||
|
||||
return _extensions;
|
||||
}, [keybindings, isAutoCompletionEnabled]);
|
||||
|
||||
return (
|
||||
<div style={{ fontSize, fontFamily }} className="w-full">
|
||||
@ -156,7 +160,7 @@ export default function CodeMirror({
|
||||
onChange={handleOnChange}
|
||||
onCreateEditor={handleOnCreateEditor}
|
||||
onUpdate={handleOnUpdate}
|
||||
extensions={[...extensions, setAutoCompletion(isAutoCompletionEnabled)]}
|
||||
extensions={extensions}
|
||||
basicSetup={{ lineNumbers: isLineNumbersDisplayed }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user