From 8e55c1d34b133612108f25488c37da6abcd249cb Mon Sep 17 00:00:00 2001 From: Todd Lewis Date: Sat, 4 Feb 2017 17:34:44 -0500 Subject: [PATCH 01/11] Fix comment detection. (#23) * Fix comment detection. * Fix spaces after '#' --- yaml.jsf | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/yaml.jsf b/yaml.jsf index ee5024d..350bd82 100644 --- a/yaml.jsf +++ b/yaml.jsf @@ -1,4 +1,5 @@ # JOE syntax highlight file for YAML +# by Christian Nicolai (http://mycrobase.de) =Idle =Comment green @@ -11,7 +12,7 @@ =Directive red =Reference yellow -=LocalType fg_310 # brown +=LocalType blue =BlockDelim bold blue =BadTab inverse red @@ -19,13 +20,18 @@ :line_start Idle * maybe_key noeat "\t" bad_tab recolor=-1 + "#" line_comment recolor=-1 " " line_start +:maybe_idlecomment Comment + * idle noeat + "#" line_comment recolor=-1 + :idle Constant * idle "\n" line_start + " " maybe_idlecomment "%" directive recolor=-1 - "#" line_comment recolor=-1 "'" string_sq_1 recolor=-1 "\"" string_dq_1 recolor=-1 "{[]}" brace recolor=-1 @@ -35,7 +41,8 @@ :maybe_key Idle * maybe_key1 recolor=-1 mark - "\n%#'\"{[]}*&!" idle noeat + "\n" line_start + "%#'\"{[]}*&!" idle noeat "-" maybe_block1 mark :maybe_key1 Constant From 47a1b1a1f02c2a2509663820cf8e116ab2fb2dc3 Mon Sep 17 00:00:00 2001 From: cn Date: Sat, 4 Feb 2017 23:40:52 +0100 Subject: [PATCH 02/11] Document yaml.jsf contributions --- README.md | 1 + yaml.jsf | 15 +++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 46f1251..be1c432 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ Files with contributions (or unclear license info): * [powershell.jsf](https://github.com/cmur2/joe-syntax/blob/master/powershell.jsf) which is entirely contributed by [Oskar Liljeblad](https://github.com/osklil) under GPL v2 or any later version ([comment](https://github.com/cmur2/joe-syntax/pull/5#issuecomment-76935968)) * [puppet.jsf](https://github.com/cmur2/joe-syntax/blob/master/puppet.jsf) which is created by [Christian Nicolai](https://github.com/cmur2) and then modified by [Eric Eisenhart](https://github.com/eeisenhart) * [sql.jsf](https://github.com/cmur2/joe-syntax/blob/master/sql.jsf) which is from an "unknown source" (delivered by [Rebecca Turner](https://github.com/iarna)) +* [yaml.jsf](https://github.com/cmur2/joe-syntax/blob/master/yaml.jsf) which is created by [Christian Nicolai](https://github.com/cmur2) with bug fixes from [Todd Lewis](https://github.com/utoddl) ## Links diff --git a/yaml.jsf b/yaml.jsf index 350bd82..810d9f5 100644 --- a/yaml.jsf +++ b/yaml.jsf @@ -12,7 +12,7 @@ =Directive red =Reference yellow -=LocalType blue +=LocalType fg_310 # brown =BlockDelim bold blue =BadTab inverse red @@ -23,15 +23,11 @@ "#" line_comment recolor=-1 " " line_start -:maybe_idlecomment Comment - * idle noeat - "#" line_comment recolor=-1 - :idle Constant * idle "\n" line_start - " " maybe_idlecomment "%" directive recolor=-1 + " " maybe_line_comment "'" string_sq_1 recolor=-1 "\"" string_dq_1 recolor=-1 "{[]}" brace recolor=-1 @@ -41,8 +37,7 @@ :maybe_key Idle * maybe_key1 recolor=-1 mark - "\n" line_start - "%#'\"{[]}*&!" idle noeat + "\n%#'\"{[]}*&!" idle noeat "-" maybe_block1 mark :maybe_key1 Constant @@ -61,6 +56,10 @@ :bad_tab BadTab * line_start noeat +:maybe_line_comment Comment + * idle noeat + "#" line_comment + :line_comment Comment * line_comment "\n" line_start From a3c24a4c8c2e7beb0c1dec3957940bb07817b2ef Mon Sep 17 00:00:00 2001 From: cn Date: Sat, 4 Feb 2017 23:41:34 +0100 Subject: [PATCH 03/11] New highligher for Dockerfile Very simple parser only recognizing comments and the COMMAND at beginning of a line. --- dockerfile.jsf | 27 +++++++++++++++++++++++++++ ftyperc | 4 ++++ 2 files changed, 31 insertions(+) create mode 100644 dockerfile.jsf diff --git a/dockerfile.jsf b/dockerfile.jsf new file mode 100644 index 0000000..4df3174 --- /dev/null +++ b/dockerfile.jsf @@ -0,0 +1,27 @@ +# JOE syntax highlight file for Dockerfile + +=Idle +=Comment green +=Instruction blue + +:idle Idle + * arguments + "a-zA-Z" instruction noeat + "#" comment recolor=-1 + "\n" idle + +:comment Comment + * comment + "\n" idle + +:instruction Instruction + * instruction + " \t" arguments noeat + +:arguments Idle + * arguments + "\n" idle + "#" comment + + + diff --git a/ftyperc b/ftyperc index 39302ba..777ed1d 100644 --- a/ftyperc +++ b/ftyperc @@ -1033,3 +1033,7 @@ -autoindent -syntax scheme -semi_comment + + Docker +*Dockerfile +-syntax dockerfile From 4a2f8009f2ce9b2f47b9a439024d3c463cf36b74 Mon Sep 17 00:00:00 2001 From: cn Date: Mon, 10 Apr 2017 12:53:50 +0200 Subject: [PATCH 04/11] New highligher for Terraform - primitives like bool, number and string - basic interpolation syntax support - some keywords --- ftyperc | 6 +++ terraform.jsf | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 terraform.jsf diff --git a/ftyperc b/ftyperc index 777ed1d..4a7f284 100644 --- a/ftyperc +++ b/ftyperc @@ -1037,3 +1037,9 @@ Docker *Dockerfile -syntax dockerfile + + Terraform +*.tf +-autoindent +-syntax terraform +-c_comment diff --git a/terraform.jsf b/terraform.jsf new file mode 100644 index 0000000..02ff43f --- /dev/null +++ b/terraform.jsf @@ -0,0 +1,129 @@ +# JOE syntax highlight file for Terraform (or "HashiCorp configuration language") + +=Idle +=Comment green +=CommentLabel bold green +=Constant cyan +=Escape bold cyan +=Bad bold red + +=Keyword fg_310 # brown +=Interpolate magenta +=InterpolateVar bold magenta + +:idle Idle + * idle + "#" line_comment recolor=-1 + "/" maybe_comment + "0-9" number recolor=-1 + "\"" string recolor=-1 + "a-zA-Z_" ident buffer + +:line_comment Comment + * line_comment + "\n" idle + +:maybe_comment Idle + * idle noeat + "*" comment recolor=-2 + +:comment Comment + * comment + # might be TODO label + "BFHNTX" comment noeat call=.comment_todo() + "*" maybe_end_comment + +:maybe_end_comment Comment + * comment noeat + "/" idle + "*" maybe_end_comment + +:number Constant + * idle noeat + "0-9" number + +:string Constant + * string + "$" maybe_interpolate + "\"" idle + +:maybe_interpolate Constant + * idle noeat + "{" interpolate recolor=-2 + +:interpolate Interpolate + * interpolate + "\"" interpolate_string recolor=-1 + "0-9" interpolate_number recolor=-1 + "*" interpolate_star recolor=-1 + "a-zA-Z" interpolate_ident buffer + "}" string + +:interpolate_string Constant + * interpolate_string + "\"" interpolate + +:interpolate_number Constant + * interpolate noeat + "0-9" interpolate_number + +:interpolate_star Constant + * interpolate noeat + +:interpolate_ident Interpolate + * interpolate noeat strings + "count" var + "data" var + "element" func + "module" var + "path" var + "self" var +# "terraform" var + "var" var +done + "a-zA-Z" interpolate_ident + +:var InterpolateVar + * interpolate noeat + +:func InterpolateVar + * interpolate noeat + +:ident Idle + * idle noeat strings + "false" bool + "module" kw + "resource" kw + "true" bool +done + "a-zA-Z_" ident + +:kw Keyword + * idle noeat + +:bool Constant + * idle noeat + +.subr comment_todo +# initial state +:comment_todo_init Comment + * comment_todo_guess buffer + +# highlight common TODO labels +:comment_todo_guess Comment + * comment_todo_unknown noeat strings + "BUG" comment_todo + "FIXME" comment_todo + "HACK" comment_todo + "NOTE" comment_todo + "TODO" comment_todo + "XXX" comment_todo +done + "A-Z" comment_todo_guess + +:comment_todo_unknown Comment + * NULL noeat return + +:comment_todo CommentLabel + * NULL noeat return +.end From c1a644af8be62f68e32e7d59030d37d6dfd0faaf Mon Sep 17 00:00:00 2001 From: cn Date: Wed, 12 Apr 2017 13:45:39 +0200 Subject: [PATCH 05/11] Fix highlighting of comments not starting at beginning of line in Dockerfile --- dockerfile.jsf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerfile.jsf b/dockerfile.jsf index 4df3174..940401b 100644 --- a/dockerfile.jsf +++ b/dockerfile.jsf @@ -21,7 +21,7 @@ :arguments Idle * arguments "\n" idle - "#" comment + "#" comment recolor=-1 From 1c43114a71e03a6099c79dcd16f1fc083c2402b8 Mon Sep 17 00:00:00 2001 From: cn Date: Tue, 18 Apr 2017 21:18:38 +0200 Subject: [PATCH 06/11] Add draft Makefile highlighter --- ftyperc | 10 +++---- makefile.jsf | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 makefile.jsf diff --git a/ftyperc b/ftyperc index 4a7f284..74ea491 100644 --- a/ftyperc +++ b/ftyperc @@ -689,27 +689,27 @@ Makefile *Makefile -autoindent --syntax conf +-syntax makefile -pound_comment *makefile -autoindent --syntax conf +-syntax makefile -pound_comment *Makefile.in -autoindent --syntax conf +-syntax makefile -pound_comment *makefile.in -autoindent --syntax conf +-syntax makefile -pound_comment *MAKEFILE -autoindent --syntax conf +-syntax makefile -pound_comment Pascal diff --git a/makefile.jsf b/makefile.jsf new file mode 100644 index 0000000..0ffdb96 --- /dev/null +++ b/makefile.jsf @@ -0,0 +1,81 @@ +# JOE syntax highlight file for Makefile + +=Idle +=Comment green +=CommentLabel bold green +=Constant cyan +=Escape bold cyan +=Bad bold red + +=BadSpace inverse red +=Variable blue +=Target fg_310 # brown +=TargetRest + +:line_start Idle + * idle noeat + " " bad_space recolor=-1 + "#" line_comment recolor=-1 + "a-zA-Z_" maybe_var_or_target mark + +:idle Idle + * idle + "$" maybe_substitute + "\n" line_start + +:maybe_substitute Idle + * idle noeat + "(" substitute recolor=-2 + +:substitute Constant + * substitute + ")" idle + +:bad_space BadSpace + * line_start noeat + +:line_comment Comment + * line_comment + # might be TODO label + "BFHNTX" comment noeat call=.comment_todo() + "\n" line_start + +:maybe_var_or_target Idle + * idle noeat + "a-zA-Z_-" maybe_var_or_target + "=" variable recolormark + ":" target noeat recolormark + +:variable Variable + * idle noeat + +:target Target + * target_rest + +:target_rest TargetRest + * target_rest + "\n" line_start + +.subr comment_todo +# initial state +:comment_todo_init Comment + * comment_todo_guess buffer + +# highlight common TODO labels +:comment_todo_guess Comment + * comment_todo_unknown noeat strings + "BUG" comment_todo + "FIXME" comment_todo + "HACK" comment_todo + "NOTE" comment_todo + "TODO" comment_todo + "XXX" comment_todo +done + "A-Z" comment_todo_guess + +:comment_todo_unknown Comment + * NULL noeat return + +:comment_todo CommentLabel + * NULL noeat return +.end From edbac0309dd2d069b6b7da438f15a4cfd73e3253 Mon Sep 17 00:00:00 2001 From: cn Date: Wed, 19 Apr 2017 08:54:50 +0200 Subject: [PATCH 07/11] Add terraform functions --- terraform.jsf | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/terraform.jsf b/terraform.jsf index 02ff43f..5758550 100644 --- a/terraform.jsf +++ b/terraform.jsf @@ -72,14 +72,54 @@ :interpolate_ident Interpolate * interpolate noeat strings + "basename" func + "ceil" func + "chomp" func + "cidrhost" func + "cidrnetmask" func + "cidrsubnet" func + "coalesce" func + "compact" func + "concat" func "count" var "data" var + "dirname" func + "distinct" func "element" func + "file" func + "floor" func + "format" func + "formatlist" func + "index" func + "join" func + "keys" func + "length" func + "list" func + "lookup" func + "lower" func + "map" func + "max" func + "merge" func + "min" func "module" var "path" var + "pathexpand" func + "replace" func "self" var + "signum" func + "slice" func + "sort" func + "split" func + "substr" func # "terraform" var + "timestamp" func + "title" func + "trimspace" func + "upper" func + "uuid" func + "values" func "var" var + "zipmap" func done "a-zA-Z" interpolate_ident From 4d940dd75a28bdf3a29210cbacacbf20952caeef Mon Sep 17 00:00:00 2001 From: cn Date: Thu, 20 Apr 2017 16:52:32 +0200 Subject: [PATCH 08/11] Fix bug in Makefiles --- makefile.jsf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefile.jsf b/makefile.jsf index 0ffdb96..0b65474 100644 --- a/makefile.jsf +++ b/makefile.jsf @@ -37,7 +37,7 @@ :line_comment Comment * line_comment # might be TODO label - "BFHNTX" comment noeat call=.comment_todo() + "BFHNTX" line_comment noeat call=.comment_todo() "\n" line_start :maybe_var_or_target Idle From 854a1893eb382a1208ea379bc6f692ca4df9f594 Mon Sep 17 00:00:00 2001 From: cn Date: Wed, 26 Apr 2017 10:48:14 +0200 Subject: [PATCH 09/11] Improve makefile highlighter --- makefile.jsf | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/makefile.jsf b/makefile.jsf index 0b65474..e0db23f 100644 --- a/makefile.jsf +++ b/makefile.jsf @@ -7,16 +7,16 @@ =Escape bold cyan =Bad bold red -=BadSpace inverse red -=Variable blue -=Target fg_310 # brown +=RecipeCont bold cyan +=TargetPhony yellow +=TargetOther fg_310 # brown =TargetRest :line_start Idle * idle noeat - " " bad_space recolor=-1 "#" line_comment recolor=-1 - "a-zA-Z_" maybe_var_or_target mark + "a-zA-Z._" maybe_target mark buffer + "\t" recipe :idle Idle * idle @@ -31,8 +31,23 @@ * substitute ")" idle -:bad_space BadSpace - * line_start noeat +:recipe Idle + * recipe + "$" maybe_r_substitute + "\\" recipe_cont recolor=-1 + "\n" line_start + +:recipe_cont RecipeCont + * recipe noeat + "\n" recipe + +:maybe_r_substitute Idle + * recipe noeat + "(" r_substitute recolor=-2 + +:r_substitute Constant + * r_substitute + ")" recipe :line_comment Comment * line_comment @@ -40,17 +55,18 @@ "BFHNTX" line_comment noeat call=.comment_todo() "\n" line_start -:maybe_var_or_target Idle +:maybe_target Idle * idle noeat - "a-zA-Z_-" maybe_var_or_target - "=" variable recolormark - ":" target noeat recolormark + ":" target_other noeat recolormark strings + ".PHONY" target_phony +done + "a-zA-Z._-" maybe_target -:variable Variable - * idle noeat +:target_phony TargetPhony + * target_rest noeat -:target Target - * target_rest +:target_other TargetOther + * target_rest noeat :target_rest TargetRest * target_rest From d35bc8d3d55e347d4725de5e7b8cc33bcb4e65d3 Mon Sep 17 00:00:00 2001 From: Todd Lewis Date: Thu, 4 May 2017 20:13:50 -0400 Subject: [PATCH 10/11] yaml: handle plain strings w/ non-initial quotes --- yaml.jsf | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/yaml.jsf b/yaml.jsf index 810d9f5..0ebe7e0 100644 --- a/yaml.jsf +++ b/yaml.jsf @@ -23,11 +23,15 @@ "#" line_comment recolor=-1 " " line_start +:maybe_idlecomment Comment + * idle noeat + "#" line_comment recolor=-1 + :idle Constant - * idle + * plain_scalar noeat "\n" line_start + " " maybe_idlecomment "%" directive recolor=-1 - " " maybe_line_comment "'" string_sq_1 recolor=-1 "\"" string_dq_1 recolor=-1 "{[]}" brace recolor=-1 @@ -35,9 +39,15 @@ "*&" maybe_reference "!" maybe_typecast +:plain_scalar Constant + * plain_scalar + "\t" bad_tab recolor=-1 + "\n" line_start noeat + :maybe_key Idle * maybe_key1 recolor=-1 mark - "\n%#'\"{[]}*&!" idle noeat + "\n" line_start + "%#'\"{[]}*&!" idle noeat "-" maybe_block1 mark :maybe_key1 Constant @@ -56,10 +66,6 @@ :bad_tab BadTab * line_start noeat -:maybe_line_comment Comment - * idle noeat - "#" line_comment - :line_comment Comment * line_comment "\n" line_start From 44616813ea32f7eba163b08d30c16b81ebebfd7c Mon Sep 17 00:00:00 2001 From: Todd Lewis Date: Sun, 7 May 2017 20:48:58 -0400 Subject: [PATCH 11/11] handle comment in plain scalars --- yaml.jsf | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/yaml.jsf b/yaml.jsf index 0ebe7e0..9d88635 100644 --- a/yaml.jsf +++ b/yaml.jsf @@ -23,15 +23,11 @@ "#" line_comment recolor=-1 " " line_start -:maybe_idlecomment Comment - * idle noeat - "#" line_comment recolor=-1 - :idle Constant * plain_scalar noeat "\n" line_start - " " maybe_idlecomment "%" directive recolor=-1 + " " maybe_idle_comment "'" string_sq_1 recolor=-1 "\"" string_dq_1 recolor=-1 "{[]}" brace recolor=-1 @@ -43,6 +39,7 @@ * plain_scalar "\t" bad_tab recolor=-1 "\n" line_start noeat + " " maybe_plain_scalar_comment :maybe_key Idle * maybe_key1 recolor=-1 mark @@ -66,6 +63,14 @@ :bad_tab BadTab * line_start noeat +:maybe_plain_scalar_comment Comment + * plain_scalar noeat + "#" line_comment + +:maybe_idle_comment Comment + * idle noeat + "#" line_comment + :line_comment Comment * line_comment "\n" line_start