How use basic autocomplete

Hi, I’m new and I’m having trouble implementing autocompletion. Could someone give me an example of how I can use it?

Here is the sample code that I can’t implement:

function myCompletions(context) {
  let word = context.matchBefore(/\w*/)
  if (word.from == word.to && !context.explicit)
    return null
  return {
    from: word.from,
    options: [
      {label: "match", type: "keyword"},
      {label: "hello", type: "variable", info: "(World)"},
      {label: "magic", type: "text", apply: "⠁⭒*.✩.*⭒⠁", detail: "macro"}
    ]
  }
}

Thank you very much if someone can help me :
:grin:

It can be useful for you.

https://codemirror.net/try/?example=Custom%20completions

Thanks a lot. Very useful, I have already been able to make it work in my demo. I appreciate your help @vugard <3

1 Like