From a72bc871bd35597afb8855d330289984042cd35a Mon Sep 17 00:00:00 2001 From: Cataldo Date: Fri, 18 Oct 2019 15:13:00 -0300 Subject: [PATCH 01/10] Add BSD extension functions to the C function list --- after/syntax/c.vim | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/after/syntax/c.vim b/after/syntax/c.vim index c147716..a87a275 100644 --- a/after/syntax/c.vim +++ b/after/syntax/c.vim @@ -208,6 +208,41 @@ syn keyword cAnsiFunction UINTMAX_C INTMAX_C UINT64_C syn keyword cAnsiFunction UINT32_C UINT16_C UINT8_C syn keyword cAnsiFunction INT64_C INT32_C INT16_C INT8_C +" Common BSD extensions +syn keyword cBSDFunction err errx warn warnx verr verrx vwarn vwarnx +syn keyword cBSDFunction errc verrc warnc vwarnc +syn keyword cBSDFunction strtonum strtoi strtou +syn keyword cBSDFunction dehumanize_number expand_number +syn keyword cBSDFunction strlcat strlcpy strnstr wcslcat wcslcpy +syn keyword cBSDFunction vis nvis strvis stravis strnvis strvisx +syn keyword cBSDFunction strnvisx strenvisx svis snvis strsvis +syn keyword cBSDFunction strsnvis strsvisx strsnvisx strsenvisx +syn keyword cBSDFunction unvis strunvis strnunvis strunvisx strnunvisx +syn keyword cBSDFunction arc4random arc4random_buf arc4random_uniform +syn keyword cBSDFunction arc4random_stir arc4random_addrrandom +syn keyword cBSDFunction be16dec be32dec be64dec le16dec le32dec le64dec +syn keyword cBSDFunction be16enc be32enc be64enc le16enc le32enc le64enc +syn keyword cBSDFunction bit_alloc bit_decl bit_clear bit_ffc bit_ffs +syn keyword cBSDFunction bit_nclear bit_nset bit_set bitstr_size +syn keyword cBSDFunction bit_test +syn keyword cBSDFunction sl_init sl_add sl_free sl_find sl_delete +syn keyword cBSDFunction closefrom bzero explicit_bzero +syn keyword cBSDFunction fgetln fgetwln flopen fmtcheck fparseln fpurge +syn keyword cBSDFunction funopen strmode +syn keyword cBSDFunction getbsize getmode setmode getpeereid +syn keyword cBSDFunction pidfile_open pidfile_write pidfile_close +syn keyword cBSDFunction pidfile_remove pidfile_fileno +syn keyword cBSDFunction getprogname setprogname nlist +syn keyword cBSDFunction setproctitle_init setproctitle +syn keyword cBSDFunction heapsort mergesort radixsort sradixsort +syn keyword cBSDFunction MD5Init MD5Update MD5Pad MD5Final MD5Transform +syn keyword cBSDFunction MD5End MD5File MD5FileChunk MD5Data +syn keyword cBSDFunction readpassphrase +syn keyword cBSDFunction reallocarray reallocf +syn keyword cBSDFunction timeradd timersub timerclear timerisset timercmp +syn keyword cBSDFunction timespecadd timespecsub timespecclear +syn keyword cBSDFunction timespecisset timespeccmp + " Common ANSI-standard Names syn keyword cAnsiName PRId8 PRIi16 PRIo32 PRIu64 syn keyword cAnsiName PRId16 PRIi32 PRIo64 PRIuLEAST8 @@ -261,6 +296,7 @@ syn keyword cAnsiName and_eq compl or xor_eq syn keyword cAnsiName bitand not or_eq hi def link cAnsiFunction cFunction +hi def link cBSDFunction cFunction hi def link cAnsiName cIdentifier hi def link cFunction Function hi def link cIdentifier Identifier From 9463edebb414d1a97f8b3637a2b76409290b8673 Mon Sep 17 00:00:00 2001 From: Cataldo Date: Fri, 18 Oct 2019 16:51:26 -0300 Subject: [PATCH 02/10] Create user-controllable variable for BSD extensions When the option cpp_posix_standard is enable, BSD extension functions are highlighted --- README.md | 5 ++++ after/syntax/c.vim | 72 ++++++++++++++++++++++++---------------------- 2 files changed, 43 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index c808f51..27878c1 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,11 @@ Highlighting of class names in declarations is disabled by default. To enable se let g:cpp_class_decl_highlight = 1 ``` +Highlighting of BSD extension functions is disabled by default. To enable set +```vim +let g:cpp_bsd_standard = 1 +``` + There are two ways to highlight template functions. Either ```vim let g:cpp_experimental_simple_template_highlight = 1 diff --git a/after/syntax/c.vim b/after/syntax/c.vim index a87a275..e795643 100644 --- a/after/syntax/c.vim +++ b/after/syntax/c.vim @@ -34,6 +34,44 @@ if exists('g:cpp_member_variable_highlight') && g:cpp_member_variable_highlight hi def link cCustomMemVar Function endif +" ----------------------------------------------------------------------------- +" Highlight BSD extensions. +" ----------------------------------------------------------------------------- +if exists('g:cpp_bsd_standard') && g:cpp_bsd_standard + syn keyword cBSDFunction err errx warn warnx verr verrx vwarn vwarnx + syn keyword cBSDFunction errc verrc warnc vwarnc + syn keyword cBSDFunction strtonum strtoi strtou + syn keyword cBSDFunction dehumanize_number expand_number + syn keyword cBSDFunction strlcat strlcpy strnstr wcslcat wcslcpy + syn keyword cBSDFunction vis nvis strvis stravis strnvis strvisx + syn keyword cBSDFunction strnvisx strenvisx svis snvis strsvis + syn keyword cBSDFunction strsnvis strsvisx strsnvisx strsenvisx + syn keyword cBSDFunction unvis strunvis strnunvis strunvisx strnunvisx + syn keyword cBSDFunction arc4random arc4random_buf arc4random_uniform + syn keyword cBSDFunction arc4random_stir arc4random_addrrandom + syn keyword cBSDFunction be16dec be32dec be64dec le16dec le32dec le64dec + syn keyword cBSDFunction be16enc be32enc be64enc le16enc le32enc le64enc + syn keyword cBSDFunction bit_alloc bit_decl bit_clear bit_ffc bit_ffs + syn keyword cBSDFunction bit_nclear bit_nset bit_set bitstr_size + syn keyword cBSDFunction bit_test + syn keyword cBSDFunction sl_init sl_add sl_free sl_find sl_delete + syn keyword cBSDFunction closefrom bzero explicit_bzero + syn keyword cBSDFunction fgetln fgetwln flopen fmtcheck fparseln fpurge + syn keyword cBSDFunction funopen strmode + syn keyword cBSDFunction getbsize getmode setmode getpeereid + syn keyword cBSDFunction pidfile_open pidfile_write pidfile_close + syn keyword cBSDFunction pidfile_remove pidfile_fileno + syn keyword cBSDFunction getprogname setprogname nlist + syn keyword cBSDFunction setproctitle_init setproctitle + syn keyword cBSDFunction heapsort mergesort radixsort sradixsort + syn keyword cBSDFunction MD5Init MD5Update MD5Pad MD5Final MD5Transform + syn keyword cBSDFunction MD5End MD5File MD5FileChunk MD5Data + syn keyword cBSDFunction readpassphrase + syn keyword cBSDFunction reallocarray reallocf + syn keyword cBSDFunction timeradd timersub timerclear timerisset timercmp + syn keyword cBSDFunction timespecadd timespecsub timespecclear + syn keyword cBSDFunction timespecisset timespeccmp +endif " ----------------------------------------------------------------------------- " Source: aftersyntaxc.vim " ----------------------------------------------------------------------------- @@ -208,40 +246,6 @@ syn keyword cAnsiFunction UINTMAX_C INTMAX_C UINT64_C syn keyword cAnsiFunction UINT32_C UINT16_C UINT8_C syn keyword cAnsiFunction INT64_C INT32_C INT16_C INT8_C -" Common BSD extensions -syn keyword cBSDFunction err errx warn warnx verr verrx vwarn vwarnx -syn keyword cBSDFunction errc verrc warnc vwarnc -syn keyword cBSDFunction strtonum strtoi strtou -syn keyword cBSDFunction dehumanize_number expand_number -syn keyword cBSDFunction strlcat strlcpy strnstr wcslcat wcslcpy -syn keyword cBSDFunction vis nvis strvis stravis strnvis strvisx -syn keyword cBSDFunction strnvisx strenvisx svis snvis strsvis -syn keyword cBSDFunction strsnvis strsvisx strsnvisx strsenvisx -syn keyword cBSDFunction unvis strunvis strnunvis strunvisx strnunvisx -syn keyword cBSDFunction arc4random arc4random_buf arc4random_uniform -syn keyword cBSDFunction arc4random_stir arc4random_addrrandom -syn keyword cBSDFunction be16dec be32dec be64dec le16dec le32dec le64dec -syn keyword cBSDFunction be16enc be32enc be64enc le16enc le32enc le64enc -syn keyword cBSDFunction bit_alloc bit_decl bit_clear bit_ffc bit_ffs -syn keyword cBSDFunction bit_nclear bit_nset bit_set bitstr_size -syn keyword cBSDFunction bit_test -syn keyword cBSDFunction sl_init sl_add sl_free sl_find sl_delete -syn keyword cBSDFunction closefrom bzero explicit_bzero -syn keyword cBSDFunction fgetln fgetwln flopen fmtcheck fparseln fpurge -syn keyword cBSDFunction funopen strmode -syn keyword cBSDFunction getbsize getmode setmode getpeereid -syn keyword cBSDFunction pidfile_open pidfile_write pidfile_close -syn keyword cBSDFunction pidfile_remove pidfile_fileno -syn keyword cBSDFunction getprogname setprogname nlist -syn keyword cBSDFunction setproctitle_init setproctitle -syn keyword cBSDFunction heapsort mergesort radixsort sradixsort -syn keyword cBSDFunction MD5Init MD5Update MD5Pad MD5Final MD5Transform -syn keyword cBSDFunction MD5End MD5File MD5FileChunk MD5Data -syn keyword cBSDFunction readpassphrase -syn keyword cBSDFunction reallocarray reallocf -syn keyword cBSDFunction timeradd timersub timerclear timerisset timercmp -syn keyword cBSDFunction timespecadd timespecsub timespecclear -syn keyword cBSDFunction timespecisset timespeccmp " Common ANSI-standard Names syn keyword cAnsiName PRId8 PRIi16 PRIo32 PRIu64 From 708767b639b7304658dcadafe8a9f32b70e703d4 Mon Sep 17 00:00:00 2001 From: Josh Seba Date: Thu, 7 Nov 2019 07:59:01 -0800 Subject: [PATCH 03/10] Update C++ concept keywords As of P1754, all concepts will become snake_case, consistent with the rest of the standard library. This change adds support for the new names by using the value of g:cpp_concepts_highlight to select the concept naming convention. This new section includes all concepts currently defined in the working draft and their names from P1754. --- after/syntax/cpp.vim | 218 +++++++++++++++++++++++++++++-------------- 1 file changed, 147 insertions(+), 71 deletions(-) diff --git a/after/syntax/cpp.vim b/after/syntax/cpp.vim index 0db95c4..3539772 100644 --- a/after/syntax/cpp.vim +++ b/after/syntax/cpp.vim @@ -1991,79 +1991,154 @@ if !exists("cpp_no_cpp20") endif -if exists('g:cpp_concepts_highlight') && g:cpp_concepts_highlight +if exists('g:cpp_concepts_highlight') syntax keyword cppStatement concept syntax keyword cppStorageClass requires - syntax keyword cppSTLtype DefaultConstructible - syntax keyword cppSTLtype MoveConstructible - syntax keyword cppSTLtype CopyConstructible - syntax keyword cppSTLtype MoveAssignable - syntax keyword cppSTLtype CopyAssignable - syntax keyword cppSTLtype Destructible - syntax keyword cppSTLtype TriviallyCopyable - syntax keyword cppSTLtype TrivialType - syntax keyword cppSTLtype StandardLayoutType - syntax keyword cppSTLtype PODType - syntax keyword cppSTLtype EqualityComparable - syntax keyword cppSTLtype LessThanComparable - syntax keyword cppSTLtype Swappable - syntax keyword cppSTLtype ValueSwappable - syntax keyword cppSTLtype NullablePointer - syntax keyword cppSTLtype Hash - syntax keyword cppSTLtype Allocator - syntax keyword cppSTLtype FunctionObject - syntax keyword cppSTLtype Callable - syntax keyword cppSTLtype Predicate - syntax keyword cppSTLtype BinaryPredicate - syntax keyword cppSTLtype Compare - syntax keyword cppSTLtype Container - syntax keyword cppSTLtype ReversibleContainer - syntax keyword cppSTLtype AllocatorAwareContainer - syntax keyword cppSTLtype SequenceContainer - syntax keyword cppSTLtype ContiguousContainer - syntax keyword cppSTLtype AssociativeContainer - syntax keyword cppSTLtype UnorderedAssociativeContainer - syntax keyword cppSTLtype DefaultInsertable - syntax keyword cppSTLtype CopyInsertable - syntax keyword cppSTLtype CopyInsertable - syntax keyword cppSTLtype MoveInsertable - syntax keyword cppSTLtype EmplaceConstructible - syntax keyword cppSTLtype Erasable - syntax keyword cppSTLtype Iterator - syntax keyword cppSTLtype InputIterator - syntax keyword cppSTLtype OutputIterator - syntax keyword cppSTLtype ForwardIterator - syntax keyword cppSTLtype BidirectionalIterator - syntax keyword cppSTLtype RandomAccessIterator - syntax keyword cppSTLtype ContiguousIterator - syntax keyword cppSTLtype UnformattedInputFunction - syntax keyword cppSTLtype FormattedInputFunction - syntax keyword cppSTLtype UnformattedOutputFunction - syntax keyword cppSTLtype FormattedOutputFunction - syntax keyword cppSTLtype SeedSequence - syntax keyword cppSTLtype UniformRandomBitGenerator - syntax keyword cppSTLtype RandomNumberEngine - syntax keyword cppSTLtype RandomNumberEngineAdaptor - syntax keyword cppSTLtype RandomNumberDistribution - syntax keyword cppSTLtype BasicLockable - syntax keyword cppSTLtype Lockable - syntax keyword cppSTLtype TimedLockable - syntax keyword cppSTLtype Mutex - syntax keyword cppSTLtype TimedMutex - syntax keyword cppSTLtype SharedMutex - syntax keyword cppSTLtype SharedTimedMutex - syntax keyword cppSTLtype UnaryTypeTrait - syntax keyword cppSTLtype BinaryTypeTrait - syntax keyword cppSTLtype TransformationTrait - syntax keyword cppSTLtype Clock - syntax keyword cppSTLtype TrivialClock - syntax keyword cppSTLtype CharTraits - syntax keyword cppSTLtype pos_type - syntax keyword cppSTLtype off_type - syntax keyword cppSTLtype BitmaskType - syntax keyword cppSTLtype NumericType - syntax keyword cppSTLtype RegexTraits - syntax keyword cppSTLtype LiteralType + + if g:cpp_concepts_highlight == 1 + syntax keyword cppSTLconcept DefaultConstructible + syntax keyword cppSTLconcept MoveConstructible + syntax keyword cppSTLconcept CopyConstructible + syntax keyword cppSTLconcept MoveAssignable + syntax keyword cppSTLconcept CopyAssignable + syntax keyword cppSTLconcept Destructible + syntax keyword cppSTLconcept TriviallyCopyable + syntax keyword cppSTLconcept TrivialType + syntax keyword cppSTLconcept StandardLayoutType + syntax keyword cppSTLconcept PODType + syntax keyword cppSTLconcept EqualityComparable + syntax keyword cppSTLconcept LessThanComparable + syntax keyword cppSTLconcept Swappable + syntax keyword cppSTLconcept ValueSwappable + syntax keyword cppSTLconcept NullablePointer + syntax keyword cppSTLconcept Hash + syntax keyword cppSTLconcept Allocator + syntax keyword cppSTLconcept FunctionObject + syntax keyword cppSTLconcept Callable + syntax keyword cppSTLconcept Predicate + syntax keyword cppSTLconcept BinaryPredicate + syntax keyword cppSTLconcept Compare + syntax keyword cppSTLconcept Container + syntax keyword cppSTLconcept ReversibleContainer + syntax keyword cppSTLconcept AllocatorAwareContainer + syntax keyword cppSTLconcept SequenceContainer + syntax keyword cppSTLconcept ContiguousContainer + syntax keyword cppSTLconcept AssociativeContainer + syntax keyword cppSTLconcept UnorderedAssociativeContainer + syntax keyword cppSTLconcept DefaultInsertable + syntax keyword cppSTLconcept CopyInsertable + syntax keyword cppSTLconcept CopyInsertable + syntax keyword cppSTLconcept MoveInsertable + syntax keyword cppSTLconcept EmplaceConstructible + syntax keyword cppSTLconcept Erasable + syntax keyword cppSTLconcept Iterator + syntax keyword cppSTLconcept InputIterator + syntax keyword cppSTLconcept OutputIterator + syntax keyword cppSTLconcept ForwardIterator + syntax keyword cppSTLconcept BidirectionalIterator + syntax keyword cppSTLconcept RandomAccessIterator + syntax keyword cppSTLconcept ContiguousIterator + syntax keyword cppSTLconcept UnformattedInputFunction + syntax keyword cppSTLconcept FormattedInputFunction + syntax keyword cppSTLconcept UnformattedOutputFunction + syntax keyword cppSTLconcept FormattedOutputFunction + syntax keyword cppSTLconcept SeedSequence + syntax keyword cppSTLconcept UniformRandomBitGenerator + syntax keyword cppSTLconcept RandomNumberEngine + syntax keyword cppSTLconcept RandomNumberEngineAdaptor + syntax keyword cppSTLconcept RandomNumberDistribution + syntax keyword cppSTLconcept BasicLockable + syntax keyword cppSTLconcept Lockable + syntax keyword cppSTLconcept TimedLockable + syntax keyword cppSTLconcept Mutex + syntax keyword cppSTLconcept TimedMutex + syntax keyword cppSTLconcept SharedMutex + syntax keyword cppSTLconcept SharedTimedMutex + syntax keyword cppSTLconcept UnaryTypeTrait + syntax keyword cppSTLconcept BinaryTypeTrait + syntax keyword cppSTLconcept TransformationTrait + syntax keyword cppSTLconcept Clock + syntax keyword cppSTLconcept TrivialClock + syntax keyword cppSTLconcept CharTraits + syntax keyword cppSTLconcept pos_type + syntax keyword cppSTLconcept off_type + syntax keyword cppSTLconcept BitmaskType + syntax keyword cppSTLconcept NumericType + syntax keyword cppSTLconcept RegexTraits + syntax keyword cppSTLconcept LiteralType + elseif g:cpp_concepts_highlight == 2 + syntax keyword cppSTLconcept same_as + syntax keyword cppSTLconcept derived_from + syntax keyword cppSTLconcept convertible_to + syntax keyword cppSTLconcept common_reference_with + syntax keyword cppSTLconcept common_with + syntax keyword cppSTLconcept integral + syntax keyword cppSTLconcept signed_integral + syntax keyword cppSTLconcept unsigned_integral + syntax keyword cppSTLconcept assignable_from + syntax keyword cppSTLconcept swappable + syntax keyword cppSTLconcept swappable_with + syntax keyword cppSTLconcept destructible + syntax keyword cppSTLconcept constructible_from + syntax keyword cppSTLconcept default_constructible + syntax keyword cppSTLconcept move_constructible + syntax keyword cppSTLconcept copy_constructible + syntax keyword cppSTLconcept boolean + syntax keyword cppSTLconcept equality_comparable + syntax keyword cppSTLconcept equality_comparable_with + syntax keyword cppSTLconcept totally_ordered + syntax keyword cppSTLconcept totally_ordered_with + syntax keyword cppSTLconcept movable + syntax keyword cppSTLconcept copyable + syntax keyword cppSTLconcept semiregular + syntax keyword cppSTLconcept regular + syntax keyword cppSTLconcept invocable + syntax keyword cppSTLconcept regular_invocable + syntax keyword cppSTLconcept predicate + syntax keyword cppSTLconcept relation + syntax keyword cppSTLconcept strict_weak_order + syntax keyword cppSTLconcept readable + syntax keyword cppSTLconcept writable + syntax keyword cppSTLconcept weakly_incrementable + syntax keyword cppSTLconcept incrementable + syntax keyword cppSTLconcept input_or_output_iterator + syntax keyword cppSTLconcept sentinal_for + syntax keyword cppSTLconcept sized_sentinal_for + syntax keyword cppSTLconcept input_iterator + syntax keyword cppSTLconcept output_iterator + syntax keyword cppSTLconcept forward_iterator + syntax keyword cppSTLconcept bidirectional_iterator + syntax keyword cppSTLconcept random_access_iterator + syntax keyword cppSTLconcept input_iterator + syntax keyword cppSTLconcept output_iterator + syntax keyword cppSTLconcept bidirectional_iterator + syntax keyword cppSTLconcept random_access_iterator + syntax keyword cppSTLconcept contiguous_iterator + syntax keyword cppSTLconcept indirectly_unary_invocable + syntax keyword cppSTLconcept indirectly_regular_unary_invocable + syntax keyword cppSTLconcept indirect_unary_predicate + syntax keyword cppSTLconcept indirect_relation + syntax keyword cppSTLconcept indirect_strict_weak_order + syntax keyword cppSTLconcept indirectly_movable + syntax keyword cppSTLconcept indirectly_movable_storable + syntax keyword cppSTLconcept indirectly_copyable + syntax keyword cppSTLconcept indirectly_copyable_storable + syntax keyword cppSTLconcept indirectly_swappable + syntax keyword cppSTLconcept indirectly_comparable + syntax keyword cppSTLconcept permutable + syntax keyword cppSTLconcept mergeable + syntax keyword cppSTLconcept sortable + syntax keyword cppSTLconcept range + syntax keyword cppSTLconcept sized_range + syntax keyword cppSTLconcept output_range + syntax keyword cppSTLconcept input_range + syntax keyword cppSTLconcept bidirectional_range + syntax keyword cppSTLconcept random_access_range + syntax keyword cppSTLconcept contiguous_range + syntax keyword cppSTLconcept common_range + syntax keyword cppSTLconcept viewable_range + syntax keyword cppSTLconcept uniform_random_bit_generator + endif endif " C++ concepts @@ -2093,6 +2168,7 @@ if version >= 508 || !exists("did_cpp_syntax_inits") HiLink cppSTLiterator Typedef HiLink cppSTLiterator_tag Typedef HiLink cppSTLenum Typedef + HiLink cppSTLconcept Typedef HiLink cppSTLios Function HiLink cppSTLcast Statement " be consistent with official syntax HiLink cppRawString String From 4bc7d8cb368ca7adbd85589f1ea6236713e98aa0 Mon Sep 17 00:00:00 2001 From: Josh Seba Date: Thu, 7 Nov 2019 07:56:48 -0800 Subject: [PATCH 04/10] Add more C++20 types and functions Also corrects iterators to remove types that don't exist in the standard. --- after/syntax/cpp.vim | 130 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 123 insertions(+), 7 deletions(-) diff --git a/after/syntax/cpp.vim b/after/syntax/cpp.vim index 3539772..34e337a 100644 --- a/after/syntax/cpp.vim +++ b/after/syntax/cpp.vim @@ -631,21 +631,19 @@ syntax keyword cppSTLios unitbuf syntax keyword cppSTLios uppercase "syntax keyword cppSTLios ws syntax keyword cppSTLiterator back_insert_iterator -syntax keyword cppSTLiterator bidirectional_iterator syntax keyword cppSTLiterator const_iterator syntax keyword cppSTLiterator const_reverse_iterator -syntax keyword cppSTLiterator forward_iterator syntax keyword cppSTLiterator front_insert_iterator -syntax keyword cppSTLiterator input_iterator syntax keyword cppSTLiterator insert_iterator syntax keyword cppSTLiterator istreambuf_iterator syntax keyword cppSTLiterator istream_iterator +syntax keyword cppSTLiterator ostreambuf_iterator +syntax keyword cppSTLiterator ostream_iterator syntax keyword cppSTLiterator iterator syntax keyword cppSTLiterator ostream_iterator syntax keyword cppSTLiterator output_iterator -syntax keyword cppSTLiterator random_access_iterator syntax keyword cppSTLiterator raw_storage_iterator -syntax keyword cppSTLiterator reverse_bidirectional_iterator +syntax keyword cppSTLiterator move_iterator syntax keyword cppSTLiterator reverse_iterator syntax keyword cppSTLiterator_tag bidirectional_iterator_tag syntax keyword cppSTLiterator_tag forward_iterator_tag @@ -1591,6 +1589,8 @@ endif " C++14 if !exists("cpp_no_cpp17") + syntax keyword cppSTLnamespace pmr + " algorithm syntax keyword cppSTLfunction clamp syntax keyword cppSTLfunction for_each_n @@ -1983,11 +1983,127 @@ endif " C++17 if !exists("cpp_no_cpp20") - " type_traits - syntax keyword cppSTLtype remove_cvref remove_cvref_t syntax keyword cppType char8_t syntax keyword cppStatement co_yield co_return co_await syntax keyword cppStorageClass consteval + syntax keyword cppSTLnamespace ranges + + " algorithm + syntax keyword cppSTLfunction shift_left + syntax keyword cppSTLfunction shift_right + syntax keyword cppSTLfunction lexicographical_compare_three_way + + " bit + syntax keyword cppSTLcast bit_cast + syntax keyword cppSTLfunction ispow2 + syntax keyword cppSTLfunction ceil2 + syntax keyword cppSTLfunction floor2 + syntax keyword cppSTLfunction log2p1 + syntax keyword cppSTLfunction rotl + syntax keyword cppSTLfunction rotr + syntax keyword cppSTLfunction countl_zero + syntax keyword cppSTLfunction countl_one + syntax keyword cppSTLfunction countr_zero + syntax keyword cppSTLfunction countr_one + syntax keyword cppSTLfunction popcount + syntax keyword cppSTLtype endian + + " compare + syntax keyword cppSTLtype weak_equality + syntax keyword cppSTLtype strong_equality + syntax keyword cppSTLtype partial_ordering + syntax keyword cppSTLtype weak_ordering + syntax keyword cppSTLtype strong_ordering + syntax keyword cppSTLtype common_comparison_category + syntax keyword cppSTLtype compare_three_way_result + syntax keyword cppSTLtype compare_three_way + syntax keyword cppSTLtype strong_order + syntax keyword cppSTLtype weak_order + syntax keyword cppSTLtype parital_order + syntax keyword cppSTLtype compare_strong_order_fallback + syntax keyword cppSTLtype compare_weak_order_fallback + syntax keyword cppSTLtype compare_parital_order_fallback + syntax keyword cppSTLfunction is_eq + syntax keyword cppSTLfunction is_neq + syntax keyword cppSTLfunction is_lt + syntax keyword cppSTLfunction is_lteq + syntax keyword cppSTLfunction is_gt + syntax keyword cppSTLfunction is_gteq + + " format + syntax keyword cppSTLtype formatter + syntax keyword cppSTLtype basic_format_parse_context + syntax keyword cppSTLtype format_parse_context + syntax keyword cppSTLtype wformat_parse_context + syntax keyword cppSTLtype basic_format_context + syntax keyword cppSTLtype format_context + syntax keyword cppSTLtype wformat_context + syntax keyword cppSTLtype basic_format_arg + syntax keyword cppSTLtype basic_format_args + syntax keyword cppSTLtype format_args + syntax keyword cppSTLtype wformat_args + syntax keyword cppSTLtype format_args_t + syntax keyword cppSTLtype format_error + syntax keyword cppSTLfuntion format + syntax keyword cppSTLfuntion format_to + syntax keyword cppSTLfuntion format_to_n + syntax keyword cppSTLfuntion formatted_size + syntax keyword cppSTLfuntion vformat + syntax keyword cppSTLfuntion vformat_to + syntax keyword cppSTLfuntion visit_format_arg + syntax keyword cppSTLfuntion make_format_args + syntax keyword cppSTLfuntion make_wformat_args + + " iterator + syntax keyword cppSTLtype default_sentinel_t unreachable_sentinel_t + syntax keyword cppSTLiterator common_iterator + syntax keyword cppSTLiterator counted_iterator + syntax keyword cppSTLiterator_tag contiguous_iterator_tag + + " memory + syntax keyword cppSTLfunction to_address + syntax keyword cppSTLfunction assume_aligned + syntax keyword cppSTLfunction make_unique_default_init + syntax keyword cppSTLfunction allocate_shared_default_init + + " source_location + syntax keyword cppSTLtype source_location + + " span + syntax keyword cppSTLtype span + syntax keyword cppSTLfunction as_bytes + syntax keyword cppSTLfunction as_writable_bytes + syntax keyword cppSTLconstant dynamic_extent + + " syncstream + syntax keyword cppSTLtype basic_syncbuf + syntax keyword cppSTLtype basic_osyncstream + syntax keyword cppSTLtype syncbuf + syntax keyword cppSTLtype wsyncbuf + syntax keyword cppSTLtype osyncstream + syntax keyword cppSTLtype wosyncstream + + " type_traits + syntax keyword cppSTLtype remove_cvref remove_cvref_t + syntax keyword cppSTLtype common_reference common_reference_t + syntax keyword cppSTLfunction is_constant_evaluated + syntax keyword cppSTLfunction is_pointer_interconvertible + syntax keyword cppSTLfunction is_corresponding_member + syntax keyword cppSTLtype is_nothrow_convertible + syntax keyword cppSTLbool is_nothrow_convertible_v + syntax keyword cppSTLtype is_layout_compatible + syntax keyword cppSTLbool is_layout_compatible_v + syntax keyword cppSTLtype is_bounded_array + syntax keyword cppSTLbool is_bounded_array_v + syntax keyword cppSTLtype is_unbounded_array + syntax keyword cppSTLbool is_unbounded_array_v + syntax keyword cppSTLtype is_pointer_interconvertible_base_of + syntax keyword cppSTLbool is_pointer_interconvertible_base_of_v + syntax keyword cppSTLtype has_strong_structural_equality + syntax keyword cppSTLbool has_strong_structural_equality_v + + " version + " TODO endif From 3dd038b73f4dcbd0369c72917868276ddc2b2632 Mon Sep 17 00:00:00 2001 From: Cataldo Date: Fri, 18 Oct 2019 13:14:41 -0300 Subject: [PATCH 05/10] Add missing socket related functions --- after/syntax/c.vim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/after/syntax/c.vim b/after/syntax/c.vim index c147716..7da4f0f 100644 --- a/after/syntax/c.vim +++ b/after/syntax/c.vim @@ -204,6 +204,12 @@ syn keyword cAnsiFunction ccosf ccos catanl syn keyword cAnsiFunction catanf catan casinl syn keyword cAnsiFunction casinf casin cacosl syn keyword cAnsiFunction cacosf cacos assert +syn keyword cAnsiFunction socket accept bind connect getsockname +syn keyword cAnsiFunction listen recv recvfrom recvmsg +syn keyword cAnsiFunction send sendmsg setsockopt socketpair +syn keyword cAnsiFunction htonl htons ntohl ntohs +syn keyword cAnsiFunction inet_ntop inet_pton getaddrinfo +syn keyword cAnsiFunction poll select pselect syn keyword cAnsiFunction UINTMAX_C INTMAX_C UINT64_C syn keyword cAnsiFunction UINT32_C UINT16_C UINT8_C syn keyword cAnsiFunction INT64_C INT32_C INT16_C INT8_C From 991f296400262f5af255f421d0650472493ab178 Mon Sep 17 00:00:00 2001 From: Cataldo Date: Fri, 18 Oct 2019 13:53:08 -0300 Subject: [PATCH 06/10] Add missing sendto function --- after/syntax/c.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/after/syntax/c.vim b/after/syntax/c.vim index 7da4f0f..d9f1c92 100644 --- a/after/syntax/c.vim +++ b/after/syntax/c.vim @@ -206,7 +206,7 @@ syn keyword cAnsiFunction casinf casin cacosl syn keyword cAnsiFunction cacosf cacos assert syn keyword cAnsiFunction socket accept bind connect getsockname syn keyword cAnsiFunction listen recv recvfrom recvmsg -syn keyword cAnsiFunction send sendmsg setsockopt socketpair +syn keyword cAnsiFunction send sendto sendmsg setsockopt socketpair syn keyword cAnsiFunction htonl htons ntohl ntohs syn keyword cAnsiFunction inet_ntop inet_pton getaddrinfo syn keyword cAnsiFunction poll select pselect From ae7a8517fd913001a7ea8999ad83262bd1c33774 Mon Sep 17 00:00:00 2001 From: Cataldo Date: Fri, 18 Oct 2019 16:31:33 -0300 Subject: [PATCH 07/10] Create user-controllable variable for POSIX functions When the option cpp_posix_standard is enabled, POSIX functions are highlighted --- after/syntax/c.vim | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/after/syntax/c.vim b/after/syntax/c.vim index d9f1c92..57fe10e 100644 --- a/after/syntax/c.vim +++ b/after/syntax/c.vim @@ -34,6 +34,19 @@ if exists('g:cpp_member_variable_highlight') && g:cpp_member_variable_highlight hi def link cCustomMemVar Function endif +" ----------------------------------------------------------------------------- +" Highlight POSIX functions. +" ----------------------------------------------------------------------------- +if exists('g:cpp_posix_standard') && g:cpp_posix_standard + syn keyword cPOSIXFunction socket accept bind connect getsockname + syn keyword cPOSIXFunction listen recv recvfrom recvmsg + syn keyword cPOSIXFunction send sendto sendmsg setsockopt socketpair + syn keyword cPOSIXFunction htonl htons ntohl ntohs + syn keyword cPOSIXFunction inet_ntop inet_pton getaddrinfo + syn keyword cPOSIXFunction poll select pselect + hi def link cPOSIXFunction Function +endif + " ----------------------------------------------------------------------------- " Source: aftersyntaxc.vim " ----------------------------------------------------------------------------- @@ -204,12 +217,6 @@ syn keyword cAnsiFunction ccosf ccos catanl syn keyword cAnsiFunction catanf catan casinl syn keyword cAnsiFunction casinf casin cacosl syn keyword cAnsiFunction cacosf cacos assert -syn keyword cAnsiFunction socket accept bind connect getsockname -syn keyword cAnsiFunction listen recv recvfrom recvmsg -syn keyword cAnsiFunction send sendto sendmsg setsockopt socketpair -syn keyword cAnsiFunction htonl htons ntohl ntohs -syn keyword cAnsiFunction inet_ntop inet_pton getaddrinfo -syn keyword cAnsiFunction poll select pselect syn keyword cAnsiFunction UINTMAX_C INTMAX_C UINT64_C syn keyword cAnsiFunction UINT32_C UINT16_C UINT8_C syn keyword cAnsiFunction INT64_C INT32_C INT16_C INT8_C From 27e0ffc215b81fa5aa87eca396acd4421d36c060 Mon Sep 17 00:00:00 2001 From: Cataldo Date: Fri, 18 Oct 2019 16:44:47 -0300 Subject: [PATCH 08/10] Include cpp_posix_standard to README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index c808f51..6b500b1 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,11 @@ Highlighting of class names in declarations is disabled by default. To enable se let g:cpp_class_decl_highlight = 1 ``` +Highlighting of POSIX functions is disabled by default. To enable set +```vim +let g:cpp_posix_standard = 1 +``` + There are two ways to highlight template functions. Either ```vim let g:cpp_experimental_simple_template_highlight = 1 From 59e90786636bc430803fa3b8e21509107abe2654 Mon Sep 17 00:00:00 2001 From: Cataldo Date: Fri, 18 Oct 2019 15:13:00 -0300 Subject: [PATCH 09/10] Add BSD extension functions to the C function list --- after/syntax/c.vim | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/after/syntax/c.vim b/after/syntax/c.vim index 57fe10e..78f683c 100644 --- a/after/syntax/c.vim +++ b/after/syntax/c.vim @@ -221,6 +221,41 @@ syn keyword cAnsiFunction UINTMAX_C INTMAX_C UINT64_C syn keyword cAnsiFunction UINT32_C UINT16_C UINT8_C syn keyword cAnsiFunction INT64_C INT32_C INT16_C INT8_C +" Common BSD extensions +syn keyword cBSDFunction err errx warn warnx verr verrx vwarn vwarnx +syn keyword cBSDFunction errc verrc warnc vwarnc +syn keyword cBSDFunction strtonum strtoi strtou +syn keyword cBSDFunction dehumanize_number expand_number +syn keyword cBSDFunction strlcat strlcpy strnstr wcslcat wcslcpy +syn keyword cBSDFunction vis nvis strvis stravis strnvis strvisx +syn keyword cBSDFunction strnvisx strenvisx svis snvis strsvis +syn keyword cBSDFunction strsnvis strsvisx strsnvisx strsenvisx +syn keyword cBSDFunction unvis strunvis strnunvis strunvisx strnunvisx +syn keyword cBSDFunction arc4random arc4random_buf arc4random_uniform +syn keyword cBSDFunction arc4random_stir arc4random_addrrandom +syn keyword cBSDFunction be16dec be32dec be64dec le16dec le32dec le64dec +syn keyword cBSDFunction be16enc be32enc be64enc le16enc le32enc le64enc +syn keyword cBSDFunction bit_alloc bit_decl bit_clear bit_ffc bit_ffs +syn keyword cBSDFunction bit_nclear bit_nset bit_set bitstr_size +syn keyword cBSDFunction bit_test +syn keyword cBSDFunction sl_init sl_add sl_free sl_find sl_delete +syn keyword cBSDFunction closefrom bzero explicit_bzero +syn keyword cBSDFunction fgetln fgetwln flopen fmtcheck fparseln fpurge +syn keyword cBSDFunction funopen strmode +syn keyword cBSDFunction getbsize getmode setmode getpeereid +syn keyword cBSDFunction pidfile_open pidfile_write pidfile_close +syn keyword cBSDFunction pidfile_remove pidfile_fileno +syn keyword cBSDFunction getprogname setprogname nlist +syn keyword cBSDFunction setproctitle_init setproctitle +syn keyword cBSDFunction heapsort mergesort radixsort sradixsort +syn keyword cBSDFunction MD5Init MD5Update MD5Pad MD5Final MD5Transform +syn keyword cBSDFunction MD5End MD5File MD5FileChunk MD5Data +syn keyword cBSDFunction readpassphrase +syn keyword cBSDFunction reallocarray reallocf +syn keyword cBSDFunction timeradd timersub timerclear timerisset timercmp +syn keyword cBSDFunction timespecadd timespecsub timespecclear +syn keyword cBSDFunction timespecisset timespeccmp + " Common ANSI-standard Names syn keyword cAnsiName PRId8 PRIi16 PRIo32 PRIu64 syn keyword cAnsiName PRId16 PRIi32 PRIo64 PRIuLEAST8 @@ -274,6 +309,7 @@ syn keyword cAnsiName and_eq compl or xor_eq syn keyword cAnsiName bitand not or_eq hi def link cAnsiFunction cFunction +hi def link cBSDFunction cFunction hi def link cAnsiName cIdentifier hi def link cFunction Function hi def link cIdentifier Identifier From c0881b6caf525e1165f9c98539b9ad927ed84c98 Mon Sep 17 00:00:00 2001 From: Cataldo Date: Fri, 18 Oct 2019 16:51:26 -0300 Subject: [PATCH 10/10] Create user-controllable variable for BSD extensions When the option cpp_posix_standard is enable, BSD extension functions are highlighted --- README.md | 5 ++++ after/syntax/c.vim | 71 ++++++++++++++++++++++++---------------------- 2 files changed, 42 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 6b500b1..2f4ab58 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,11 @@ Highlighting of POSIX functions is disabled by default. To enable set let g:cpp_posix_standard = 1 ``` +Highlighting of BSD extension functions is disabled by default. To enable set +```vim +let g:cpp_bsd_standard = 1 +``` + There are two ways to highlight template functions. Either ```vim let g:cpp_experimental_simple_template_highlight = 1 diff --git a/after/syntax/c.vim b/after/syntax/c.vim index 78f683c..7f1f5cc 100644 --- a/after/syntax/c.vim +++ b/after/syntax/c.vim @@ -47,6 +47,43 @@ if exists('g:cpp_posix_standard') && g:cpp_posix_standard hi def link cPOSIXFunction Function endif +" Highlight BSD extensions. +" ----------------------------------------------------------------------------- +if exists('g:cpp_bsd_standard') && g:cpp_bsd_standard + syn keyword cBSDFunction err errx warn warnx verr verrx vwarn vwarnx + syn keyword cBSDFunction errc verrc warnc vwarnc + syn keyword cBSDFunction strtonum strtoi strtou + syn keyword cBSDFunction dehumanize_number expand_number + syn keyword cBSDFunction strlcat strlcpy strnstr wcslcat wcslcpy + syn keyword cBSDFunction vis nvis strvis stravis strnvis strvisx + syn keyword cBSDFunction strnvisx strenvisx svis snvis strsvis + syn keyword cBSDFunction strsnvis strsvisx strsnvisx strsenvisx + syn keyword cBSDFunction unvis strunvis strnunvis strunvisx strnunvisx + syn keyword cBSDFunction arc4random arc4random_buf arc4random_uniform + syn keyword cBSDFunction arc4random_stir arc4random_addrrandom + syn keyword cBSDFunction be16dec be32dec be64dec le16dec le32dec le64dec + syn keyword cBSDFunction be16enc be32enc be64enc le16enc le32enc le64enc + syn keyword cBSDFunction bit_alloc bit_decl bit_clear bit_ffc bit_ffs + syn keyword cBSDFunction bit_nclear bit_nset bit_set bitstr_size + syn keyword cBSDFunction bit_test + syn keyword cBSDFunction sl_init sl_add sl_free sl_find sl_delete + syn keyword cBSDFunction closefrom bzero explicit_bzero + syn keyword cBSDFunction fgetln fgetwln flopen fmtcheck fparseln fpurge + syn keyword cBSDFunction funopen strmode + syn keyword cBSDFunction getbsize getmode setmode getpeereid + syn keyword cBSDFunction pidfile_open pidfile_write pidfile_close + syn keyword cBSDFunction pidfile_remove pidfile_fileno + syn keyword cBSDFunction getprogname setprogname nlist + syn keyword cBSDFunction setproctitle_init setproctitle + syn keyword cBSDFunction heapsort mergesort radixsort sradixsort + syn keyword cBSDFunction MD5Init MD5Update MD5Pad MD5Final MD5Transform + syn keyword cBSDFunction MD5End MD5File MD5FileChunk MD5Data + syn keyword cBSDFunction readpassphrase + syn keyword cBSDFunction reallocarray reallocf + syn keyword cBSDFunction timeradd timersub timerclear timerisset timercmp + syn keyword cBSDFunction timespecadd timespecsub timespecclear + syn keyword cBSDFunction timespecisset timespeccmp +endif " ----------------------------------------------------------------------------- " Source: aftersyntaxc.vim " ----------------------------------------------------------------------------- @@ -221,40 +258,6 @@ syn keyword cAnsiFunction UINTMAX_C INTMAX_C UINT64_C syn keyword cAnsiFunction UINT32_C UINT16_C UINT8_C syn keyword cAnsiFunction INT64_C INT32_C INT16_C INT8_C -" Common BSD extensions -syn keyword cBSDFunction err errx warn warnx verr verrx vwarn vwarnx -syn keyword cBSDFunction errc verrc warnc vwarnc -syn keyword cBSDFunction strtonum strtoi strtou -syn keyword cBSDFunction dehumanize_number expand_number -syn keyword cBSDFunction strlcat strlcpy strnstr wcslcat wcslcpy -syn keyword cBSDFunction vis nvis strvis stravis strnvis strvisx -syn keyword cBSDFunction strnvisx strenvisx svis snvis strsvis -syn keyword cBSDFunction strsnvis strsvisx strsnvisx strsenvisx -syn keyword cBSDFunction unvis strunvis strnunvis strunvisx strnunvisx -syn keyword cBSDFunction arc4random arc4random_buf arc4random_uniform -syn keyword cBSDFunction arc4random_stir arc4random_addrrandom -syn keyword cBSDFunction be16dec be32dec be64dec le16dec le32dec le64dec -syn keyword cBSDFunction be16enc be32enc be64enc le16enc le32enc le64enc -syn keyword cBSDFunction bit_alloc bit_decl bit_clear bit_ffc bit_ffs -syn keyword cBSDFunction bit_nclear bit_nset bit_set bitstr_size -syn keyword cBSDFunction bit_test -syn keyword cBSDFunction sl_init sl_add sl_free sl_find sl_delete -syn keyword cBSDFunction closefrom bzero explicit_bzero -syn keyword cBSDFunction fgetln fgetwln flopen fmtcheck fparseln fpurge -syn keyword cBSDFunction funopen strmode -syn keyword cBSDFunction getbsize getmode setmode getpeereid -syn keyword cBSDFunction pidfile_open pidfile_write pidfile_close -syn keyword cBSDFunction pidfile_remove pidfile_fileno -syn keyword cBSDFunction getprogname setprogname nlist -syn keyword cBSDFunction setproctitle_init setproctitle -syn keyword cBSDFunction heapsort mergesort radixsort sradixsort -syn keyword cBSDFunction MD5Init MD5Update MD5Pad MD5Final MD5Transform -syn keyword cBSDFunction MD5End MD5File MD5FileChunk MD5Data -syn keyword cBSDFunction readpassphrase -syn keyword cBSDFunction reallocarray reallocf -syn keyword cBSDFunction timeradd timersub timerclear timerisset timercmp -syn keyword cBSDFunction timespecadd timespecsub timespecclear -syn keyword cBSDFunction timespecisset timespeccmp " Common ANSI-standard Names syn keyword cAnsiName PRId8 PRIi16 PRIo32 PRIu64