Ask questionsHow to add simple custom language support?
For example I want to parse something like this: equals('somestring') | equals('anotherstring') | ...
Especially interested in the first. Or this isn't straightforward?
Answer questions
rcjsuen
@Beyerheiser You need to use the setModelMarkers function in monaco.editor.
https://github.com/microsoft/monaco-editor/blob/0e0cf007e200ee1ee4a3ea55aa9210a54a78f7d5/monaco.d.ts#L852-L855
Please use the following code in the Monaco Playground to get started.
let model = monaco.editor.createModel(
'This line is okay.\nThis line has a warning.\nThis line has an error.'
);
monaco.editor.create(document.getElementById("container"), {
model
});
monaco.editor.setModelMarkers(model, "owner", [
{
startLineNumber: 2,
startColumn: 17,
endLineNumber: 2,
endColumn: 24,
message: 'Warning!',
severity: monaco.MarkerSeverity.Warning
},
{
startLineNumber: 3,
startColumn: 18,
endLineNumber: 3,
endColumn: 23,
message: 'Erorr!',
severity: monaco.MarkerSeverity.Error
}
]);
Related questions