summaryrefslogtreecommitdiff
path: root/contrib/vim/syntax
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-04-26 16:39:25 -0500
committerJohn Wiegley <johnw@newartisans.com>2012-04-26 16:39:25 -0500
commit64a9b42381c26baf24e58b40f50f0b253e551811 (patch)
tree5447a29dff64c3a8b7be8100a01bcb4a2d73b0bb /contrib/vim/syntax
parent7cc550fc22357e2ded194d3e65287c6b3317f5ae (diff)
parentb4407c10c0071365322b2963747bf42a57fd7304 (diff)
downloadfork-ledger-64a9b42381c26baf24e58b40f50f0b253e551811.tar.gz
fork-ledger-64a9b42381c26baf24e58b40f50f0b253e551811.tar.bz2
fork-ledger-64a9b42381c26baf24e58b40f50f0b253e551811.zip
Merge branch 'release/v3.0.0-20120426'
Diffstat (limited to 'contrib/vim/syntax')
-rw-r--r--contrib/vim/syntax/ledger.vim34
1 files changed, 24 insertions, 10 deletions
diff --git a/contrib/vim/syntax/ledger.vim b/contrib/vim/syntax/ledger.vim
index 73aaa0c3..c516bab0 100644
--- a/contrib/vim/syntax/ledger.vim
+++ b/contrib/vim/syntax/ledger.vim
@@ -17,15 +17,24 @@ syntax clear
" DATE[=EDATE] [*|!] [(CODE)] DESC <-- first line of transaction
" ACCOUNT AMOUNT [; NOTE] <-- posting
-syn region ledgerTransaction start=/^[[:digit:]~]/ skip=/^\s/ end=/^/
- \ fold keepend transparent contains=ledgerTransactionDate,ledgerMetadata,ledgerPosting
+syn region ledgerTransaction start=/^[[:digit:]~=]/ skip=/^\s/ end=/^/
+ \ fold keepend transparent
+ \ contains=ledgerTransactionDate,ledgerMetadata,ledgerPosting,ledgerTransactionExpression
syn match ledgerTransactionDate /^\d\S\+/ contained
+syn match ledgerTransactionExpression /^[=~]\s\+\zs.*/ contained
syn match ledgerPosting /^\s\+[^[:blank:];][^;]*\ze\%($\|;\)/
\ contained transparent contains=ledgerAccount,ledgerMetadata
" every space in an account name shall be surrounded by two non-spaces
" every account name ends with a tab, two spaces or the end of the line
syn match ledgerAccount /^\s\+\zs\%(\S\@<= \S\|\S\)\+\ze\%( \|\t\|\s*$\)/ contained
+syn region ledgerPreDeclaration start=/^\(account\|payee\|commodity\|tag\)/ skip=/^\s/ end=/^/
+ \ keepend transparent
+ \ contains=ledgerPreDeclarationType,ledgerPreDeclarationName,ledgerPreDeclarationDirective
+syn match ledgerPreDeclarationType /^\(account\|payee\|commodity\|tag\)/ contained
+syn match ledgerPreDeclarationName /^\S\+\s\+\zs.*/ contained
+syn match ledgerPreDeclarationDirective /^\s\+\zs\S\+/ contained
+
syn match ledgerComment /^;.*$/
" comments at eol must be preceeded by at least 2 spaces / 1 tab
syn region ledgerMetadata start=/\%( \|\t\|^\s\+\);/ skip=/^\s\+;/ end=/^/
@@ -34,22 +43,27 @@ syn match ledgerTag /:[^:]\+:/hs=s+1,he=e-1 contained
syn match ledgerTag /\%(\%(;\|^tag\)[^:]\+\)\@<=[^:]\+:\ze[^:]\+$/ contained
syn match ledgerTypedTag /\%(\%(;\|^tag\)[^:]\+\)\@<=[^:]\+::\ze[^:]\+$/ contained
-syn region ledgerTagStack
- \ matchgroup=ledgerTagPush start=/^tag\>/
- \ matchgroup=ledgerTagPop end=/^pop\>/
- \ contains=ledgerTagHead,ledgerTagStack,ledgerTransaction,ledgerComment
-syn match ledgerTagHead /\%(^tag\s\+\)\@<=\S.*$/ contained contains=ledgerTag transparent
+syn region ledgerApply
+ \ matchgroup=ledgerStartApply start=/^apply\>/
+ \ matchgroup=ledgerEndApply end=/^end\s\+apply\>/
+ \ contains=ledgerApplyHead,ledgerApply,ledgerTransaction,ledgerComment
+syn match ledgerApplyHead /\%(^apply\s\+\)\@<=\S.*$/ contained
highlight default link ledgerTransactionDate Constant
+highlight default link ledgerTransactionExpression Statement
highlight default link ledgerMetadata Tag
highlight default link ledgerTypedTag Keyword
highlight default link ledgerTag Type
-highlight default link ledgerTagPop Tag
-highlight default link ledgerTagPush Tag
+highlight default link ledgerStartApply Tag
+highlight default link ledgerEndApply Tag
+highlight default link ledgerApplyHead Type
highlight default link ledgerAccount Identifier
+highlight default link ledgerPreDeclarationType Type
+highlight default link ledgerPreDeclarationName Identifier
+highlight default link ledgerPreDeclarationDirective Type
" syncinc is easy: search for the first transaction.
syn sync clear
-syn sync match ledgerSync grouphere ledgerTransaction "^[[:digit:]~]"
+syn sync match ledgerSync grouphere ledgerTransaction "^[[:digit:]~=]"
let b:current_syntax = "ledger"