CodeMirror.registerHelper("lint", "customMode", function (text) {
// the "myLint()" function returns an array of error objects
// each object has a "from", "to", "severity", and "message" property
let errorsArray = myLint(text)
return errorsArray ;
});
If run the command console.log(CodeMirror.lint.customMode(code));
An array of error objects is printed to the console, each with a “to”, “from”, “severity” and “message” property. What I’m wondering is, how do I use this function so that these errors can be underlined in red in the code editor?
Thank you
hello! Is there an equivalent functionality in v6 for registerHelper? I’m migrating some old work from v5 to v6 that used registerHelper for combining the hints in autocomplete. I’ve looked into v6 docs but couldn’t find anything on registerHelper. I’m assuming there isn’t one? And if I want to combine the default autocomplete list with our custom list, is that possible to do? Thank you!
Is it correct to say that if I want to add my own custom autocompletes to the default autocompletes, I’ll need to go through the language data mechanism to “create a new language” in order to include the custom list? Say I have different modes I’m supporting and I want to include the same list. I’ll need to determine which langauge to use in order to have it this the following?
So I’m thinking to have a switch statement that will return the language (either javascriptLanguage from @codemirror/lang-javascript, or htmlLanguage from @codemirror/lang-html based on mode). I don’t see a SQLLanguage from @codemirror/lang-sql. Instead would I be calling one of the dialects instead, using it like StandardSQL.data.of({....})?
You can also add languageData.of(() => globalLanguageData) to your configuration to add language data for all languages (assuming globalLanguageData is an object with an autocomplete property holding a completion source).
Without autocompletion(), i’m not getting any errors but still I can’t see the custom list nor the default list. And when I do include autocompletion() it errors out with the following:
Uncaught TypeError: provider is not a function or its return value is not iterable
at EditorState.languageDataAt (index.js:2826:1)
at CompletionState.update (index.js:997:1)
at StateField.update [as updateF] (index.js:1136:1)
at Object.update (index.js:1798:1)
at EditorState.eval [as computeSlot] (index.js:2630:1)
at ensureAddr (index.js:2034:1)
at new EditorState (index.js:2567:1)
at EditorState.applyTransaction (index.js:2630:1)
at get state [as state] (index.js:2281:1)
at EditorView.update (index.js:6569:1)