Skip to content

Commit

Permalink
improved editor highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
eneoli committed Sep 4, 2024
1 parent 9c80698 commit 40e0799
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 35 deletions.
42 changes: 15 additions & 27 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 41 additions & 8 deletions frontend/src/domain/code-editor/components/code-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,52 @@ function handleEditorWillMount(monaco: Monaco) {

monaco.languages.register({ id: 'alice' });
monaco.languages.setMonarchTokensProvider('alice', {
brackets: [{ token: 'delimiter.parenthesis', open: '(', close: ')' }],
keywords,
tokenizer: {
root: [
[/@?[a-zA-Z][\w$]*/, {
cases: {
'@keywords': 'keyword',
'@default': 'variable',
}
}]
]
}
[
/@?[a-zA-Z][\w$]*/, {
cases: {
'@keywords': 'keyword',
'@default': 'variable',
}
}],
{ include: '@whitespace' },],
whitespace: [
[/[ \t\r\n]+/, ''],
[/\/\*/, 'comment', '@comment'],
[/\/\/.*\\$/, 'comment', '@linecomment'],
[/\/\/.*$/, 'comment']
],
comment: [
[/[^\/*]+/, 'comment'],
[/\*\//, 'comment', '@pop'],
[/[\/*]/, 'comment']
],
linecomment: [
[/.*[^\\]$/, 'comment', '@pop'],
[/[^]+/, 'comment']
],
},
});

monaco.languages.setLanguageConfiguration('alice', {
comments: {
lineComment: '//',
blockComment: ['/*', '*/'],
},
brackets: [
['(', ')']
],
autoClosingPairs: [
{ open: '(', close: ')' },
],
surroundingPairs: [
{ open: '(', close: ')' },
],
})

monaco.languages.registerCompletionItemProvider('alice', {
provideCompletionItems: function (model, position) {
// Get the text before the cursor
Expand Down

0 comments on commit 40e0799

Please sign in to comment.