From a407f2291302321e36c6b137369b4d46f62eeb4f Mon Sep 17 00:00:00 2001 From: Thomas Jensen Date: Wed, 24 Mar 2021 16:03:29 +0100 Subject: [PATCH] Support aliases in vim syntax file #30 --- boxes.vim | 76 +++++++++++++++++++++++++++---------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/boxes.vim b/boxes.vim index afcc9c0..7eae733 100644 --- a/boxes.vim +++ b/boxes.vim @@ -12,10 +12,8 @@ " --------------- " Latest version available from: " https://github.com/ascii-boxes/boxes/blob/master/boxes.vim -" Status: This syntax file is still under development (you could say "beta") and has a few known issues (below). -" We think it's good enough to be used in the wild. -" Even though it is not officially part of a boxes release, and simply intended to be downloaded via the link -" above, we think it's great when it gets packaged and installed with boxes! +" Status: This syntax file is not officially part of a boxes release, and simply intended to be downloaded via the link +" above, but we think it's great when it gets packaged and installed with boxes! " Known Issues: " https://github.com/ascii-boxes/boxes/issues?q=is%3Aissue+is%3Aopen+Vim+Syntax " _____________________________________________________________________________________________________________________ @@ -33,27 +31,31 @@ syntax clear syntax case ignore " Set the keyword characters -setlocal iskeyword=a-z,A-Z +syntax iskeyword a-z,A-Z + +" TODO foldlevel - It should be possible to fold box designs +" TODO spell checking - In a boxes config file, only comments should be spell checked. " " Key Words " -syntax keyword boxesClassicKeywords contained author designer revision created revdate tags indent skipwhite skipempty nextgroup=boxesString -syntax keyword boxesBlocks contained elastic replace reverse padding shapes -syntax keyword boxesRegStuff contained with to once global -syntax keyword boxesParent parent skipwhite nextgroup=boxesParentPath,boxesParentGlobal +syntax keyword boxesClassicKeywords author designer revision created revdate tags indent skipwhite skipempty nextgroup=boxesString +syntax keyword boxesBlocks elastic replace reverse padding shapes skipwhite skipempty +syntax keyword boxesRegStuff with to once global skipwhite skipempty +syntax keyword boxesParent parent skipwhite nextgroup=boxesParentPath,boxesParentGlobal +syntax keyword boxesEnd end skipwhite skipempty nextgroup=boxesNameAtEnd " Shape Names -syntax keyword boxesShapes contained nw nnw n nne ne ene e ese -syntax keyword boxesShapes contained se sse s ssw sw wsw w wnw +syntax keyword boxesShapes nw nnw n nne ne ene e ese +syntax keyword boxesShapes se sse s ssw sw wsw w wnw " Padding Areas -syntax keyword boxesPads contained a[ll] l[eft] r[ight] t top -syntax keyword boxesPads contained b[ottom] h[orizontal] v[ertical] +syntax keyword boxesPads a[ll] l[eft] r[ight] t top +syntax keyword boxesPads b[ottom] h[orizontal] v[ertical] " Delimiter statement -syntax keyword boxesDelim contained delim delimiter skipwhite skipempty nextgroup=boxesDelSpec +syntax keyword boxesDelim delim delimiter skipwhite skipempty nextgroup=boxesDelSpec " @@ -65,38 +67,33 @@ syntax match boxesError /\S/ " " Main syntax definition part " -syntax match boxesComma contained /,/ -syntax match boxesBraces contained /[{}]/ -syntax match boxesDelSpec contained /[^ \t\r]\+/ -syntax match boxesWord contained /[a-zA-ZäöüÄÖÜ][a-zA-Z0-9\-_üäöÜÄÖß]*/ -syntax match boxesNumber contained /[-+]\=\d\+/ +syntax match boxesComma contained display /,/ +syntax match boxesBraces display /[{}]/ +" TODO Introduce region between delim and delim|end which exists 361 times to cover all combinations +syntax match boxesDelSpec contained display /[^ \t\r]\+/ +syntax match boxesNameAtEnd display /[a-zA-ZäöüÄÖÜ][a-zA-Z0-9_\-üäöÜÄÖß]*/ skipwhite skipempty +syntax match boxesWord display /[a-zA-ZäöüÄÖÜ][a-zA-Z0-9_\-üäöÜÄÖß]*/ +syntax match boxesNumber display /[-+]\=\d\+/ " a list, used inside shape blocks and for the elastic list -syntax region boxesList contained matchgroup=Normal start="(" end=")" contains=boxesString,boxesShapes,boxesComma,boxesError,boxesComment +syntax region boxesList matchgroup=Normal start="(" end=")" contains=boxesString,boxesShapes,boxesComma,boxesError,boxesComment " Strings -syntax region boxesString contained start=/"/ skip=/\\\\\|\\"/ end=/"/ oneline - - -" These items may appear inside a BOX..END block -syntax cluster boxesInside contains=boxesComment,boxesWord,boxesElasticList -syntax cluster boxesInside add=boxesError,boxesBlocks,boxesSample,boxesDelim -syntax cluster boxesInside add=boxesClassicKeywords,boxesShapeBlk,boxesPadBlock -syntax cluster boxesInside add=boxesRegStuff,boxesShapes,boxesList -syntax cluster boxesInside add=boxesString,boxesPads,boxesNumber,boxesBraces +" TODO the uncontained is normal, and contained ones belong to a delim region +syntax region boxesString display start=/"/ skip=/\\\\\|\\"/ end=/"/ oneline " File path of a 'parent' definition -syntax match boxesParentGlobal "\s:global:\s*$" -syntax match boxesParentPath contained "[^:]\{-}$" - -" The main box design blocks BOX..END -syntax region boxesDesign matchgroup=boxesBoxStmt start="box" skip="ends" end="end" keepend contains=@boxesInside skipwhite skipempty nextgroup=boxesWord +syntax match boxesParentGlobal display "\s:global:\s*$" +syntax match boxesParentPath contained display "[^:]\{-}$" " The SAMPLE block -syntax region boxesSample contained matchgroup=boxesBlocks start="sample" end=+^[ \t]*ends[ \t\r]*$+ keepend contains=NONE +syntax region boxesSample matchgroup=boxesBlocks start="sample" end=+^[ \t]*ends[ \t\r]*$+ keepend + +" a BOX definition with aliases +syntax region boxesNames matchgroup=boxesBoxStmt start=/\[ \t\r\n]\+\