diff options
Diffstat (limited to 'syntax')
-rw-r--r-- | syntax/beancount.vim | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/syntax/beancount.vim b/syntax/beancount.vim index 04e72ea..5961c17 100644 --- a/syntax/beancount.vim +++ b/syntax/beancount.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: beancount " Maintainer: Nathan Grigg -" Latest Revision: 2014-10-07 +" Latest Revision: 2016-04-25 " if exists("b:current_syntax") " finish @@ -19,10 +19,13 @@ syn match beanCurrency "\v\w+" contained syn match beanAccount "\v[[:alnum:]]+:[-[:alnum:]:]+" contained syn match beanTag "\v#[-[:alnum:]]+" contained syn match beanLink "\v\^\S+" contained - +" We must require a space after the flag because you can have flags per +" transaction leg, and the letter-based flags might get confused with the +" start of an account name. +syn match beanFlag "\v[*!&#?%PSTCURM]\s\@=" contained " Most directives start with a date. -syn match beanDate "^\v\d{4}-\d{2}-\d{2}" skipwhite +syn match beanDate "^\v\d{4}[-/]\d{2}[-/]\d{2}" skipwhite \ nextgroup=beanOpen,beanTxn,beanClose,beanNote,beanBalance,beanEvent,beanPad,beanPrice " Options and events have two string arguments. The first, we are matching as " beanOptionTitle and the second as a regular string. @@ -30,6 +33,8 @@ syn region beanOption matchgroup=beanKeyword start="^option" end="$" \ keepend contains=beanOptionTitle,beanComment syn region beanOption matchgroup=beanKeyword start="^plugin" end="$" \ keepend contains=beanString,beanComment +syn region beanInclude matchgroup=beanKeyword start="^include" end="$" + \ keepend contains=beanString,beanComment syn region beanEvent matchgroup=beanKeyword start="event" end="$" contained \ keepend contains=beanOptionTitle,beanComment syn region beanOptionTitle start='"' skip='\\"' end='"' contained @@ -49,16 +54,28 @@ syn region beanPushTag matchgroup=beanKeyword start="\v^(push|pop)tag" end="$" syn region beanPad matchgroup=beanKeyword start="pad" end="$" contained \ keepend contains=beanAccount,beanComment -syn region beanTxn matchgroup=beanKeyword start="\v(txn)?\s+[*!]" skip="^\s" +syn region beanTxn matchgroup=beanKeyword start="\v\s+(txn|[*!&#?%PSTCURM])" skip="^\s" \ end="^" keepend contained fold \ contains=beanString,beanPost,beanComment,beanTag,beanLink,beanMeta -syn region beanPost start="^\v\C\s+[A-Z]@=" end="$" - \ contains=beanAccount,beanAmount,beanComment,beanCost,beanPrice -syn region beanMeta matchgroup=beanTag start="^\v\C\s+[-a-z]+:(\s|$)@=" end="$" +syn region beanPost start="^\v\C\s+(([*!&#?%PSTCURM]\s+)?[A-Z])@=" end="$" + \ contains=beanFlag,beanAccount,beanAmount,beanComment,beanCost,beanPrice +syn region beanMeta matchgroup=beanTag start="^\v\C\s+[a-z][-_a-zA-Z0-9]*:(\s|$)@=" end="$" syn region beanCost start="{" end="}" contains=beanAmount contained syn match beanPrice "\V@@\?" nextgroup=beanAmount contained +syn region beanHashHeaderFold + \ start="^\z(#\+\)" + \ skip="^\s*\z1#\+" + \ end="^\(#\)\@=" + \ fold contains=TOP + +syn region beanStarHeaderFold + \ start="^\z(\*\+\)" + \ skip="^\s*\z1\*\+" + \ end="^\(\*\)\@=" + \ fold contains=TOP + highlight default link beanKeyword Keyword highlight default link beanOptionTitle Keyword highlight default link beanDate Keyword @@ -72,3 +89,4 @@ highlight default link beanPrice Number highlight default link beanTag Comment highlight default link beanLink Comment highlight default link beanMeta Comment +highlight default link beanFlag Keyword |