Skip to content

Commit

Permalink
feat: support for semantic highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Jun 27, 2023
1 parent 62e582a commit ee722b1
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 22,31 @@ const afterReady = (theme: string) => {
inlineSuggest: {
enabled: false,
},
'semanticHighlighting.enabled': true,
});

// Support for semantic highlighting
const t = (editorInstance as any)._themeService._theme
t.getTokenStyleMetadata = (
type: string,
modifiers: string[],
_language: string
) => {
const _readonly = modifiers.includes('readonly')
switch (type) {
case 'function':
case 'method':
return { foreground: 12 }
case 'class':
return { foreground: 11 }
case 'variable':
case 'property':
return { foreground: _readonly ? 21 : 9 }
default:
return { foreground: 0 }
}
}

loadGrammars(monaco, editorInstance);
};

Expand Down

0 comments on commit ee722b1

Please sign in to comment.