Im working on svelte library based on top of CM6. In it, I have this option,
setup: 'basic' | 'minimal', as well as
autocomplete: boolean | CompletionConfig. For the extensions array I have a compartment for setup type, as well as autocomplete. When any option is updated, the compartment is reconfigured. The compartment for autocomplete is above setup’s compartment, so autocomplete has a higher precedence than setup.
This is how the extensions are created
return [ //!NOTE User extensions matter the most, keep em on top extensions_compartment.of(extensions ?? ), //!Note: Autocomplete may come built in with setup: basic, so always keep it above setup_compartment autocomplete_compartment.of(await get_autocompletion(autocomplete)), keymap.of([...defaultKeymap, ...(useTabs ? [indentWithTab] : )]), setup_compartment.of((await get_setup(setup)) ?? ), lang_compartment.of(await get_lang(lang, langMap)), theming_compartment.of(get_theme(theme, styles)), tabs_compartment.of(await get_tab_setting(useTabs, tabSize)), readonly_compartment.of(EditorState.readOnly.of(!readonly)), ];
autocomplete option is true or
CompletionConfig, then it works fine. But when it is
false, the compartment is reconfigured to be an empty array
. But if basic setup is applied, this does nothing. Is there a way that I can remove the
autocomplete option from the final extensions array?
As it is a library, I can’t tell user to not use
setup: 'basic' with
autocomplete, basicSetup comes with lot of goodies, so going with minimal setup for this specific case feels wrong