4 ms·
We are definitely cheating there - we use the same colorizer for C and C++. I don't remember why we define two different languages that point to the same colori
by alexdima 10y ago
We are definitely cheating there - we use the same colorizer for C and C++. I don't remember why we define two different languages that point to the same colorizer.
Please help us out and contribute a PR. Here[1] is where we register the C language and point to the cpp colorizer. And here[2] is the cpp colorizer. Please go ahead and try the C++ colorizer out at the Monarch playground[3] and edit it to make it colorize only C keywords, etc. Here[4] are the steps for adding a new colorizer.
Looking forward for a contribution on this :).
[1] https://github.com/Microsoft/monaco-languages/blob/master/src/monaco.contribution.ts#L58 https://github.com/Microsoft/monaco-languages/blob/master/sr...
[2] https://github.com/Microsoft/monaco-languages/blob/master/src/cpp.ts https://github.com/Microsoft/monaco-languages/blob/master/sr...
[3] https://microsoft.github.io/monaco-editor/monarch.html https://microsoft.github.io/monaco-editor/monarch.html
[4] https://github.com/Microsoft/monaco-languages#dev-adding-a-new-language https://github.com/Microsoft/monaco-languages#dev-adding-a-n...
- satysin 10y agoThe highlighting isn't an issue, I think most editors cheat in the same way. As C++ is a super-set of C it shouldn't be a problem, at least not except for a few edge cases which I wouldn't worry about IMHO. My comment was more that the C example code is actually C++.
- mFixman 10y agoExcept C isn't a subset of C++. There are many valid C keywords that aren't valid in C++, like restrict and _Noreturn.
- satysin 10y agoWell MSVC only just supports C99 so asking for C11 keywords is unlikely to happen. I had a quick look at their C++ word list [0] and it looks like _Imaginary and _Complex and _Bool are the only missing C99 keywords. Feel free to make a PR if you want them added :) [0] https://github.com/Microsoft/monaco-languages/blob/master/src/cpp.ts https://github.com/Microsoft/monaco-languages/blob/master/sr...
- jongalloway2 10y agoFixed: https://github.com/Microsoft/monaco-editor/pull/12 https://github.com/Microsoft/monaco-editor/pull/12
- deleted 10y ago[deleted]