When using defineTheme and setMonarchTokensProvider, the default theme is overridden
I introduced the cpp language pack, but I wanted to customize some hints and highlight them, but when I set them, they overwrite the vs theme by default
monaco.languages.setMonarchTokensProvider('cpp', {
tokenizer: {
root: [['AddField', 'custom-keywords']]
}
});
monaco.editor.defineTheme('custom-theme', {
base: 'vs',
inherit: true,
rules: [{ token: 'custom-keywords', foreground: 'ce63eb' }],
colors: {
'editor.foreground': '#000000'
}
});
editorInstance = monaco.editor.create(editorRef.value as HTMLElement, {
value: code.value,
language: 'cpp',
automaticLayout: true,
theme:"custom-theme"
});
monaco.languages.registerCompletionItemProvider('cpp', {
provideCompletionItems: (model, position) => {
const word = model.getWordUntilPosition(position);
const range = {
startLineNumber: position.lineNumber,
endLineNumber: position.lineNumber,
startColumn: word.startColumn,
endColumn: word.endColumn
};
const suggestions = data.map(item => ({
detail: 'test',
label: item,
kind: monaco.languages.CompletionItemKind.Text,
insertText: item,
range
}));
return { suggestions };
}
});
How can I introduce cpp language packs and automatically prompt and highlight them without overwriting the default vs theme style