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

Review syntax group changes that split cleared/uncleared #96

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
11 changes: 5 additions & 6 deletions ftplugin/ledger.vim
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,11 @@ endif
" }}}

" Highlight groups for Ledger reports {{{
hi! link LedgerNumber Number
hi! link LedgerNegativeNumber Special
hi! link LedgerCleared Constant
hi! link LedgerPending Todo
hi! link LedgerTarget Statement
hi! link LedgerImproperPerc Special
hi link LedgerNumber Number
hi link LedgerNegativeNumber Special
hi link LedgerPending Todo
hi link LedgerTarget Statement
hi link LedgerImproperPerc Special
" }}}

let s:rx_amount = '\('.
Expand Down
14 changes: 9 additions & 5 deletions syntax/ledger.vim
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ syntax clear

exe 'syn region ledgerTransaction start=/^[[:digit:]~=]/ '.
\ 'skip=/^\s'. s:skip . '/ end=/^/ fold keepend transparent '.
\ 'contains=ledgerTransactionDate,ledgerMetadata,ledgerPosting,ledgerTransactionExpression'
\ 'contains=ledgerCleared,ledgerUncleared,ledgerMetadata,ledgerPosting,ledgerTransactionExpression'
syn match ledgerCleared /^\d\S\+ \* .*$/ contained contains=ledgerTransactionDate
syn match ledgerUncleared /^\d\S\+ [^*].*$/ contained contains=ledgerTransactionDate
syn match ledgerTransactionDate /^\d\S\+/ contained
syn match ledgerTransactionExpression /^[=~]\s\+\zs.*/ contained
syn match ledgerPosting /^\s\+[^[:blank:];][^;]*\ze\%($\|;\)/
Expand Down Expand Up @@ -70,9 +72,8 @@ exe 'syn match ledgerApplyHead '.
\ '/'.s:oe.'\%(^apply\s\+\)\@<=\S.*$/ contained'

highlight default link ledgerComment Comment
highlight default link ledgerTransactionDate Constant
highlight default link ledgerTransactionExpression Statement
highlight default link ledgerMetadata Tag
highlight default link ledgerMetadata Comment
highlight default link ledgerTypedTag Keyword
highlight default link ledgerValueTag Type
highlight default link ledgerTag Type
Expand All @@ -84,9 +85,12 @@ highlight default link ledgerAmount Number
highlight default link ledgerPreDeclarationType Type
highlight default link ledgerPreDeclarationName Identifier
highlight default link ledgerPreDeclarationDirective Type

highlight default link ledgerTransactionDate String
highlight default link ledgerCleared String
highlight default link ledgerUncleared Statement

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

let b:current_syntax = "ledger"