Mercurial > vim
annotate runtime/syntax/yacc.vim @ 36258:4e190eb5f0ad draft
runtime(vim): Update base-syntax file, improve class, enum and interface highlighting
Commit: https://github.com/vim/vim/commit/818c641b6fac73b574a2b760213f515cee9a3c8e
Author: Doug Kearns <dougkearns@gmail.com>
Date: Sun Oct 6 17:00:48 2024 +0200
runtime(vim): Update base-syntax file, improve class, enum and interface highlighting
- Enable folding of class, enum and interface declarations.
- Highlight constructor names with the Function highlight group, like
other special methods.
- Mark function definitions using special method names as errors.
- Highlight :type arguments.
fixes: #14393#issuecomment-2042796198.
closes: #13810
Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 06 Oct 2024 17:15:04 +0200 |
parents | 02bd0fe77c68 |
children |
rev | line source |
---|---|
7 | 1 " Vim syntax file |
2 " Language: Yacc | |
34375
02bd0fe77c68
runtime(misc): announce adoption of various runtime files
Christian Brabandt <cb@256bit.org>
parents:
19180
diff
changeset
|
3 " Former Maintainer: Charles E. Campbell |
16208 | 4 " Last Change: Mar 25, 2019 |
19180 | 5 " Version: 17 |
34375
02bd0fe77c68
runtime(misc): announce adoption of various runtime files
Christian Brabandt <cb@256bit.org>
parents:
19180
diff
changeset
|
6 " 2024 Feb 19 by Vim Project (announce adoption) |
02bd0fe77c68
runtime(misc): announce adoption of various runtime files
Christian Brabandt <cb@256bit.org>
parents:
19180
diff
changeset
|
7 " Former URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_YACC |
7 | 8 " |
1624 | 9 " Options: {{{1 |
683 | 10 " g:yacc_uses_cpp : if this variable exists, then C++ is loaded rather than C |
7 | 11 |
1624 | 12 " --------------------------------------------------------------------- |
2034 | 13 " this version of syntax/yacc.vim requires 6.0 or later |
14 if exists("b:current_syntax") | |
15 syntax clear | |
16 endif | |
17 | |
18 " --------------------------------------------------------------------- | |
19 " Folding Support {{{1 | |
20 if has("folding") | |
3920 | 21 com! -nargs=+ SynFold <args> fold |
2034 | 22 else |
3920 | 23 com! -nargs=+ SynFold <args> |
7 | 24 endif |
25 | |
1624 | 26 " --------------------------------------------------------------------- |
27 " Read the C syntax to start with {{{1 | |
3920 | 28 " Read the C/C++ syntax to start with |
29 let s:Cpath= fnameescape(expand("<sfile>:p:h").(exists("g:yacc_uses_cpp")? "/cpp.vim" : "/c.vim")) | |
30 if !filereadable(s:Cpath) | |
31 for s:Cpath in split(globpath(&rtp,(exists("g:yacc_uses_cpp")? "syntax/cpp.vim" : "syntax/c.vim")),"\n") | |
32 if filereadable(fnameescape(s:Cpath)) | |
33 let s:Cpath= fnameescape(s:Cpath) | |
34 break | |
35 endif | |
36 endfor | |
7 | 37 endif |
3920 | 38 exe "syn include @yaccCode ".s:Cpath |
7 | 39 |
1624 | 40 " --------------------------------------------------------------------- |
2034 | 41 " Yacc Clusters: {{{1 |
2662 | 42 syn cluster yaccInitCluster contains=yaccKey,yaccKeyActn,yaccBrkt,yaccType,yaccString,yaccUnionStart,yaccHeader2,yaccComment,yaccDefines,yaccParseParam,yaccParseOption |
6484 | 43 syn cluster yaccRulesCluster contains=yaccNonterminal,yaccString,yaccComment |
2034 | 44 |
45 " --------------------------------------------------------------------- | |
46 " Yacc Sections: {{{1 | |
16208 | 47 SynFold syn region yaccInit start='.'ms=s-1,rs=s-1 matchgroup=yaccSectionSep end='^%%\ze\(\s*/[*/].*\)\=$'me=e-2,re=e-2 contains=@yaccInitCluster nextgroup=yaccRules skipwhite skipempty contained |
48 SynFold syn region yaccInit2 start='\%^.'ms=s-1,rs=s-1 matchgroup=yaccSectionSep end='^%%\ze\(\s*/[*/].*\)\=$'me=e-2,re=e-2 contains=@yaccInitCluster nextgroup=yaccRules skipwhite skipempty | |
49 SynFold syn region yaccHeader2 matchgroup=yaccSep start="^\s*\zs%{" end="^\s*%}" contains=@yaccCode nextgroup=yaccInit skipwhite skipempty contained | |
50 SynFold syn region yaccHeader matchgroup=yaccSep start="^\s*\zs%{" end="^\s*%}" contains=@yaccCode nextgroup=yaccInit skipwhite skipempty | |
51 SynFold syn region yaccRules matchgroup=yaccSectionSep start='^%%\ze\(\s*/[*/].*\)\=$' end='^%%\ze\(\s*/[*/].*\)\=$'me=e-2,re=e-2 contains=@yaccRulesCluster nextgroup=yaccEndCode skipwhite skipempty contained | |
52 SynFold syn region yaccEndCode matchgroup=yaccSectionSep start='^%%\ze\(\s*/[*/].*\)\=$' end='\%$' contains=@yaccCode contained | |
7 | 53 |
1624 | 54 " --------------------------------------------------------------------- |
2034 | 55 " Yacc Commands: {{{1 |
2473
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
56 syn match yaccDefines '^%define\s\+.*$' |
2662 | 57 syn match yaccParseParam '%\(parse\|lex\)-param\>' skipwhite nextgroup=yaccParseParamStr |
58 syn match yaccParseOption '%\%(api\.pure\|pure-parser\|locations\|error-verbose\)\>' | |
2473
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
59 syn region yaccParseParamStr contained matchgroup=Delimiter start='{' end='}' contains=cStructure |
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
60 |
2034 | 61 syn match yaccDelim "[:|]" contained |
62 syn match yaccOper "@\d\+" contained | |
7 | 63 |
2034 | 64 syn match yaccKey "^\s*%\(token\|type\|left\|right\|start\|ident\|nonassoc\)\>" contained |
65 syn match yaccKey "\s%\(prec\|expect\)\>" contained | |
66 syn match yaccKey "\$\(<[a-zA-Z_][a-zA-Z_0-9]*>\)\=[\$0-9]\+" contained | |
67 syn keyword yaccKeyActn yyerrok yyclearin contained | |
7 | 68 |
2034 | 69 syn match yaccUnionStart "^%union" skipwhite skipnl nextgroup=yaccUnion contained |
3920 | 70 SynFold syn region yaccUnion matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}" contains=@yaccCode contained |
2034 | 71 syn match yaccBrkt "[<>]" contained |
72 syn match yaccType "<[a-zA-Z_][a-zA-Z0-9_]*>" contains=yaccBrkt contained | |
7 | 73 |
3920 | 74 SynFold syn region yaccNonterminal start="^\s*\a\w*\ze\_s*\(/\*\_.\{-}\*/\)\=\_s*:" matchgroup=yaccDelim end=";" matchgroup=yaccSectionSep end='^%%$'me=e-2,re=e-2 contains=yaccAction,yaccDelim,yaccString,yaccComment contained |
2034 | 75 syn region yaccComment start="/\*" end="\*/" |
16208 | 76 syn region yaccComment start="//" end="$" |
2034 | 77 syn match yaccString "'[^']*'" contained |
78 | |
7 | 79 |
1624 | 80 " --------------------------------------------------------------------- |
81 " I'd really like to highlight just the outer {}. Any suggestions??? {{{1 | |
2034 | 82 syn match yaccCurlyError "[{}]" |
3920 | 83 SynFold syn region yaccAction matchgroup=yaccCurly start="{" end="}" contains=@yaccCode,yaccVar contained |
84 syn match yaccVar '\$\d\+\|\$\$\|\$<\I\i*>\$\|\$<\I\i*>\d\+' containedin=cParen,cPreProc,cMulti contained | |
7 | 85 |
1624 | 86 " --------------------------------------------------------------------- |
87 " Yacc synchronization: {{{1 | |
2034 | 88 syn sync fromstart |
7 | 89 |
1624 | 90 " --------------------------------------------------------------------- |
91 " Define the default highlighting. {{{1 | |
10051
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
92 if !exists("skip_yacc_syn_inits") |
3920 | 93 hi def link yaccBrkt yaccStmt |
94 hi def link yaccComment Comment | |
95 hi def link yaccCurly Delimiter | |
96 hi def link yaccCurlyError Error | |
97 hi def link yaccDefines cDefine | |
98 hi def link yaccDelim Delimiter | |
99 hi def link yaccKeyActn Special | |
100 hi def link yaccKey yaccStmt | |
101 hi def link yaccNonterminal Function | |
102 hi def link yaccOper yaccStmt | |
103 hi def link yaccParseOption cDefine | |
104 hi def link yaccParseParam yaccParseOption | |
105 hi def link yaccSectionSep Todo | |
106 hi def link yaccSep Delimiter | |
107 hi def link yaccStmt Statement | |
108 hi def link yaccString String | |
109 hi def link yaccType Type | |
110 hi def link yaccUnionStart yaccKey | |
111 hi def link yaccVar Special | |
7 | 112 endif |
2034 | 113 |
114 " --------------------------------------------------------------------- | |
115 " Cleanup: {{{1 | |
3920 | 116 delcommand SynFold |
7 | 117 let b:current_syntax = "yacc" |
118 | |
1624 | 119 " --------------------------------------------------------------------- |
120 " Modelines: {{{1 | |
121 " vim: ts=15 fdm=marker |