Skip to content

Commit 3a298c9

Browse files
committed
Add more advanced cpp syntax, #557
1 parent d9ec600 commit 3a298c9

File tree

4 files changed

+531
-1
lines changed

4 files changed

+531
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ A collection of language packs for Vim.
77
> One to rule them all, one to find them, one to bring them all and in the darkness bind them.
88
99
- It **won't affect your startup time**, as scripts are loaded only on demand\*.
10-
- It **installs and updates 120+ times faster** than the <!--Package Count-->199<!--/Package Count--> packages it consists of.
10+
- It **installs and updates 120+ times faster** than the <!--Package Count-->200<!--/Package Count--> packages it consists of.
1111
- It is more secure because scripts loaded for all extensions are generated by vim-polyglot (ftdetect).
1212
- Solid syntax and indentation support (other features skipped). Only the best language packs.
1313
- All unnecessary files are ignored (like enormous documentation from php support).
@@ -89,6 +89,7 @@ If you need full functionality of any plugin, please use it directly with your p
8989
- [clojure](https://github.com/guns/vim-clojure-static)
9090
- [cmake](https://github.com/pboettch/vim-cmake-syntax)
9191
- [coffee-script](https://github.com/kchmck/vim-coffee-script)
92+
- [cpp-modern](https://github.com/bfrg/vim-cpp-modern)
9293
- [cql](https://github.com/elubow/cql-vim)
9394
- [cryptol](https://github.com/victoredwardocallaghan/cryptol.vim)
9495
- [crystal](https://github.com/rhysd/vim-crystal)

after/syntax/c.vim

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'cpp-modern') == -1
2+
3+
" ==============================================================================
4+
" Vim syntax file
5+
" Language: C Additions
6+
" Original Author: Mikhail Wolfson <[email protected]>
7+
" http://www.vim.org/scripts/script.php?script_id=3064
8+
" Maintainer: bfrg <[email protected]>
9+
" Website: https://github.com/bfrg/vim-cpp-modern
10+
" Last Change: Mar 14, 2020
11+
"
12+
" Extended C syntax highlighting including highlighting of user-defined
13+
" functions.
14+
"
15+
" This syntax file is based on:
16+
" https://github.com/octol/vim-cpp-enhanced-highlight
17+
" ==============================================================================
18+
19+
20+
" Highlight some additional keywords in the comments
21+
syn keyword cTodo contained BUG NOTE
22+
23+
24+
" Highlight function names
25+
if !get(g:, 'cpp_no_function_highlight', 0)
26+
syn match cUserFunction "\<\h\w*\>\(\s\|\n\)*("me=e-1 contains=cParen,cCppParen
27+
hi def link cUserFunction Function
28+
endif
29+
30+
31+
" Common ANSI-standard Names
32+
syn keyword cAnsiName
33+
\ PRId8 PRIi16 PRIo32 PRIu64 PRId16 PRIi32 PRIo64 PRIuLEAST8 PRId32 PRIi64 PRIoLEAST8 PRIuLEAST16 PRId64 PRIiLEAST8 PRIoLEAST16 PRIuLEAST32 PRIdLEAST8 PRIiLEAST16 PRIoLEAST32 PRIuLEAST64 PRIdLEAST16 PRIiLEAST32 PRIoLEAST64 PRIuFAST8 PRIdLEAST32 PRIiLEAST64 PRIoFAST8 PRIuFAST16 PRIdLEAST64 PRIiFAST8 PRIoFAST16 PRIuFAST32 PRIdFAST8 PRIiFAST16 PRIoFAST32 PRIuFAST64 PRIdFAST16 PRIiFAST32 PRIoFAST64 PRIuMAX PRIdFAST32 PRIiFAST64 PRIoMAX PRIuPTR PRIdFAST64 PRIiMAX PRIoPTR PRIx8 PRIdMAX PRIiPTR PRIu8 PRIx16 PRIdPTR PRIo8 PRIu16 PRIx32 PRIi8 PRIo16 PRIu32 PRIx64 PRIxLEAST8 SCNd8 SCNiFAST32 SCNuLEAST32 PRIxLEAST16 SCNd16 SCNiFAST64 SCNuLEAST64 PRIxLEAST32 SCNd32 SCNiMAX SCNuFAST8 PRIxLEAST64 SCNd64 SCNiPTR SCNuFAST16 PRIxFAST8 SCNdLEAST8 SCNo8 SCNuFAST32 PRIxFAST16 SCNdLEAST16 SCNo16 SCNuFAST64 PRIxFAST32 SCNdLEAST32 SCNo32 SCNuMAX PRIxFAST64 SCNdLEAST64 SCNo64 SCNuPTR PRIxMAX SCNdFAST8 SCNoLEAST8 SCNx8 PRIxPTR SCNdFAST16 SCNoLEAST16 SCNx16 PRIX8 SCNdFAST32 SCNoLEAST32 SCNx32 PRIX16 SCNdFAST64 SCNoLEAST64 SCNx64 PRIX32 SCNdMAX SCNoFAST8 SCNxLEAST8 PRIX64 SCNdPTR SCNoFAST16 SCNxLEAST16 PRIXLEAST8 SCNi8 SCNoFAST32 SCNxLEAST32 PRIXLEAST16 SCNi16 SCNoFAST64 SCNxLEAST64 PRIXLEAST32 SCNi32 SCNoMAX SCNxFAST8 PRIXLEAST64 SCNi64 SCNoPTR SCNxFAST16 PRIXFAST8 SCNiLEAST8 SCNu8 SCNxFAST32 PRIXFAST16 SCNiLEAST16 SCNu16 SCNxFAST64 PRIXFAST32 SCNiLEAST32 SCNu32 SCNxMAX PRIXFAST64 SCNiLEAST64 SCNu64 SCNxPTR PRIXMAX SCNiFAST8 SCNuLEAST8 PRIXPTR SCNiFAST16 SCNuLEAST16 STDC CX_LIMITED_RANGE STDC FENV_ACCESS STDC FP_CONTRACT
34+
\ errno environ and bitor not_eq xor and_eq compl or xor_eq bitand not or_eq
35+
36+
" Booleans
37+
syn keyword cBoolean true false TRUE FALSE
38+
39+
40+
" Default highlighting
41+
hi def link cBoolean Boolean
42+
hi def link cAnsiName Identifier
43+
44+
45+
" Highlight all standard C keywords as Statement
46+
" This is very similar to what other IDEs and editors do
47+
if get(g:, 'cpp_simple_highlight', 0)
48+
hi link cStorageClass Statement
49+
hi link cStructure Statement
50+
hi link cLabel Statement
51+
endif
52+
53+
54+
" Operators
55+
" syn match cOperator "\(<<\|>>\|[-+*/%&^|<>!=]\)="
56+
" syn match cOperator "<<\|>>\|&&\|||\|++\|--\|->"
57+
" syn match cOperator "[.!~*&%<>^|=,+-]"
58+
" syn match cOperator "/[^/*=]"me=e-1
59+
" syn match cOperator "/$"
60+
" syn match cOperator "&&\|||"
61+
" syn match cOperator "[][]"
62+
63+
" Preprocessor
64+
" syn keyword cDefined defined contained containedin=cDefine
65+
" hi def link cDefined cDefine
66+
67+
" Delimiters
68+
" syn match cDelimiter "[();\\]"
69+
" hi def link cDelimiter Delimiter
70+
" foldmethod=syntax fix, courtesy of Ivan Freitas
71+
" syn match cBraces display "[{}]"
72+
" hi def link cBraces Delimiter
73+
74+
endif

0 commit comments

Comments
 (0)