Wrap/Modify Existing Autocompletes

Is there a way to wrap/modify existing code autocompletes?

I want to use @codemirror/lang-sql but modify the format that gets shown. Remove the “type” and add an “apply” to the autocompletes.

Do i need to write my own custom completion and re-implement all the autocompletes, or is there a way to modify the current autocompletes provided by the package?

https://codemirror.net/6/examples/autocompletion/

1 Like

hello filip, I created this gist to show how to add/extend autocomplete without overriding the original autocomplete.

You can wrap the completion source functions with your own function that further processes its output, and then add it to the editor using Language.data. But the SQL package wasn’t exporting completion sources directly, making it hard to get hold of the function you’d want to wrap. Version 0.20.1 exports schemaCompletionSource, which should help with that.