Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow both fold markers and syntax folding #120

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions spec/folds.vader
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Given ledger:
;{{{Year: 2011
;{{{Month: January

2011/01/01 * What a new years night!
Expenses:Parties $ 1500.00
Assets:Checking


2011/01/01 * What a new years night!
Expenses:Parties $ 1500.00
Assets:Checking

;}}}
;{{{Month:February

2011/01/01 * What a new years night!
Expenses:Parties $ 1500.00
Assets:Checking

;}}}
;}}}
36 changes: 34 additions & 2 deletions syntax/ledger.vim
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,38 @@ exe 'syn match ledgerApplyHead '.
syntax keyword ledgerTodo FIXME TODO
\ contained containedin=ledgerComment,ledgerTransaction,ledgerTransactionMetadata,ledgerPostingMetadata

syn cluster ledgerAll contains={}
" syn cluster ledgerAll add=ledgerComment
" syn cluster ledgerAll add=ledgerBlockComment
syn cluster ledgerAll add=ledgerBlockTest
syn cluster ledgerAll add=ledgerTransactionDate
syn cluster ledgerAll add=ledgerTransactionExpression
syn cluster ledgerAll add=ledgerTransactionMetadata
syn cluster ledgerAll add=ledgerPostingMetadata
syn cluster ledgerAll add=ledgerTypedTag
syn cluster ledgerAll add=ledgerValueTag
syn cluster ledgerAll add=ledgerTag
syn cluster ledgerAll add=ledgerStartApply
syn cluster ledgerAll add=ledgerEndApply
syn cluster ledgerAll add=ledgerApplyHead
syn cluster ledgerAll add=ledgerAccount
syn cluster ledgerAll add=ledgerAmount
syn cluster ledgerAll add=ledgerValueExpression
syn cluster ledgerAll add=ledgerPreDeclarationType
syn cluster ledgerAll add=ledgerPreDeclarationName
syn cluster ledgerAll add=ledgerPreDeclarationDirective
syn cluster ledgerAll add=ledgerDirective
syn cluster ledgerAll add=ledgerOneCharDirective
syn cluster ledgerAll add=ledgerTodo

" if get(g:, 'ledger_fold_markers', 0) == 1
" syn region foldMarker matchgroup=foldMarkers start='{{{' end ='}}}' fold transparent contained contains=
syn region foldMarker matchgroup=foldMarkers start='{{{' end ='}}}' fold transparent
\ contained containedin=ledgerBlockComment,ledgerComment
" contains=ledgerAll
" syn sync fromstart
" endif

highlight default link ledgerComment Comment
highlight default link ledgerBlockComment Comment
highlight default link ledgerBlockTest Comment
Expand All @@ -124,9 +156,9 @@ highlight default link ledgerPreDeclarationDirective Type
highlight default link ledgerDirective Type
highlight default link ledgerOneCharDirective Type
highlight default link ledgerTodo Todo

" syncinc is easy: search for the first transaction.
syn sync clear
syn sync match ledgerSync grouphere ledgerTransaction "^[[:digit:]~=]"

let b:current_syntax = b:is_hledger ? 'hledger' : 'ledger'