aboutsummaryrefslogtreecommitdiffstats
path: root/syntax
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--syntax/beancount.vim32
-rw-r--r--syntax_checkers/beancount/bean_check.vim13
2 files changed, 31 insertions, 14 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
diff --git a/syntax_checkers/beancount/bean_check.vim b/syntax_checkers/beancount/bean_check.vim
index c3e5fce..b477104 100644
--- a/syntax_checkers/beancount/bean_check.vim
+++ b/syntax_checkers/beancount/bean_check.vim
@@ -4,17 +4,16 @@ endif
let g:loaded_syntastic_beancount_bean_check=1
-let s:save_cpo = &cpo
-set cpo&vim
+let s:save_cpo = &cpoptions
+set cpoptions&vim
function! SyntaxCheckers_beancount_bean_check_IsAvailable() dict
- return executable(self.getExec())
+ return executable(l:self.getExec())
endfunction
function! SyntaxCheckers_beancount_bean_check_GetLocList() dict
- let makeprg = self.makeprgBuild({})
-
- return SyntasticMake({ 'makeprg': makeprg })
+ let l:makeprg = l:self.makeprgBuild({})
+ return SyntasticMake({ 'makeprg': l:makeprg })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
@@ -22,5 +21,5 @@ call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'name': 'bean_check',
\ 'exec': 'bean-check'})
-let &cpo = s:save_cpo
+let &cpoptions = s:save_cpo
unlet s:save_cpo