[vim/vim] Fix c++ float and integer literal syntax highlighting (#8939)

37 views
Skip to first unread message

Dominique Pellé

unread,
Oct 2, 2021, 3:18:24 PM10/2/21
to vim/vim, Subscribed

This PR fixes syntax highlighting of C++ floating point and integer literals, which were not properly highlighted as illustrated in the screenshot below:

cpp-wrong-syntax-highlight


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/8939

Commit Summary

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

Dominique Pellé

unread,
Oct 2, 2021, 3:25:25 PM10/2/21
to vim/vim, Subscribed

I should have indicated: I emailed the maintainer of vim/runtime/syntax/cpp.vim (Ken Shan).

codecov[bot]

unread,
Oct 2, 2021, 3:26:06 PM10/2/21
to vim/vim, Subscribed

Codecov Report

Merging #8939 (f343267) into master (d85931e) will decrease coverage by 87.62%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@

##           master    #8939       +/-   ##

===========================================

- Coverage   90.08%    2.45%   -87.63%     

===========================================

  Files         151      149        -2     

  Lines      168894   165905     -2989     

===========================================

- Hits       152145     4077   -148068     

- Misses      16749   161828   +145079     
Flag Coverage Δ
huge-clang-none ?
huge-gcc-none ?
huge-gcc-testgui ?
huge-gcc-unittests 2.45% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/float.c 0.00% <0.00%> (-99.22%) ⬇️
src/gui_gtk_f.c 0.00% <0.00%> (-97.43%) ⬇️
src/crypt_zip.c 0.00% <0.00%> (-97.06%) ⬇️
src/cmdhist.c 0.00% <0.00%> (-97.00%) ⬇️
src/sha256.c 0.00% <0.00%> (-96.94%) ⬇️
src/evalbuffer.c 0.00% <0.00%> (-96.88%) ⬇️
src/textprop.c 0.00% <0.00%> (-96.84%) ⬇️
src/match.c 0.00% <0.00%> (-96.76%) ⬇️
src/libvterm/src/rect.h 0.00% <0.00%> (-96.56%) ⬇️
src/evalfunc.c 0.00% <0.00%> (-96.51%) ⬇️
... and 137 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d85931e...f343267. Read the comment docs.

Bram Moolenaar

unread,
Oct 3, 2021, 3:02:16 PM10/3/21
to vim/vim, Subscribed

Ken Shan is no longer the maintainer, see https://github.com/vim-jp/vim-cpp

Bram Moolenaar

unread,
Nov 15, 2021, 2:41:25 PM11/15/21
to vim/vim, Subscribed

Did this get picked up by vim-jp?

K.Takata

unread,
Nov 15, 2021, 7:31:32 PM11/15/21
to vim/vim, Subscribed

Not yet.
@dpelle Could you create a PR at vim-jp/vim-cpp?

Dominique Pellé

unread,
Jan 20, 2023, 4:36:41 PM1/20/23
to vim/vim, Subscribed

Closed #8939.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/8939/issue_event/8325351697@github.com>

Dominique Pellé

unread,
Jan 20, 2023, 4:36:42 PM1/20/23
to vim/vim, Subscribed

Long overdue, but I created PR vim-jp/vim-cpp#63

Closing this one now.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/8939/c1398980168@github.com>

Eisuke Kawashima

unread,
Jan 7, 2026, 2:23:43 PMJan 7
to vim/vim, Subscribed
e-kwsm left a comment (vim/vim#8939)

https://github.com/vim-jp/vim-cpp is now archived, so please reopen this PR?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/8939/c3720406358@github.com>

Christian Brabandt

unread,
Jan 7, 2026, 5:01:05 PMJan 7
to vim/vim, Subscribed

Reopened #8939.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/8939/issue_event/21909027893@github.com>

Christian Brabandt

unread,
Jan 7, 2026, 5:04:44 PMJan 7
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#8939)

@dpelle or @e-kwsm can you rebase this change and fix the conflicts?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/8939/c3720993380@github.com>

Eisuke Kawashima

unread,
Jan 8, 2026, 3:57:00 PMJan 8
to vim/vim, Subscribed
e-kwsm left a comment (vim/vim#8939)
diff --git a/runtime/syntax/cpp.vim b/runtime/syntax/cpp.vim
index 2bf5b1ffc468..b5f4f824d8d2 100644
--- a/runtime/syntax/cpp.vim
+++ b/runtime/syntax/cpp.vim
@@ -59,8 +59,8 @@ if !exists("cpp_no_cpp14")
   syn match cppNumber          display contained "\<0\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
   syn match cppNumber          display contained "\<[1-9]\('\=\d\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
   syn match cppNumber          display contained "\<0\('\=\o\+\)\+\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
-  syn match cppNumber          display contained "\<0b[01]\('\=[01]\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
-  syn match cppNumber          display contained "\<0x\x\('\=\x\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
+  syn match cppNumber          display contained "\<0[bB][01]\('\=[01]\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
+  syn match cppNumber          display contained "\<0[xX]\x\('\=\x\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
   syn match cppFloat           display contained "\<\d\('\=\d\+\)*\.\(\d\('\=\d\+\)*\)\=\(e[-+]\=\d\+\)\=\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
   syn match cppFloat           display contained "\.\d\('\=\d\+\)*\(e[-+]\=\d\+\)\=\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
   syn match cppFloat           display contained "\<\d\+e[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
@@ -71,8 +71,8 @@ endif
 if !exists("cpp_no_cpp17")
   syn match cppCast            "\<reinterpret_pointer_cast\s*<"me=e-1
   syn match cppCast            "\<reinterpret_pointer_cast\s*$"
-  syn match cppFloat           display contained "\<0x\x*\.\x\+p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
-  syn match cppFloat           display contained "\<0x\x\+\.\=p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
+  syn match cppFloat           display contained "\<0[Xx]\x*\.\x\+p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
+  syn match cppFloat           display contained "\<0[Xx]\x\+\.\=p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"

   " TODO: push this up to c.vim if/when supported in C23
   syn match cppCharacter       "u8'[^\\]'"
@@ -94,8 +94,8 @@ if !exists("cpp_no_cpp20")
   syn match cppNumber          display contained "\<0\(y\|d\)\>"
   syn match cppNumber          display contained "\<[1-9]\('\=\d\+\)*\(y\|d\)\>"
   syn match cppNumber          display contained "\<0\o\+\(y\|d\)\>"
-  syn match cppNumber          display contained "\<0b[01]\('\=[01]\+\)*\(y\|d\)\>"
-  syn match cppNumber          display contained "\<0x\x\('\=\x\+\)*\(y\|d\)\>"
+  syn match cppNumber          display contained "\<0[Bb][01]\('\=[01]\+\)*\(y\|d\)\>"
+  syn match cppNumber          display contained "\<0[Xx]\x\('\=\x\+\)*\(y\|d\)\>"
   syn keyword cppStatement     co_await co_return co_yield requires
   syn keyword cppStorageClass  consteval constinit
   syn keyword cppStructure     concept


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/8939/c3725762084@github.com>

Christian Brabandt

unread,
Jan 8, 2026, 4:17:10 PMJan 8
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#8939)

That patch seems simple enough to be applied (even so you seem to have missed the capital exponent :) ). Let me include with a syntax test.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/8939/c3725838842@github.com>

Christian Brabandt

unread,
Jan 8, 2026, 4:26:28 PMJan 8
to vim/vim, Subscribed

Closed #8939 via 335aecd.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/8939/issue_event/21933230305@github.com>

Eisuke Kawashima

unread,
Jan 8, 2026, 4:58:27 PMJan 8
to vim/vim, Subscribed
e-kwsm left a comment (vim/vim#8939)

Thanks.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/8939/c3726003850@github.com>

Reply all
Reply to author
Forward
0 new messages