From cf786ed5a2f66043b834f85f72b56aa74e0d4c38 Mon Sep 17 00:00:00 2001 From: AlphaJack Date: Thu, 24 Dec 2020 21:42:56 +0100 Subject: [PATCH] Improved and separated ledger and beancount syntaxes --- beancount.nanorc | 20 ++++++++++++++++++++ ledger.nanorc | 21 ++++++++++++++------- 2 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 beancount.nanorc diff --git a/beancount.nanorc b/beancount.nanorc new file mode 100644 index 0000000..966d765 --- /dev/null +++ b/beancount.nanorc @@ -0,0 +1,20 @@ +syntax "Beancount" "(^|\.|/)beancount|bnct|bc$" + +# directives +color red "^([0-9]{4}-[0-9]{2}-[0-9]{2} | )?[a-z-]+( |: )" +# dates +color blue "^[0-9]{4}-[0-9]{2}-[0-9]{2}" +# tags +color green "#\S+" +# links +color blue "\^\S+" +# accounts +color cyan "(\t| )\b\w*-?\w*(:\w*-?\w*){1,}\b" +# currencies and stocks +color cyan "\b[A-Z]+\b" +# double quotes and transaction flags +color red "[*!@\"]" +# text within double quotes +color pink "\"(.*?)\"" +# comments +color brightblack "(^|\s);.*" diff --git a/ledger.nanorc b/ledger.nanorc index 8d07329..d8632da 100644 --- a/ledger.nanorc +++ b/ledger.nanorc @@ -1,10 +1,17 @@ -syntax "Ledger" "(^|\.|/)ledger|ldgr|beancount|bnct$" +syntax "Ledger" "(^|\.|/)ledger|ldgr|lg$" -color brightmagenta "^([0-9]{4}(/|-)[0-9]{2}(/|-)[0-9]{2}|[=~]) .*" -color blue "^[0-9]{4}(/|-)[0-9]{2}(/|-)[0-9]{2}" +# descriptions +color brightmagenta "^(([0-9]{4}(/|-|.))?[0-9]{2}(/|-|.)[0-9]{2}|[=~]) .*" +# dates +color blue "^([0-9]{4}(\/|-|.))?[0-9]{2}(\/|-|.)[0-9]{2}" +# balance color brightyellow "^~ .*" color brightblue "^= .*" -color cyan "^[[:space:]]+(![[:space:]]+)?\(?[A-Za-z ]+(:[A-Za-z ]+)*\)?" -color cyan "^[[:space:]]+(![[:space:]]+)?\(?[A-Za-z_-]+(:[A-Za-z_-]+)*\)?" -color red "[*!]" -color brightblack "^[[:space:]]*;.*" +# accounts +color cyan "(\t| )\b\w*\ ?\w*(:\w*\ ?\w*\w*){1,}\b" +# double quotes and transaction flags +color red "[*!@\"]" +# text within double quotes +color pink "\"(.*?)\"" +# comments +color brightblack "(^|\s)(;|#|%|\|).*"