From 39bf20a0501b7312f0f95b0faf4d5a951eba0ad3 Mon Sep 17 00:00:00 2001 From: farwyler <1705805+farwyler@users.noreply.github.com> Date: Mon, 6 Jun 2022 07:07:20 +0200 Subject: [PATCH 1/9] adds support for openscad --- languages.toml | 15 ++++++++ runtime/queries/openscad/highlights.scm | 51 +++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 runtime/queries/openscad/highlights.scm diff --git a/languages.toml b/languages.toml index 1f42ddcc0049..11f8a60957f9 100644 --- a/languages.toml +++ b/languages.toml @@ -1433,3 +1433,18 @@ indent = { tab-width = 2, unit = " " } [[grammar]] name = "jsdoc" source = { git = "https://github.com/tree-sitter/tree-sitter-jsdoc", rev = "189a6a4829beb9cdbe837260653b4a3dfb0cc3db" } + + +[[language]] +name = "openscad" +scope = "source.openscad" +injection-regex = "openscad" +file-types = ["scad"] +roots = [] +comment-token = "//" +language-server = { command = "openscad-language-server" } +indent = { tab-width = 2, unit = " " } + +[[grammar]] +name = "openscad" +source = { git = "https://github.com/bollian/tree-sitter-openscad", rev = "5c3ce93df0ac1da7197cf6ae125aade26d6b8972" } diff --git a/runtime/queries/openscad/highlights.scm b/runtime/queries/openscad/highlights.scm new file mode 100644 index 000000000000..c8bbdbf65540 --- /dev/null +++ b/runtime/queries/openscad/highlights.scm @@ -0,0 +1,51 @@ +(number) @number +(string) @string +(boolean) @constant.builtin +(include_path) @string + +(function_call function: (identifier) @function) +(module_call name: (identifier) @function) + +(identifier) @variable +(special_variable) @variable.builtin + +[ + "module" + "function" + "for" + "intersection_for" + "if" + "let" + "assign" + "use" + "include" + "each" +] @keyword + +[ + "||" + "&&" + "==" + "!=" + "<" + ">" + "<=" + ">=" + "+" + "-" + "*" + "/" + "%" + "^" + "?" + "!" + ":" +] @operator + +[ + ";" + "," + "." +] @delimeter + +(comment) @comment \ No newline at end of file From 56327122b2107c67a5a6faf1e9e787a55c8b539f Mon Sep 17 00:00:00 2001 From: farwyler <1705805+farwyler@users.noreply.github.com> Date: Mon, 6 Jun 2022 07:45:55 +0200 Subject: [PATCH 2/9] adds scad to generated docs --- book/src/generated/lang-support.md | 1 + 1 file changed, 1 insertion(+) diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index aa9fc1417eab..1d9b89a40777 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -63,6 +63,7 @@ | ocaml | ✓ | | ✓ | `ocamllsp` | | ocaml-interface | ✓ | | | `ocamllsp` | | odin | ✓ | | | | +| openscad | ✓ | | | `openscad-language-server` | | org | ✓ | | | | | perl | ✓ | ✓ | ✓ | | | php | ✓ | ✓ | ✓ | `intelephense` | From a06d38a9a722dd362bdcc14dd805857558b29d80 Mon Sep 17 00:00:00 2001 From: farwyler <1705805+farwyler@users.noreply.github.com> Date: Mon, 6 Jun 2022 16:01:45 +0200 Subject: [PATCH 3/9] rename/split openscad scopes for helix --- runtime/queries/openscad/highlights.scm | 27 ++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/runtime/queries/openscad/highlights.scm b/runtime/queries/openscad/highlights.scm index c8bbdbf65540..a7de1b4ab28e 100644 --- a/runtime/queries/openscad/highlights.scm +++ b/runtime/queries/openscad/highlights.scm @@ -1,6 +1,6 @@ -(number) @number -(string) @string -(boolean) @constant.builtin +(number) @constant.number +(string) @constant.string +(boolean) @constant.builtin.boolean (include_path) @string (function_call function: (identifier) @function) @@ -10,17 +10,26 @@ (special_variable) @variable.builtin [ - "module" "function" + "let" + "assign" +] @keyword + +[ "for" + "each" "intersection_for" +] @keyword.control.repeat + +[ "if" - "let" - "assign" +] @keyword.control.conditional + +[ + "module" "use" "include" - "each" -] @keyword +] @keyword.control.import [ "||" @@ -46,6 +55,6 @@ ";" "," "." -] @delimeter +] @punctuation.delimeter (comment) @comment \ No newline at end of file From 97f6eaeb75d2aab52fbc23b6319b372454b5112f Mon Sep 17 00:00:00 2001 From: farwyler <1705805+farwyler@users.noreply.github.com> Date: Mon, 6 Jun 2022 18:04:35 +0200 Subject: [PATCH 4/9] Update runtime/queries/openscad/highlights.scm Co-authored-by: Michael Davis --- runtime/queries/openscad/highlights.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/queries/openscad/highlights.scm b/runtime/queries/openscad/highlights.scm index a7de1b4ab28e..0bb2726c5664 100644 --- a/runtime/queries/openscad/highlights.scm +++ b/runtime/queries/openscad/highlights.scm @@ -55,6 +55,6 @@ ";" "," "." -] @punctuation.delimeter +] @punctuation.delimiter (comment) @comment \ No newline at end of file From a347200c6667bd79b9af85221d8b5aa3537c27b7 Mon Sep 17 00:00:00 2001 From: farwyler <1705805+farwyler@users.noreply.github.com> Date: Mon, 6 Jun 2022 18:04:42 +0200 Subject: [PATCH 5/9] Update runtime/queries/openscad/highlights.scm Co-authored-by: Michael Davis --- runtime/queries/openscad/highlights.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/queries/openscad/highlights.scm b/runtime/queries/openscad/highlights.scm index 0bb2726c5664..0988b790c419 100644 --- a/runtime/queries/openscad/highlights.scm +++ b/runtime/queries/openscad/highlights.scm @@ -1,5 +1,5 @@ (number) @constant.number -(string) @constant.string +(string) @string (boolean) @constant.builtin.boolean (include_path) @string From 1af362fe2a773b49ae7f36f7da0ac54bc54807b5 Mon Sep 17 00:00:00 2001 From: farwyler <1705805+farwyler@users.noreply.github.com> Date: Mon, 6 Jun 2022 18:06:25 +0200 Subject: [PATCH 6/9] Update runtime/queries/openscad/highlights.scm Co-authored-by: Michael Davis --- runtime/queries/openscad/highlights.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/queries/openscad/highlights.scm b/runtime/queries/openscad/highlights.scm index 0988b790c419..c67543210542 100644 --- a/runtime/queries/openscad/highlights.scm +++ b/runtime/queries/openscad/highlights.scm @@ -1,4 +1,4 @@ -(number) @constant.number +(number) @constant.numeric (string) @string (boolean) @constant.builtin.boolean (include_path) @string From 11607b1fa0e0035d9ef1df7f5083683314857751 Mon Sep 17 00:00:00 2001 From: farwyler <1705805+farwyler@users.noreply.github.com> Date: Mon, 6 Jun 2022 18:07:33 +0200 Subject: [PATCH 7/9] openscad highlights suggestions --- runtime/queries/openscad/highlights.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/queries/openscad/highlights.scm b/runtime/queries/openscad/highlights.scm index c67543210542..30fadc09a1f8 100644 --- a/runtime/queries/openscad/highlights.scm +++ b/runtime/queries/openscad/highlights.scm @@ -1,7 +1,7 @@ (number) @constant.numeric (string) @string (boolean) @constant.builtin.boolean -(include_path) @string +(include_path) @string.special.path (function_call function: (identifier) @function) (module_call name: (identifier) @function) From bfe49b2c9a99b301bdbfff3d6d67fd386457c864 Mon Sep 17 00:00:00 2001 From: farwyler <1705805+farwyler@users.noreply.github.com> Date: Mon, 6 Jun 2022 19:11:33 +0200 Subject: [PATCH 8/9] use tabs for openscad Co-authored-by: Michael Davis --- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages.toml b/languages.toml index 11f8a60957f9..7ab8ff84507a 100644 --- a/languages.toml +++ b/languages.toml @@ -1443,7 +1443,7 @@ file-types = ["scad"] roots = [] comment-token = "//" language-server = { command = "openscad-language-server" } -indent = { tab-width = 2, unit = " " } +indent = { tab-width = 2, unit = "\t" } [[grammar]] name = "openscad" From f2ff715d5d0a8a62ff08738105050f89362b9f09 Mon Sep 17 00:00:00 2001 From: farwyler <1705805+farwyler@users.noreply.github.com> Date: Mon, 6 Jun 2022 19:12:04 +0200 Subject: [PATCH 9/9] adds more function captures for openscad syntax --- runtime/queries/openscad/highlights.scm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/runtime/queries/openscad/highlights.scm b/runtime/queries/openscad/highlights.scm index 30fadc09a1f8..c06738e855e9 100644 --- a/runtime/queries/openscad/highlights.scm +++ b/runtime/queries/openscad/highlights.scm @@ -3,6 +3,9 @@ (boolean) @constant.builtin.boolean (include_path) @string.special.path +(parameters_declaration (identifier) @variable.parameter) +(function_declaration name: (identifier) @function) + (function_call function: (identifier) @function) (module_call name: (identifier) @function)