Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Syntax highlighting for .c files actually highlights C++ #157

Open
vbar opened this issue Apr 4, 2022 · 2 comments
Open

Syntax highlighting for .c files actually highlights C++ #157

vbar opened this issue Apr 4, 2022 · 2 comments
Labels
type: enhancement And enhancement or proposal to an existing feature

Comments

@vbar
Copy link
Collaborator

vbar commented Apr 4, 2022

This is most visible highlighting keywords, where the editor incorrectly highlights C++-specific bool, catch, class, constexpr, const_cast, decltype, delete, dynamic_cast, explicit, export, false, friend, mutable, namespace, new, noexcept, nullptr, operator, private, protected, public, reinterpret_cast, static_assert, static_cast, template, this, thread_local, throw, true, try, typeid, typename, using and virtual.

Also, the asm keyword isn't highlighted but should be.

@valstu
Copy link
Collaborator

valstu commented Apr 6, 2022

Monaco Editor is pretty much considering c and cpp as same langauge from syntax highlighting POV.

https://github.com/microsoft/monaco-editor/blob/main/src/basic-languages/cpp/cpp.contribution.ts
https://github.com/microsoft/monaco-editor/blob/main/src/basic-languages/cpp/cpp.ts

If I got this right the actual highlight logic is in cpp.ts. In cpp.contribution.ts you can see that editor registers c language but imports cpp logic.

Maybe you could use the cpp.ts file as a starter and build own logic for C and then we could try to register it on our monaco editor? 🤔

@vbar
Copy link
Collaborator Author

vbar commented Apr 6, 2022

Well, except for the keywords, C and C++ pretty much are the same language as far as simple highlighting is concerned - I can't think about any other construct I'd want to highlight differently... So I've removed some keywords from cpp.ts (more than in the list above - Microsoft also highlights keywords for its extensions) and put the result into a highlight/c.ts file in feat/c-highlighting branch. How does one register it in the Monaco editor?

@valstu valstu added the type: enhancement And enhancement or proposal to an existing feature label Apr 7, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
type: enhancement And enhancement or proposal to an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants