zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH 1/3] Add Vim highlighting file for Test/*.ztst files.
@ 2019-12-21 11:43 Daniel Shahaf
  2019-12-21 11:43 ` [PATCH 2/3] ztst.vim: Conceal the '>' or '?' on pattern expected output / expected errput lines Daniel Shahaf
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Daniel Shahaf @ 2019-12-21 11:43 UTC (permalink / raw)
  To: zsh-workers

---
 Test/B01cd.ztst |  2 ++
 Test/ztst.vim   | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Util/zyodl.vim  |  5 +++-
 3 files changed, 78 insertions(+), 1 deletion(-)
 create mode 100644 Test/ztst.vim

diff --git a/Test/B01cd.ztst b/Test/B01cd.ztst
index 8d4f0955c..50c14b496 100644
--- a/Test/B01cd.ztst
+++ b/Test/B01cd.ztst
@@ -105,6 +105,8 @@
 #   is to be skipped.
 # ZTST_skip: Set this in any test case if that single test case is to be
 #   skipped.  Testing resumes at the next test case in the same file.
+#
+# Syntax highlighting for Vim is available, see Test/ztst.vim.
  cd cdtst.tmp/sub/fake &&
  pwd &&
  print $PWD
diff --git a/Test/ztst.vim b/Test/ztst.vim
new file mode 100644
index 000000000..3c9e0e173
--- /dev/null
+++ b/Test/ztst.vim
@@ -0,0 +1,72 @@
+"" A Vim syntax highlighting file for Test/*.ztst
+"
+" See ../Util/zyodl.vim for installation instructions
+" See B01cd.ztst for cases we cover
+
+" TODO: Some zsh syntax isn't highlighted, e.g., «{ cd $0 }» doesn't highlight either 'cd' or '$0'
+"   Apparently because the $VIMRUNTIME/syntax/zsh.vim zshBrackets group is defined as 'contains=TOP'?
+"   https://bugs.debian.org/947120
+" TODO: ZTST_unimplemented ZTST_skip aren't recognized everywhere
+"   I haven't found yet a legitimate use where they aren't highlighted, but
+"   they aren't highlighted in theoretical cases such as (( ++ZTST_skip )).
+"   (This example is theoretical because those variables are string-typed.)
+" TODO: for glob-like output/errput lines, conceal the '>' or '?' to align them with adjacent lines.
+
+"" Boilerplate:
+if exists("b:current_syntax")
+  finish
+endif
+let s:cpo_save = &cpo
+set cpo&vim
+
+"" Syntax groups:
+syn clear
+
+syn include @zsh                   syntax/zsh.vim
+
+syn match  ztstPayload             /^\s\+\zs.*/ contains=@zsh
+
+syn match  ztstExitCode            /^\d\+\|^-/                nextgroup=ztstFlags
+syn match  ztstFlags               /[.dDq]*:/       contained nextgroup=ztstTestName contains=ztstColon
+syn match  ztstColon               /:/              contained
+syn region ztstTestName            start=// end=/$/ contained 
+
+syn match  ztstInputMarker         /^</                       nextgroup=ztstInput
+syn region ztstInput               start=// end=/$/ contained
+syn match  ztstOutputMarker        /^[*]\?>/                  nextgroup=ztstOutput   contains=ztstPatternMarker
+syn region ztstOutput              start=// end=/$/ contained
+syn match  ztstErrputMarker        /^[*]\??/                  nextgroup=ztstErrput   contains=ztstPatternMarker
+syn region ztstErrput              start=// end=/$/ contained
+syn match  ztstPatternMarker       /[*]/            contained
+
+syn match  ztstFrequentExplanationMarker /^F:/                nextgroup=ztstFrequentExplanation
+syn region ztstFrequentExplanation start=// end=/$/ contained
+
+syn match  ztstDirective           /^%.*/
+
+syn match  ztstComment             /^#.*/
+
+syn keyword ztstSpecialVariable ZTST_unimplemented ZTST_skip ZTST_testdir containedin=@zsh 
+
+"" Highlight groups:
+hi def link ztstExitCode                  Number
+hi def link ztstFlags                     Normal
+hi def link ztstColon                     Ignore
+hi def link ztstTestName                  Title
+hi def link ztstInput                     Normal
+hi def link ztstInputMarker               Ignore
+hi def link ztstOutput                    String
+hi def link ztstOutputMarker              Ignore
+hi def link ztstErrput                    Identifier
+hi def link ztstErrputMarker              Ignore
+hi def link ztstDirective                 Statement
+hi def link ztstPatternMarker             Type
+hi def link ztstComment                   Comment
+hi def link ztstFrequentExplanation       PreProc
+hi def link ztstFrequentExplanationMarker Ignore
+hi def link ztstSpecialVariable           Underlined
+
+"" Boilerplate:
+let b:current_syntax = "ztst"
+let &cpo = s:cpo_save
+unlet s:cpo_save
diff --git a/Util/zyodl.vim b/Util/zyodl.vim
index d0d3cf54f..7bde946c1 100644
--- a/Util/zyodl.vim
+++ b/Util/zyodl.vim
@@ -35,6 +35,8 @@
 if exists("b:current_syntax")
   finish
 endif
+let s:cpo_save = &cpo
+set cpo&vim
 
 "" Syntax groups:
 syn clear
@@ -80,4 +82,5 @@ hi def link zyodlSItemArg1 Macro
 hi def link zyodlSItemArg2 Underlined
 
 let b:current_syntax = "zyodl"
-
+let &cpo = s:cpo_save
+unlet s:cpo_save

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/3] ztst.vim: Conceal the '>' or '?' on pattern expected output / expected errput lines.
  2019-12-21 11:43 [PATCH 1/3] Add Vim highlighting file for Test/*.ztst files Daniel Shahaf
@ 2019-12-21 11:43 ` Daniel Shahaf
  2019-12-21 11:43 ` [PATCH 3/3] ztst.vim: Highlight some more special variables Daniel Shahaf
  2019-12-21 17:42 ` [PATCH 1/3] Add Vim highlighting file for Test/*.ztst files Bart Schaefer
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Shahaf @ 2019-12-21 11:43 UTC (permalink / raw)
  To: zsh-workers

This aligns the expectations given by '*>' and '>' lines.
---
 Test/ztst.vim | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/Test/ztst.vim b/Test/ztst.vim
index 3c9e0e173..842564de2 100644
--- a/Test/ztst.vim
+++ b/Test/ztst.vim
@@ -1,6 +1,8 @@
 "" A Vim syntax highlighting file for Test/*.ztst
 "
-" See ../Util/zyodl.vim for installation instructions
+" See ../Util/zyodl.vim for installation instructions.
+" Also, it's recommended to 'setlocal conceallevel=3 concealcursor=nc'.
+"
 " See B01cd.ztst for cases we cover
 
 " TODO: Some zsh syntax isn't highlighted, e.g., «{ cd $0 }» doesn't highlight either 'cd' or '$0'
@@ -10,7 +12,6 @@
 "   I haven't found yet a legitimate use where they aren't highlighted, but
 "   they aren't highlighted in theoretical cases such as (( ++ZTST_skip )).
 "   (This example is theoretical because those variables are string-typed.)
-" TODO: for glob-like output/errput lines, conceal the '>' or '?' to align them with adjacent lines.
 
 "" Boilerplate:
 if exists("b:current_syntax")
@@ -33,11 +34,18 @@ syn region ztstTestName            start=// end=/$/ contained
 
 syn match  ztstInputMarker         /^</                       nextgroup=ztstInput
 syn region ztstInput               start=// end=/$/ contained
-syn match  ztstOutputMarker        /^[*]\?>/                  nextgroup=ztstOutput   contains=ztstPatternMarker
+
+syn match  ztstOutputPattern       /^[*]>/                    nextgroup=ztstOutput   contains=ztstOutputPatternSigil,ztstOutputPatternMarker
+syn match  ztstOutputPatternSigil  /[*]/            contained
+syn match  ztstOutputPatternMarker /[>]/            contained conceal
+syn match  ztstOutputLiteral       /^>/                       nextgroup=ztstOutput
 syn region ztstOutput              start=// end=/$/ contained
-syn match  ztstErrputMarker        /^[*]\??/                  nextgroup=ztstErrput   contains=ztstPatternMarker
+
+syn match  ztstErrputPattern       /^[*][?]/                  nextgroup=ztstErrput   contains=ztstErrputPatternSigil,ztstErrputPatternMarker
+syn match  ztstErrputPatternSigil  /[*]/            contained
+syn match  ztstErrputPatternMarker /[?]/            contained conceal
+syn match  ztstErrputLiteral       /^[?]/                     nextgroup=ztstErrput
 syn region ztstErrput              start=// end=/$/ contained
-syn match  ztstPatternMarker       /[*]/            contained
 
 syn match  ztstFrequentExplanationMarker /^F:/                nextgroup=ztstFrequentExplanation
 syn region ztstFrequentExplanation start=// end=/$/ contained
@@ -56,11 +64,14 @@ hi def link ztstTestName                  Title
 hi def link ztstInput                     Normal
 hi def link ztstInputMarker               Ignore
 hi def link ztstOutput                    String
-hi def link ztstOutputMarker              Ignore
+hi def link ztstOutputPatternSigil        Type
+hi def link ztstOutputPatternMarker       Ignore
+hi def link ztstOutputLiteral             Ignore
 hi def link ztstErrput                    Identifier
-hi def link ztstErrputMarker              Ignore
+hi def link ztstErrputPatternSigil        Type
+hi def link ztstErrputPatternMarker       Ignore
+hi def link ztstErrputLiteral             Ignore
 hi def link ztstDirective                 Statement
-hi def link ztstPatternMarker             Type
 hi def link ztstComment                   Comment
 hi def link ztstFrequentExplanation       PreProc
 hi def link ztstFrequentExplanationMarker Ignore

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/3] ztst.vim: Highlight some more special variables
  2019-12-21 11:43 [PATCH 1/3] Add Vim highlighting file for Test/*.ztst files Daniel Shahaf
  2019-12-21 11:43 ` [PATCH 2/3] ztst.vim: Conceal the '>' or '?' on pattern expected output / expected errput lines Daniel Shahaf
@ 2019-12-21 11:43 ` Daniel Shahaf
  2019-12-21 17:42 ` [PATCH 1/3] Add Vim highlighting file for Test/*.ztst files Bart Schaefer
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Shahaf @ 2019-12-21 11:43 UTC (permalink / raw)
  To: zsh-workers

---
 Test/ztst.vim | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Test/ztst.vim b/Test/ztst.vim
index 842564de2..8d8becfe7 100644
--- a/Test/ztst.vim
+++ b/Test/ztst.vim
@@ -54,7 +54,9 @@ syn match  ztstDirective           /^%.*/
 
 syn match  ztstComment             /^#.*/
 
