vim-jp / vim-cpp

c or cpp syntax files
147 stars 44 forks source link

Add C++ syntax support for user-defined literals #55

Closed adah1972 closed 3 years ago

adah1972 commented 3 years ago

This PR makes Vim recognize user-defined literals like "hello"sv, 5.0i, 300ms, 0x123456789abcdef_cppi, etc.

There are some repetitions, which seem usual in syntax files. However, if there is a better way of achieve such effects, let me know.

mattn commented 3 years ago

Looks good.

adah1972 commented 3 years ago

I have found another problem with case. I'll push a fix soon.

adah1972 commented 3 years ago

Any more questions? Or more changes that I should make?

@mattn @k-takata

mattn commented 3 years ago

It seems okay to me. @k-takata what do you think this?

mattn commented 3 years ago

syntax for 0b0.1 is right?

image

#include <iostream>
#include <string>
#include <algorithm>

int
main(int argc, char* argv[]) {
  auto i = 1000y;
  auto i = 1000.1y;
  auto i = 1000d;
  auto i = 10.00d;
  auto i = 00d;
  auto i = -00d;
  auto i = -00y;
  auto i = R"(xxxxyyy)";
  auto i = 0b1;
  auto i = 0b01;
  auto i = 0b0.1;
  auto i = 0b02;
  return 0;
}
adah1972 commented 3 years ago

syntax for 0b0.1 is right?

No, it is not. It is actually an interaction problem with c.vim (the fraction part is cFloat, not cppFloat).

I’ve pushed a fix. Also added the support for C++17 hexadecimal float literals.

adah1972 commented 3 years ago

It's been another week. Did you find time to check again?

@mattn @k-takata

mattn commented 3 years ago

Looks ok to me.

k-takata commented 3 years ago

LGTM

adah1972 commented 3 years ago

Is there anything else I should do before merging?

mattn commented 3 years ago

I'll merge this and I'll send patch to vim-dev. Thanks..

mattn commented 3 years ago

https://groups.google.com/g/vim_dev/c/QiILCWOXnuY/m/UnWeCwmEBQAJ

brammool commented 3 years ago

I'll include the changes, thanks.