From 58d270e58203c335a211dbee424e048a1bf9523a Mon Sep 17 00:00:00 2001 From: Midgard Date: Sun, 20 Jun 2021 22:08:41 +0200 Subject: [PATCH] HLDS: change :: to double space and require it Require double space before tags and price, like in the plain text accounting format of ledger. This makes it easier to differentiate between prices mentioned in descriptions and the price for the dish. --- app/hlds/hlds.tatsu | 12 +++++++----- etc/vim/ftplugin.vim | 1 + etc/vim/syntax.vim | 5 +++-- etc/vscode/syntaxes/hlds.tmLanguage.json | 11 +++-------- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/app/hlds/hlds.tatsu b/app/hlds/hlds.tatsu index b4d47b8..08c859c 100644 --- a/app/hlds/hlds.tatsu +++ b/app/hlds/hlds.tatsu @@ -29,10 +29,12 @@ location = >location_header items:{ block } ; attributes = - name:/[^\n#]*?(?= +-- | +:: | +€ | *\n| *#)/ - [ s '--' ~ s description:/[^\n#]*?(?= +:: | +€ | *\n| *#)/ ] - [ s '::' {s ('{' tags+:identifier '}')} ] - [ [ s '::' ~ ] s price:price ] + name:/[^\n#]*?(?= +-- | | *\n| *#)/ + [ s '--' ~ s description:/[^\n#]*?(?= | *\n| *#)/ ] + [ / {2,}/ ~ + [ {[ s ] ('{' tags+:identifier '}')} / +|$/ ] + [ price:price ] + ] ; @@ -73,7 +75,7 @@ indent_choice_block = ; -s = / +/ ; +s = / +/ ; n = '\n' {{'\t'} '\n'} ; @name diff --git a/etc/vim/ftplugin.vim b/etc/vim/ftplugin.vim index bbd8967..edcbd4d 100644 --- a/etc/vim/ftplugin.vim +++ b/etc/vim/ftplugin.vim @@ -1 +1,2 @@ setlocal noexpandtab +setlocal softtabstop=0 diff --git a/etc/vim/syntax.vim b/etc/vim/syntax.vim index f9d2629..5b783cd 100644 --- a/etc/vim/syntax.vim +++ b/etc/vim/syntax.vim @@ -25,8 +25,9 @@ syn keyword hldsChoiceType single_choice multi_choice nextgroup=hldsBlockIdAf syn match hldsBlockId "^[a-z0-9_-]\+: " syn match hldsBlockIdAftrKywrd "[a-z0-9_-]\+: " contained -syn match hldsTag " {[a-z0-9_-]\+}" -syn match hldsPrice "€ *[0-9]\+\(\.[0-9]\+\|\)" +syn match _doubleSpace " \+" nextgroup=hldsTag,hldsPrice +syn match hldsTag "{[a-z0-9_-]\+}\( \|$\)" contained nextgroup=hldsTag,hldsPrice +syn match hldsPrice "€ *[0-9]\+\(\.[0-9]\+\|\)\( \|$\)" contained syn match hldsComment "#.*$" contains=hldsTodo,@Spell syn keyword hldsTodo FIXME NOTE NOTES TODO XXX contained diff --git a/etc/vscode/syntaxes/hlds.tmLanguage.json b/etc/vscode/syntaxes/hlds.tmLanguage.json index cfbe47a..02f52b2 100644 --- a/etc/vscode/syntaxes/hlds.tmLanguage.json +++ b/etc/vscode/syntaxes/hlds.tmLanguage.json @@ -33,13 +33,8 @@ "tags": { "patterns": [ { - "match": "(::)\\s*({[a-zA-Z-_]*}\\s*)*", - "name": "markup.italic", - "captures": { - "1": { - "name": "markup.bold" - } - } + "match": " +( +{[a-zA-Z-_]*})*", + "name": "markup.italic" } ] }, @@ -94,4 +89,4 @@ } }, "scopeName": "source.hlds" -} \ No newline at end of file +}