Search code examples
codemirror

What is the definition of a 'helper' in CodeMirror registerHelper method


I am looking at CodeMirror help and registerHelper is described as

CodeMirror.registerHelper(type: string, name: string, value: helper)
Registers a helper value with the given name in the given namespace (type). This is used to define functionality that may be looked up by mode. ...

http://codemirror.net/doc/manual.html#registerHelper

This does not explain what the value is, when is it called (it seems to be a function), or why getHelpers accepts a position.

Is helper similar to a mode, but providing non-visual annotations (for code lookups)?


Solution

  • It's just a value -- any value. How it will be used depends on the type of helper. For "hint", it'll be a function providing completions at a given point in a document, for "hintWords", it'll be an array of strings that form possible completions, for "wordChars", it is a regular expression describing the characters that count as word characters for a mode, and so on.