From 0f81c67c29446edca76de30ab8193815c0613fc2 Mon Sep 17 00:00:00 2001 From: Johann Klähn Date: Mon, 13 Sep 2010 12:55:36 +0200 Subject: vim. change syntax file to allow comments at eol --- contrib/vim/syntax/ledger.vim | 55 +++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 31 deletions(-) (limited to 'contrib/vim/syntax/ledger.vim') diff --git a/contrib/vim/syntax/ledger.vim b/contrib/vim/syntax/ledger.vim index 61f9a2e5..acd17bca 100644 --- a/contrib/vim/syntax/ledger.vim +++ b/contrib/vim/syntax/ledger.vim @@ -28,43 +28,36 @@ syntax clear " DATE[=EDATE] [*|!] [(CODE)] DESC <-- first line of transaction " ACCOUNT AMOUNT [; NOTE] <-- posting -" region: a transaction containing postings -syn region transNorm start=/^[[:digit:]~]/ skip=/^\s/ end=/^/ - \ fold keepend transparent contains=transDate,Metadata,Posting -syn match transDate /^\d\S\+/ contained -syn match Metadata /^\s\+;.*/ contained contains=MetadataTag -syn match Comment /^;.*$/ +syn region ledgerTransaction start=/^[[:digit:]~]/ skip=/^\s/ end=/^/ + \ fold keepend transparent contains=ledgerTransactionDate,ledgerMetadata,ledgerPosting +syn match ledgerTransactionDate /^\d\S\+/ contained +syn match ledgerPosting /^\s\+[^[:blank:];][^;]*\ze\%($\|;\)/ + \ contained transparent contains=ledgerAccount " 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 Account /^\s\+\zs\%(\S \S\|\S\)\+\ze\%([ ]\{2,}\|\t\s*\|\s*$\)/ contained -syn match Posting /^\s\+[^[:blank:];].*$/ contained transparent contains=Account,Amount -" FIXME: add other symbols? -let s:currency = '\([$€£¢]\|\w\+\)' -let s:figures = '\d\+\([.,]\d\+\)*' -let s:amount = '-\?\('.s:figures.'\s*'.s:currency.'\|'.s:currency.'\s*'.s:figures.'\)' -exe 'syn match Amount /'.s:amount.'/ contained' -syn match MetadataTag /:[^:]\+:/hs=s+1,he=e-1 contained -syn match MetadataTag /;\s*\zs[^:]\+\ze:[^:]\+$/ contained +syn match ledgerAccount /^\s\+\zs\%(\S \S\|\S\)\+\ze\%( \|\t\|\s*$\)/ contained -syn region TagStack - \ matchgroup=TagPush start=/^tag\>/ - \ matchgroup=TagPop end=/^pop\>/ - \ contains=TagHead,TagStack,transNorm -syn match TagHead /\%(^tag\s\+\)\@<=\S.*$/ contained contains=tagKey transparent -syn match TagKey /:[^:]\+:/hs=s+1,he=e-1 contained -syn match TagKey /\%(^tag\s\+\)\@<=[^:]\+\ze:[^:]\+$/ contained +syn match ledgerComment /^;.*$/ +syn region ledgerMetadata start=/;/ skip=/^\s\+;/ end=/^/ + \ keepend contained contains=ledgerTag +syn match ledgerTag /:[^:]\+:/hs=s+1,he=e-1 contained +syn match ledgerTag /\%(\%(;\|^tag\)[^:]\+\)\@<=[^:]\+\ze:[^:]\+$/ contained -highlight default link transDate Constant -highlight default link Metadata Tag -highlight default link MetadataTag Type -highlight default link TagPop Tag -highlight default link TagPush Tag -highlight default link TagKey Type -highlight default link Amount Number -highlight default link Account Identifier +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 + +highlight default link ledgerTransactionDate Constant +highlight default link ledgerMetadata Tag +highlight default link ledgerTag Type +highlight default link ledgerTagPop Tag +highlight default link ledgerTagPush Tag +highlight default link ledgerAccount Identifier " syncinc is easy: search for the first transaction. syn sync clear -syn sync match ledgerSync grouphere transNorm "^[[:digit:]~]" +syn sync match ledgerSync grouphere ledgerTransaction "^[[:digit:]~]" let b:current_syntax = "ledger" -- cgit v1.2.3 From c2384b60465ac48ac9bdd77871c611ebeeb7795b Mon Sep 17 00:00:00 2001 From: Johann Klähn Date: Mon, 13 Sep 2010 13:09:17 +0200 Subject: vim. fix highlighting of comments at end of line --- contrib/vim/syntax/ledger.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'contrib/vim/syntax/ledger.vim') diff --git a/contrib/vim/syntax/ledger.vim b/contrib/vim/syntax/ledger.vim index acd17bca..70473232 100644 --- a/contrib/vim/syntax/ledger.vim +++ b/contrib/vim/syntax/ledger.vim @@ -38,7 +38,8 @@ syn match ledgerPosting /^\s\+[^[:blank:];][^;]*\ze\%($\|;\)/ syn match ledgerAccount /^\s\+\zs\%(\S \S\|\S\)\+\ze\%( \|\t\|\s*$\)/ contained syn match ledgerComment /^;.*$/ -syn region ledgerMetadata start=/;/ skip=/^\s\+;/ end=/^/ +" comments at eol must be preceeded by at least 2 spaces / 1 tab +syn region ledgerMetadata start=/\%( \|\t\|^\s\+\);/ skip=/^\s\+;/ end=/^/ \ keepend contained contains=ledgerTag syn match ledgerTag /:[^:]\+:/hs=s+1,he=e-1 contained syn match ledgerTag /\%(\%(;\|^tag\)[^:]\+\)\@<=[^:]\+\ze:[^:]\+$/ contained -- cgit v1.2.3 From 2a82edb9f0b418ca6c855b09cf9ec6fbe4f88d47 Mon Sep 17 00:00:00 2001 From: Johann Klähn Date: Wed, 15 Sep 2010 20:46:18 +0200 Subject: vim. highlight metadata on same line as posting --- contrib/vim/syntax/ledger.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'contrib/vim/syntax/ledger.vim') diff --git a/contrib/vim/syntax/ledger.vim b/contrib/vim/syntax/ledger.vim index 70473232..2a49e93b 100644 --- a/contrib/vim/syntax/ledger.vim +++ b/contrib/vim/syntax/ledger.vim @@ -32,7 +32,7 @@ syn region ledgerTransaction start=/^[[:digit:]~]/ skip=/^\s/ end=/^/ \ fold keepend transparent contains=ledgerTransactionDate,ledgerMetadata,ledgerPosting syn match ledgerTransactionDate /^\d\S\+/ contained syn match ledgerPosting /^\s\+[^[:blank:];][^;]*\ze\%($\|;\)/ - \ contained transparent contains=ledgerAccount + \ 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 -- cgit v1.2.3 From 64ce9e2e99423436329a2ea207c4f45bb17f8766 Mon Sep 17 00:00:00 2001 From: Johann Klähn Date: Thu, 7 Oct 2010 18:09:01 +0200 Subject: vim. highlight typed tags See mailing list on June 12 2010 / "New: Support for typed metadata" Message-Id: --- contrib/vim/syntax/ledger.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'contrib/vim/syntax/ledger.vim') diff --git a/contrib/vim/syntax/ledger.vim b/contrib/vim/syntax/ledger.vim index 2a49e93b..d4097e2b 100644 --- a/contrib/vim/syntax/ledger.vim +++ b/contrib/vim/syntax/ledger.vim @@ -40,9 +40,10 @@ syn match ledgerAccount /^\s\+\zs\%(\S \S\|\S\)\+\ze\%( \|\t\|\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=/^/ - \ keepend contained contains=ledgerTag + \ keepend contained contains=ledgerTag,ledgerTypedTag syn match ledgerTag /:[^:]\+:/hs=s+1,he=e-1 contained -syn match ledgerTag /\%(\%(;\|^tag\)[^:]\+\)\@<=[^:]\+\ze:[^:]\+$/ contained +syn match ledgerTag /\%(\%(;\|^tag\)[^:]\+\)\@<=[^:]\+:\ze[^:]\+$/ contained +syn match ledgerTypedTag /\%(\%(;\|^tag\)[^:]\+\)\@<=[^:]\+::\ze[^:]\+$/ contained syn region ledgerTagStack \ matchgroup=ledgerTagPush start=/^tag\>/ @@ -52,6 +53,7 @@ syn match ledgerTagHead /\%(^tag\s\+\)\@<=\S.*$/ contained contains=ledgerTag tr highlight default link ledgerTransactionDate Constant 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 -- cgit v1.2.3