How to add simple custom language support?
Closed this issue · 2 comments
Beyerheiser commented
For example I want to parse something like this: equals('somestring') | equals('anotherstring') | ...
- Syntax should be checked with error suggestions.
- Autocomplete.
- Highlighting.
Especially interested in the first. Or this isn't straightforward?
rcjsuen commented
@Beyerheiser You need to use the setModelMarkers
function in monaco.editor
.
Lines 852 to 855 in 0e0cf00
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
}
]);
Beyerheiser commented
Thank you!