-syn keyword ztstSpecialVariable ZTST_unimplemented ZTST_skip ZTST_testdir containedin=@zsh 
+" Highlight those variables which are /de jure/ or /de facto/ APIs of the test
+" harness to the test files.
+syn keyword ztstSpecialVariable ZTST_unimplemented ZTST_skip ZTST_testdir ZTST_fd ZTST_srcdir containedin=@zsh 
 
 "" Highlight groups:
 hi def link ztstExitCode                  Number

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/3] Add Vim highlighting file for Test/*.ztst files.
  2019-12-21 11:43 [PATCH 1/3] Add Vim highlighting file for Test/*.ztst files Daniel Shahaf
  2019-12-21 11:43 ` [PATCH 2/3] ztst.vim: Conceal the '>' or '?' on pattern expected output / expected errput lines Daniel Shahaf
  2019-12-21 11:43 ` [PATCH 3/3] ztst.vim: Highlight some more special variables Daniel Shahaf
@ 2019-12-21 17:42 ` Bart Schaefer
  2 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2019-12-21 17:42 UTC (permalink / raw)
  To: Daniel Shahaf; +Cc: zsh-workers

Somewhere I have a yodl-mode.el for emacs.  I can try to dig it up if
there is interest.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-12-21 21:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-21 11:43 [PATCH 1/3] Add Vim highlighting file for Test/*.ztst files Daniel Shahaf
2019-12-21 11:43 ` [PATCH 2/3] ztst.vim: Conceal the '>' or '?' on pattern expected output / expected errput lines Daniel Shahaf
2019-12-21 11:43 ` [PATCH 3/3] ztst.vim: Highlight some more special variables Daniel Shahaf
2019-12-21 17:42 ` [PATCH 1/3] Add Vim highlighting file for Test/*.ztst files Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).