Describe the bug
C++ identifiers with special meaning (final, override, import and module). are incorrectly highlighted out-of-context. These keywords should be considered as regular identifiers when used out of their special meaning context (c.f. C++20 standard, section 5.10, paragraph 2).
To Reproduce
vim --cleana.ccExpected behavior
Highlighting for these variables names should be the same as the one for int x;
Environment (please complete the following information):
Vim version 8.2.3323
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.![]()
That is a CPP syntax issue. So I'll leave that for https://github.com/vim-jp/vim-cpp
Closed #8745.
This is probably difficult to do properly as C++ syntax is complex and Vim does not use a C++ parser, but uses heuristics based on regexp for syntax highlighting. We can maybe improve heuristics, but we can't expect to get syntax highlighting it 100% right with heuristics. In practice, it's already doing a fairly good job for C++. Calling variables override,final or module seems quite a rare and is asking for trouble. I understand that C++ allowed that for to avoid breaking existing software. Backward compatibility is important for C++. For Vim, the cost / benefit of fixing this ticket seems low IMO.
The only way to syntax highlight C++ correctly (and other languages) 100% correctly, is to have a real C++ parser using e.g. Tree-sitter. Maybe something for Vim-10? :-)
apparently it works quite nicely for Neovim (for languages that have treesitter parsers).
apparently it works quite nicely for Neovim (for languages that have treesitter parsers).