@@ -11,6 +11,9 @@ elseif exists("b:current_sytax")
11
11
finish
12
12
endif
13
13
14
+ " Force old regex engine (:help two-engines)
15
+ let s: oe = v: version < 704 ? ' ' : ' \%#=1'
16
+
14
17
" for debugging
15
18
syntax clear
16
19
@@ -26,8 +29,10 @@ syn match ledgerPosting /^\s\+[^[:blank:];][^;]*\ze\%($\|;\)/
26
29
\ contained transparent contains= ledgerAccount,ledgerAmount,ledgerMetadata
27
30
" every space in an account name shall be surrounded by two non-spaces
28
31
" every account name ends with a tab, two spaces or the end of the line
29
- syn match ledgerAccount / ^\s\+\z s\% (\S\@ <= \S\|\S\)\+\z e\% ( \|\t\|\s *$\) / contained
30
- syn match ledgerAmount / \S\@ <=\% ( \|\t\)\s *\z s\% ([^;[:space:]]\|\s\+ [^;[:space:]]\)\+ / contained
32
+ exe ' syn match ledgerAccount ' .
33
+ \ ' /' .s: oe .' ^\s\+\zs\%(\S\@1<= \S\|\S\)\+\ze\%( \|\t\|\s*$\)/ contained'
34
+ exe ' syn match ledgerAmount ' .
35
+ \ ' /' .s: oe .' \S\@1<=\%( \|\t\)\s*\zs\%([^;[:space:]]\|\s\+[^;[:space:]]\)\+/ contained'
31
36
32
37
syn region ledgerPreDeclaration start =/ ^\( account\| payee\| commodity\| tag\) / skip =/ ^\s / end =/ ^/
33
38
\ keepend transparent
@@ -40,17 +45,22 @@ syn match ledgerComment /^;.*$/
40
45
" comments at eol must be preceeded by at least 2 spaces / 1 tab
41
46
syn region ledgerMetadata start =/ \% ( \|\t\| ^\s\+\) ;/ skip =/ ^\s\+ ;/ end =/ ^/
42
47
\ keepend contained contains= ledgerTags,ledgerValueTag,ledgerTypedTag
43
- syn match ledgerTags / \% (\% (;\s *\| ^tag\s\+\)\)\@ <=:[^:[:space:]][^:]*\% (::\? [^:[:space:]][^:]*\) *:\s *$/
44
- \ contained contains= ledgerTag
48
+ exe ' syn match ledgerTags ' .
49
+ \ ' /' s: oe .' \%#=1\%(\%(;\s*\|^tag\s\+\)\)\@<=' .
50
+ \ ' :[^:[:space:]][^:]*\%(::\?[^:[:space:]][^:]*\)*:\s*$/ ' .
51
+ \ ' contained contains=ledgerTag'
45
52
syn match ledgerTag / :\z s[^:]\+\z e:/ contained
46
- syn match ledgerValueTag / \% (\% (;\| ^tag\) [^:]\+\)\@ <=[^:]\+ :\z e.\+ $/ contained
47
- syn match ledgerTypedTag / \% (\% (;\| ^tag\) [^:]\+\)\@ <=[^:]\+ ::\z e.\+ $/ contained
53
+ exe ' syn match ledgerValueTag ' .
54
+ \ ' /\%#=1\%(\%(;\|^tag\)[^:]\+\)\@<=[^:]\+:\ze.\+$/ contained'
55
+ exe ' syn match ledgerTypedTag ' .
56
+ \ ' /\%#=1\%(\%(;\|^tag\)[^:]\+\)\@<=[^:]\+::\ze.\+$/ contained'
48
57
49
58
syn region ledgerApply
50
59
\ matchgroup= ledgerStartApply start = /^apply\>/
51
60
\ matchgroup= ledgerEndApply end = /^end\s\+apply\>/
52
61
\ contains= ledgerApplyHead,ledgerApply,ledgerTransaction,ledgerComment
53
- syn match ledgerApplyHead / \% (^apply\s\+\)\@ <=\S .*$/ contained
62
+ exe ' syn match ledgerApplyHead ' .
63
+ \ ' /\%#=1\%(^apply\s\+\)\@<=\S.*$/ contained'
54
64
55
65
highlight default link ledgerComment Comment
56
66
highlight default link ledgerTransactionDate Constant
0 commit comments