From 5d7967cd46991fb44f5909e307c402801cd5f539 Mon Sep 17 00:00:00 2001 From: Jomy10 Date: Sat, 3 Dec 2022 17:27:37 +0100 Subject: [PATCH 1/4] added syntax highlighting support for C --- .gitignore | 1 + languages.toml | 12 +++++ runtime/queries/crystal/highlights.scm | 74 ++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 runtime/queries/crystal/highlights.scm diff --git a/.gitignore b/.gitignore index 6a6fc782a827..19e3acc2934d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +**/.DS_Store # macOS target .direnv helix-term/rustfmt.toml diff --git a/languages.toml b/languages.toml index 756315cd6924..f89b60163a3d 100644 --- a/languages.toml +++ b/languages.toml @@ -223,6 +223,18 @@ args = { console = "internalConsole", attachCommands = [ "platform select remote name = "cpp" source = { git = "https://github.com/tree-sitter/tree-sitter-cpp", rev = "d5e90fba898f320db48d81ddedd78d52c67c1fed" } +[[language]] +name = "crystal" +scope = "source.cr" +file-types = ["cr"] +roots = ["shard.yml", "shard.lock"] +comment-token = "#" +indent = { tab-width = 2, unit = " " } + +[[grammar]] +name = "crystal" +source = { git = "https://github.com/will/tree-sitter-crystal", rev = "15597b307b18028b04d288561f9c29794621562b" } + [[language]] name = "c-sharp" scope = "source.csharp" diff --git a/runtime/queries/crystal/highlights.scm b/runtime/queries/crystal/highlights.scm new file mode 100644 index 000000000000..1e98177d0cd8 --- /dev/null +++ b/runtime/queries/crystal/highlights.scm @@ -0,0 +1,74 @@ +[ + "class" + "struct" + "module" + + "def" + "alias" + "do" + "end" + + "require" + "include" + "extend" +] @keyword + +[ + "[" "]" + "(" ")" + "{" "}" +] @punctuation.bracket + +(operator) @operator + +(comment) @comment + +; literals + +[ + (nil) + (bool) +] @constant.builtin + +[ + (integer) + (float) +] @number + +[ + (string) + (char) + (commandLiteral) +] @string + +(symbol) @string.special.symbol + +(regex) @string.special.regex + +; variables + +[ + (local_variable) +] @variable + +[ + (instance_variable) + (class_variable) +] @property + +(constant) @constant + +; type defintitions + +(type_identifier) @constructor + +; method definition/call +(identifier) @function.method + +; types +(generic_type) @type +(union_type) @type +(type_identifier) @type + + +(local_variable) @variable.local From b3cac4381067db41b116e10f510f21f129e00b7c Mon Sep 17 00:00:00 2001 From: Jomy10 Date: Sat, 10 Dec 2022 22:45:12 +0100 Subject: [PATCH 2/4] correct query names for Crystal --- .gitignore | 1 - runtime/queries/crystal/highlights.scm | 16 ++++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 19e3acc2934d..6a6fc782a827 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -**/.DS_Store # macOS target .direnv helix-term/rustfmt.toml diff --git a/runtime/queries/crystal/highlights.scm b/runtime/queries/crystal/highlights.scm index 1e98177d0cd8..346030068b7f 100644 --- a/runtime/queries/crystal/highlights.scm +++ b/runtime/queries/crystal/highlights.scm @@ -25,15 +25,11 @@ ; literals -[ - (nil) - (bool) -] @constant.builtin +(nil) @constant.builtin +(bool) @constant.builtin.boolean -[ - (integer) - (float) -] @number +(integer) @constant.numeric.integer +(float) @constant.numeric.float [ (string) @@ -54,7 +50,7 @@ [ (instance_variable) (class_variable) -] @property +] @variable.other.member (constant) @constant @@ -71,4 +67,4 @@ (type_identifier) @type -(local_variable) @variable.local +(local_variable) @variable From 6d820f4315946763f2a42a05ff1f72f9f74ea94a Mon Sep 17 00:00:00 2001 From: Jomy10 Date: Sat, 10 Dec 2022 22:52:24 +0100 Subject: [PATCH 3/4] docgen for Crystal --- 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 b1fde0016abb..4f6acd918435 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -14,6 +14,7 @@ | comment | ✓ | | | | | cpon | ✓ | | ✓ | | | cpp | ✓ | ✓ | ✓ | `clangd` | +| crystal | ✓ | | | | | css | ✓ | | | `vscode-css-language-server` | | cue | ✓ | | | `cuelsp` | | d | ✓ | ✓ | ✓ | `serve-d` | From 4dee20f5ea7491b619def1cfab632c97c916649b Mon Sep 17 00:00:00 2001 From: Jomy10 Date: Sat, 17 Dec 2022 12:30:44 +0100 Subject: [PATCH 4/4] changed indent style and removed duplicate query --- languages.toml | 2 +- runtime/queries/crystal/highlights.scm | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/languages.toml b/languages.toml index be956ac6af32..4135539c907f 100644 --- a/languages.toml +++ b/languages.toml @@ -229,7 +229,7 @@ scope = "source.cr" file-types = ["cr"] roots = ["shard.yml", "shard.lock"] comment-token = "#" -indent = { tab-width = 2, unit = " " } +indent = { tab-width = 2, unit = " " } [[grammar]] name = "crystal" diff --git a/runtime/queries/crystal/highlights.scm b/runtime/queries/crystal/highlights.scm index 346030068b7f..33a53e7f94cb 100644 --- a/runtime/queries/crystal/highlights.scm +++ b/runtime/queries/crystal/highlights.scm @@ -43,9 +43,7 @@ ; variables -[ - (local_variable) -] @variable +(local_variable) @variable [ (instance_variable) @@ -66,5 +64,3 @@ (union_type) @type (type_identifier) @type - -(local_variable) @variable