From 49e067874133e12d10ad3ac0c941438e2d7025e7 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Wed, 15 Dec 2021 00:45:38 +0900 Subject: Add markdown grammar Fixes #215 --- helix-syntax/languages/tree-sitter-markdown | 1 + 1 file changed, 1 insertion(+) create mode 160000 helix-syntax/languages/tree-sitter-markdown (limited to 'helix-syntax/languages') diff --git a/helix-syntax/languages/tree-sitter-markdown b/helix-syntax/languages/tree-sitter-markdown new file mode 160000 index 00000000..ad8c3291 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-markdown @@ -0,0 +1 @@ +Subproject commit ad8c32917a16dfbb387d1da567bf0c3fb6fffde2 -- cgit v1.2.3-70-g09d2 From 0683f0a20ae1c1ce3e7788e303c468767381e6fd Mon Sep 17 00:00:00 2001 From: Oliver Hechtl Date: Sat, 18 Dec 2021 05:40:34 +0100 Subject: Add scala syntax highlights (#1278) * add partial scala syntax highlights * ran cargo xtask docgen * updated tree-sitter-scala, fixed highlights * fix comments * move identifier to the end of the highlights * add indents--- book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-scala | 2 +- languages.toml | 9 ++ runtime/queries/scala/highlights.scm | 203 +++++++++++++++++++++++++++++++ runtime/queries/scala/indents.toml | 23 ++++ runtime/queries/scala/injections.scm | 1 + 6 files changed, 238 insertions(+), 1 deletion(-) create mode 100644 runtime/queries/scala/highlights.scm create mode 100644 runtime/queries/scala/indents.toml create mode 100644 runtime/queries/scala/injections.scm (limited to 'helix-syntax/languages') diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 80989e63..b7babd8c 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -31,6 +31,7 @@ | racket | | | | `racket` | | ruby | ✓ | | | `solargraph` | | rust | ✓ | ✓ | ✓ | `rust-analyzer` | +| scala | ✓ | | | `metals` | | svelte | ✓ | | ✓ | `svelteserver` | | toml | ✓ | | | | | tsq | ✓ | | | | diff --git a/helix-syntax/languages/tree-sitter-scala b/helix-syntax/languages/tree-sitter-scala index fb23ed9a..0a3dd53a 160000 --- a/helix-syntax/languages/tree-sitter-scala +++ b/helix-syntax/languages/tree-sitter-scala @@ -1 +1 @@ -Subproject commit fb23ed9a99da012d86b7a5059b9d8928607cce29 +Subproject commit 0a3dd53a7fc4b352a538397d054380aaa28be54c diff --git a/languages.toml b/languages.toml index abb94acf..88882f3e 100644 --- a/languages.toml +++ b/languages.toml @@ -430,3 +430,12 @@ file-types = ["md"] roots = [] indent = { tab-width = 2, unit = " " } + +[[language]] +name = "scala" +scope = "source.scala" +roots = ["build.sbt"] +file-types = ["scala", "sbt"] +comment-token = "//" +indent = { tab-width = 2, unit = " " } +language-server = { command = "metals" } diff --git a/runtime/queries/scala/highlights.scm b/runtime/queries/scala/highlights.scm new file mode 100644 index 00000000..50a6e18a --- /dev/null +++ b/runtime/queries/scala/highlights.scm @@ -0,0 +1,203 @@ +; CREDITS @stumash (stuart.mashaal@gmail.com) + +;; variables + + +((identifier) @variable.builtin + (#match? @variable.builtin "^this$")) + +(interpolation) @none + +; Assume other uppercase names constants. +; NOTE: In order to distinguish constants we highlight +; all the identifiers that are uppercased. But this solution +; is not suitable for all occurrences e.g. it will highlight +; an uppercased method as a constant if used with no params. +; Introducing highlighting for those specific cases, is probably +; best way to resolve the issue. +((identifier) @constant (#match? @constant "^[A-Z]")) + +;; types + +(type_identifier) @type + +(class_definition + name: (identifier) @type) + +(object_definition + name: (identifier) @type) + +(trait_definition + name: (identifier) @type) + +(type_definition + name: (type_identifier) @type) + +; method definition + +(class_definition + body: (template_body + (function_definition + name: (identifier) @function.method))) +(object_definition + body: (template_body + (function_definition + name: (identifier) @function.method))) +(trait_definition + body: (template_body + (function_definition + name: (identifier) @function.method))) + +; imports + +(import_declaration + path: (identifier) @namespace) +((stable_identifier (identifier) @namespace)) + +((import_declaration + path: (identifier) @type) (#match? @type "^[A-Z]")) +((stable_identifier (identifier) @type) (#match? @type "^[A-Z]")) + +((import_selectors (identifier) @type) (#match? @type "^[A-Z]")) + +; method invocation + + +(call_expression + function: (identifier) @function) + +(call_expression + function: (field_expression + field: (identifier) @function.method)) + +((call_expression + function: (identifier) @variable.other.member) + (#match? @variable.other.member "^[A-Z]")) + +(generic_function + function: (identifier) @function) + +( + (identifier) @function.builtin + (#match? @function.builtin "^super$") +) + +; function definitions + +(function_definition + name: (identifier) @function) + +(parameter + name: (identifier) @variable.parameter) + +; expressions + + +(field_expression field: (identifier) @variable.other.member) +(field_expression value: (identifier) @type + (#match? @type "^[A-Z]")) + +(infix_expression operator: (identifier) @operator) +(infix_expression operator: (operator_identifier) @operator) +(infix_type operator: (operator_identifier) @operator) +(infix_type operator: (operator_identifier) @operator) + +; literals +(boolean_literal) @constant.builtin.boolean +(integer_literal) @constant.numeric.integer +(floating_point_literal) @constant.numeric.float + + +(symbol_literal) @string.special.symbol + +[ +(string) +(character_literal) +(interpolated_string_expression) +] @string + +(interpolation "$" @punctuation.special) + +;; keywords + +[ + "abstract" + "case" + "class" + "extends" + "final" + "finally" +;; `forSome` existential types not implemented yet + "implicit" + "lazy" +;; `macro` not implemented yet + "object" + "override" + "package" + "private" + "protected" + "sealed" + "trait" + "type" + "val" + "var" + "with" +] @keyword + +(null_literal) @constant.builtin +(wildcard) @keyword + +;; special keywords + +"new" @keyword.operator + +[ + "else" + "if" + "match" + "try" + "catch" + "throw" +] @keyword.control.conditional + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "." + "," +] @punctuation.delimiter + +[ + "do" + "for" + "while" + "yield" +] @keyword.control.repeat + +"def" @keyword.function + +[ + "=>" + "<-" + "@" +] @keyword.operator + +"import" @keyword.control.import + +"return" @keyword.control.return + +(comment) @comment + +;; `case` is a conditional keyword in case_block + +(case_block + (case_clause ("case") @keyword.control.conditional)) + +(identifier) @variable \ No newline at end of file diff --git a/runtime/queries/scala/indents.toml b/runtime/queries/scala/indents.toml new file mode 100644 index 00000000..6de54844 --- /dev/null +++ b/runtime/queries/scala/indents.toml @@ -0,0 +1,23 @@ + +indent = [ + "block", + "arguments", + "parameter", + "class_definition", + "trait_definition", + "object_definition", + "function_definition", + "val_definition", + "import_declaration", + "while_expression", + "do_while_expression", + "for_expression", + "try_expression", + "match_expression" +] + +outdent = [ + "}", + "]", + ")" +] diff --git a/runtime/queries/scala/injections.scm b/runtime/queries/scala/injections.scm new file mode 100644 index 00000000..4bb7d675 --- /dev/null +++ b/runtime/queries/scala/injections.scm @@ -0,0 +1 @@ +(comment) @comment -- cgit v1.2.3-70-g09d2 From edf3c70c302aef628dc1a63895e2492d34e82507 Mon Sep 17 00:00:00 2001 From: Luke Jones Date: Sat, 18 Dec 2021 17:41:32 +1300 Subject: Add dart lsp config and queries (#1250) * Add language: dart The setup requires that dart be in the users path, such as: ``` export PATH="$HOME/Android/flutter/bin/cache/dart-sdk/bin/:$PATH" ``` Refactor the dart highlights * lang: dart: add indents and locals * lang: dart: corrections to local scope Co-authored-by: Blaž Hrastnik --- .gitmodules | 4 + helix-syntax/languages/tree-sitter-dart | 1 + languages.toml | 12 +- runtime/queries/dart/highlights.scm | 237 ++++++++++++++++++++++++++++++++ runtime/queries/dart/indents.toml | 20 +++ runtime/queries/dart/locals.scm | 20 +++ 6 files changed, 293 insertions(+), 1 deletion(-) create mode 160000 helix-syntax/languages/tree-sitter-dart create mode 100644 runtime/queries/dart/highlights.scm create mode 100644 runtime/queries/dart/indents.toml create mode 100644 runtime/queries/dart/locals.scm (limited to 'helix-syntax/languages') diff --git a/.gitmodules b/.gitmodules index 9c10846d..4b142adf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -154,3 +154,7 @@ path = helix-syntax/languages/tree-sitter-markdown url = https://github.com/MDeiml/tree-sitter-markdown shallow = true +[submodule "helix-syntax/languages/tree-sitter-dart"] + path = helix-syntax/languages/tree-sitter-dart + url = https://github.com/UserNobody14/tree-sitter-dart.git + shallow = true diff --git a/helix-syntax/languages/tree-sitter-dart b/helix-syntax/languages/tree-sitter-dart new file mode 160000 index 00000000..6a253766 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-dart @@ -0,0 +1 @@ +Subproject commit 6a25376685d1d47968c2cef06d4db8d84a70025e diff --git a/languages.toml b/languages.toml index 88882f3e..5c2bc8bb 100644 --- a/languages.toml +++ b/languages.toml @@ -431,6 +431,16 @@ roots = [] indent = { tab-width = 2, unit = " " } +[[language]] +name = "dart" +scope = "source.dart" +file-types = ["dart"] +roots = ["pubspec.yaml"] +auto-format = true +comment-token = "//" +language-server = { command = "dart", args = ["language-server", "--client-id=helix"] } +indent = { tab-width = 2, unit = " " } + [[language]] name = "scala" scope = "source.scala" @@ -438,4 +448,4 @@ roots = ["build.sbt"] file-types = ["scala", "sbt"] comment-token = "//" indent = { tab-width = 2, unit = " " } -language-server = { command = "metals" } +language-server = { command = "metals" } \ No newline at end of file diff --git a/runtime/queries/dart/highlights.scm b/runtime/queries/dart/highlights.scm new file mode 100644 index 00000000..9f667d6b --- /dev/null +++ b/runtime/queries/dart/highlights.scm @@ -0,0 +1,237 @@ +(dotted_identifier_list) @string + +; Methods +; -------------------- +(super) @function.builtin + +(function_expression_body (identifier) @function.method) +((identifier)(selector (argument_part)) @function.method) + +; Annotations +; -------------------- +(annotation + name: (identifier) @attribute) +(marker_annotation + name: (identifier) @attribute) + +; Types +; -------------------- +(class_definition + name: (identifier) @type) + +(constructor_signature + name: (identifier) @function.method) + +(function_signature + name: (identifier) @function.method) + +(getter_signature + (identifier) @function.builtin) + +(setter_signature + name: (identifier) @function.builtin) + +(enum_declaration + name: (identifier) @type) + +(enum_constant + name: (identifier) @type.builtin) + +(void_type) @type.builtin + +((scoped_identifier + scope: (identifier) @type) + (#match? @type "^[a-zA-Z]")) + +((scoped_identifier + scope: (identifier) @type + name: (identifier) @type) + (#match? @type "^[a-zA-Z]")) + +; the DisabledDrawerButtons in : const DisabledDrawerButtons(history: true), +(type_identifier) @type.builtin + +; Variables +; -------------------- +; the "File" in var file = File(); +((identifier) @namespace + (#match? @namespace "^_?[A-Z].*[a-z]")) ; catch Classes or IClasses not CLASSES + +("Function" @type.builtin) +(inferred_type) @type.builtin + +; properties +(unconditional_assignable_selector + (identifier) @variable.other.member) + +(conditional_assignable_selector + (identifier) @variable.other.member) + +; assignments +; -------------------- +; the "strings" in : strings = "some string" +(assignment_expression + left: (assignable_expression) @variable) + +(this) @variable.builtin + +; Parameters +; -------------------- +(formal_parameter + name: (identifier) @variable) + +(named_argument + (label (identifier) @variable)) + +; Literals +; -------------------- +[ + (hex_integer_literal) + (decimal_integer_literal) + (decimal_floating_point_literal) + ;(octal_integer_literal) + ;(hex_floating_point_literal) +] @constant.numeric.integer + +(symbol_literal) @string.special.symbol +(string_literal) @string + +[ + (const_builtin) + (final_builtin) +] @variable.builtin + +[ + (true) + (false) +] @constant.builtin.boolean + +(null_literal) @constant.builtin + +(comment) @comment.line +(documentation_comment) @comment.block.documentation + +; Tokens +; -------------------- +(template_substitution + "$" @punctuation.special + "{" @punctuation.special + "}" @punctuation.special +) @embedded + +(template_substitution + "$" @punctuation.special + (identifier_dollar_escaped) @variable +) @embedded + +(escape_sequence) @constant.character.escape + +; Punctuation +;--------------------- +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + ";" + "." + "," + ":" +] @punctuation.delimiter + +; Operators +;--------------------- +[ + "@" + "?" + "=>" + ".." + "==" + "&&" + "%" + "<" + ">" + "=" + ">=" + "<=" + "||" + (multiplicative_operator) + (increment_operator) + (is_operator) + (prefix_operator) + (equality_operator) + (additive_operator) +] @operator + +; Keywords +; -------------------- +["import" "library" "export"] @keyword.control.import +["do" "while" "continue" "for"] @keyword.control.repeat +["return" "yield"] @keyword.control.return +["as" "in" "is"] @keyword.operator + +[ + "?." + "??" + "if" + "else" + "switch" + "default" + "late" +] @keyword.control.conditional + +[ + "try" + "throw" + "catch" + "finally" + (break_statement) +] @keyword.control.exception + +; Reserved words (cannot be used as identifiers) +[ + (case_builtin) + "abstract" + "async" + "async*" + "await" + "class" + "covariant" + "deferred" + "dynamic" + "enum" + "extends" + "extension" + "external" + "factory" + "Function" + "get" + "implements" + "interface" + "mixin" + "new" + "on" + "operator" + "part" + "required" + "set" + "show" + "static" + "super" + "sync*" + "typedef" + "with" +] @keyword + +; when used as an identifier: +((identifier) @variable.builtin + (#match? @variable.builtin "^(abstract|as|covariant|deferred|dynamic|export|external|factory|Function|get|implements|import|interface|library|operator|mixin|part|set|static|typedef)$")) + +; Error +(ERROR) @error + diff --git a/runtime/queries/dart/indents.toml b/runtime/queries/dart/indents.toml new file mode 100644 index 00000000..5c11e05d --- /dev/null +++ b/runtime/queries/dart/indents.toml @@ -0,0 +1,20 @@ +indent = [ + "class_body", + "function_body", + "function_expression_body", + "declaration", + "initializers", + "switch_block", + "if_statement", + "formal_parameter_list", + "formal_parameter", + "list_literal", + "return_statement", + "arguments" +] + +outdent = [ + "}", + "]", + ")" +] diff --git a/runtime/queries/dart/locals.scm b/runtime/queries/dart/locals.scm new file mode 100644 index 00000000..629838e5 --- /dev/null +++ b/runtime/queries/dart/locals.scm @@ -0,0 +1,20 @@ +; Scopes +;------- + +[ + (block) + (try_statement) + (catch_clause) + (finally_clause) +] @local.scope + +; Definitions +;------------ + +(class_definition + body: (_) @local.definition) + +; References +;------------ + +(identifier) @local.reference -- cgit v1.2.3-70-g09d2 From 6d183b2154bdeb8508059d2cb3cf165ac4c67bb6 Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Sun, 19 Dec 2021 01:46:47 +0100 Subject: Fix tree-sitter-llvm submodule (#1298) Fix the path to the submodule and init the submodule.--- .gitmodules | 2 +- helix-syntax/languages/tree-sitter-llvm | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 160000 helix-syntax/languages/tree-sitter-llvm (limited to 'helix-syntax/languages') diff --git a/.gitmodules b/.gitmodules index 4b142adf..a899c778 100644 --- a/.gitmodules +++ b/.gitmodules @@ -146,7 +146,7 @@ path = helix-syntax/languages/tree-sitter-wgsl url = https://github.com/szebniok/tree-sitter-wgsl shallow = true -[submodule "helix-syntax/tree-sitter-llvm"] +[submodule "helix-syntax/languages/tree-sitter-llvm"] path = helix-syntax/languages/tree-sitter-llvm url = https://github.com/benwilliamgraham/tree-sitter-llvm shallow = true diff --git a/helix-syntax/languages/tree-sitter-llvm b/helix-syntax/languages/tree-sitter-llvm new file mode 160000 index 00000000..d4f61bed --- /dev/null +++ b/helix-syntax/languages/tree-sitter-llvm @@ -0,0 +1 @@ +Subproject commit d4f61bed8ecb632addcd5e088c4f4cb9c1bf1c5b -- cgit v1.2.3-70-g09d2 From e72786df8eae5684c0330be18f190a33f516da76 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sun, 19 Dec 2021 08:56:56 -0600 Subject: Add tree-sitter-comment (#1300) * Add tree-sitter-comment Fix #1164 * fix precedence in tree-sitter-comment highlights connects https://github.com/helix-editor/helix/pull/1170 * set injection-regex for comment language * remove comment filetype * fix comment injections for neovim-style injections tags * add comment injections for elixir * remove f.comment * fix spacing in .gitmodules * run 'cargo xtask docgen' Co-authored-by: Ivan Tham --- .gitmodules | 4 ++++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-comment | 1 + languages.toml | 9 ++++++++- runtime/queries/comment/highlights.scm | 30 ++++++++++++++++++++++++++++++ runtime/queries/elixir/injections.scm | 2 ++ runtime/queries/glsl/injections.scm | 6 ++++-- runtime/queries/julia/injections.scm | 8 +++++--- runtime/queries/ledger/injections.scm | 4 ++-- runtime/queries/python/injections.scm | 2 ++ runtime/queries/rust/injections.scm | 3 +++ runtime/queries/svelte/injections.scm | 4 ++-- runtime/queries/tsq/injections.scm | 2 ++ 13 files changed, 66 insertions(+), 10 deletions(-) create mode 160000 helix-syntax/languages/tree-sitter-comment create mode 100644 runtime/queries/comment/highlights.scm create mode 100644 runtime/queries/elixir/injections.scm create mode 100644 runtime/queries/python/injections.scm create mode 100644 runtime/queries/tsq/injections.scm (limited to 'helix-syntax/languages') diff --git a/.gitmodules b/.gitmodules index a899c778..c7b81336 100644 --- a/.gitmodules +++ b/.gitmodules @@ -142,6 +142,10 @@ path = helix-syntax/languages/tree-sitter-perl url = https://github.com/ganezdragon/tree-sitter-perl shallow = true +[submodule "helix-syntax/languages/tree-sitter-comment"] + path = helix-syntax/languages/tree-sitter-comment + url = https://github.com/stsewd/tree-sitter-comment + shallow = true [submodule "helix-syntax/languages/tree-sitter-wgsl"] path = helix-syntax/languages/tree-sitter-wgsl url = https://github.com/szebniok/tree-sitter-wgsl diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 3255b9af..cb91872b 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -4,6 +4,7 @@ | c | ✓ | | | `clangd` | | c-sharp | ✓ | | | | | cmake | ✓ | | | `cmake-language-server` | +| comment | ✓ | | | | | cpp | ✓ | | | `clangd` | | css | ✓ | | | | | dart | ✓ | | ✓ | `dart` | diff --git a/helix-syntax/languages/tree-sitter-comment b/helix-syntax/languages/tree-sitter-comment new file mode 160000 index 00000000..5dd3c62f --- /dev/null +++ b/helix-syntax/languages/tree-sitter-comment @@ -0,0 +1 @@ +Subproject commit 5dd3c62f1bbe378b220fe16b317b85247898639e diff --git a/languages.toml b/languages.toml index 5c2bc8bb..0695022e 100644 --- a/languages.toml +++ b/languages.toml @@ -406,6 +406,13 @@ shebangs = ["racket"] comment-token = ";" language-server = { command = "racket", args = ["-l", "racket-langserver"] } +[[language]] +name = "comment" +scope = "scope.comment" +roots = [] +file-types = [] +injection-regex = "comment" + [[language]] name = "wgsl" scope = "source.wgsl" @@ -448,4 +455,4 @@ roots = ["build.sbt"] file-types = ["scala", "sbt"] comment-token = "//" indent = { tab-width = 2, unit = " " } -language-server = { command = "metals" } \ No newline at end of file +language-server = { command = "metals" } diff --git a/runtime/queries/comment/highlights.scm b/runtime/queries/comment/highlights.scm new file mode 100644 index 00000000..88685d59 --- /dev/null +++ b/runtime/queries/comment/highlights.scm @@ -0,0 +1,30 @@ +[ + "(" + ")" +] @punctuation.bracket + +":" @punctuation.delimiter + +((tag (name) @warning) + (#match? @warning "^(TODO|HACK|WARNING)$")) + +("text" @warning + (#match? @warning "^(TODO|HACK|WARNING)$")) + +((tag (name) @error) + (match? @error "^(FIXME|XXX|BUG)$")) + +("text" @error + (match? @error "^(FIXME|XXX|BUG)$")) + +(tag + (name) @ui.text + (user)? @constant) + +; Issue number (#123) +("text" @constant.numeric + (#match? @constant.numeric "^#[0-9]+$")) + +; User mention (@user) +("text" @tag + (#match? @tag "^[@][a-zA-Z0-9_-]+$")) diff --git a/runtime/queries/elixir/injections.scm b/runtime/queries/elixir/injections.scm new file mode 100644 index 00000000..321c90ad --- /dev/null +++ b/runtime/queries/elixir/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/glsl/injections.scm b/runtime/queries/glsl/injections.scm index 7d3323b1..b01b8b4b 100644 --- a/runtime/queries/glsl/injections.scm +++ b/runtime/queries/glsl/injections.scm @@ -1,3 +1,5 @@ -(preproc_arg) @glsl +((preproc_arg) @injection.content + (#set! injection.language "glsl")) -(comment) @comment +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/julia/injections.scm b/runtime/queries/julia/injections.scm index be2412c0..3cf7339f 100644 --- a/runtime/queries/julia/injections.scm +++ b/runtime/queries/julia/injections.scm @@ -1,5 +1,7 @@ ; TODO: re-add when markdown is added. -; ((triple_string) @markdown -; (#offset! @markdown 0 3 0 -3)) +; ((triple_string) @injection.content +; (#offset! @injection.content 0 3 0 -3) +; (#set! injection.language "markdown")) -(comment) @comment +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/ledger/injections.scm b/runtime/queries/ledger/injections.scm index 2d948141..c1714786 100644 --- a/runtime/queries/ledger/injections.scm +++ b/runtime/queries/ledger/injections.scm @@ -1,2 +1,2 @@ -(comment) @comment -(note) @comment +([(comment) (note)] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/python/injections.scm b/runtime/queries/python/injections.scm new file mode 100644 index 00000000..321c90ad --- /dev/null +++ b/runtime/queries/python/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/rust/injections.scm b/runtime/queries/rust/injections.scm index 6035d418..d8382e49 100644 --- a/runtime/queries/rust/injections.scm +++ b/runtime/queries/rust/injections.scm @@ -1,3 +1,6 @@ +([(line_comment) (block_comment)] @injection.content + (#set! injection.language "comment")) + ((macro_invocation (token_tree) @injection.content) (#set! injection.language "rust") diff --git a/runtime/queries/svelte/injections.scm b/runtime/queries/svelte/injections.scm index 266f4701..04e860cf 100644 --- a/runtime/queries/svelte/injections.scm +++ b/runtime/queries/svelte/injections.scm @@ -26,5 +26,5 @@ (#set! injection.language "typescript") ) -(comment) @comment - +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/tsq/injections.scm b/runtime/queries/tsq/injections.scm new file mode 100644 index 00000000..321c90ad --- /dev/null +++ b/runtime/queries/tsq/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) -- cgit v1.2.3-70-g09d2 From 205dc8776b6ff4f5ab331df9c33b33e44caab12c Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Tue, 21 Dec 2021 03:02:53 +0100 Subject: Add fish highlighting (#1308) The highlights were copied and modified from https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/fish/highlights.scm--- .gitmodules | 4 + book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-fish | 1 + languages.toml | 11 +++ runtime/queries/fish/highlights.scm | 156 ++++++++++++++++++++++++++++++++ runtime/queries/fish/indents.toml | 12 +++ runtime/queries/fish/injections.scm | 2 + runtime/queries/fish/textobjects.scm | 1 + 8 files changed, 188 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-fish create mode 100644 runtime/queries/fish/highlights.scm create mode 100644 runtime/queries/fish/indents.toml create mode 100644 runtime/queries/fish/injections.scm create mode 100644 runtime/queries/fish/textobjects.scm (limited to 'helix-syntax/languages') diff --git a/.gitmodules b/.gitmodules index c7b81336..dcec2813 100644 --- a/.gitmodules +++ b/.gitmodules @@ -162,3 +162,7 @@ path = helix-syntax/languages/tree-sitter-dart url = https://github.com/UserNobody14/tree-sitter-dart.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-fish"] + path = helix-syntax/languages/tree-sitter-fish + url = https://github.com/ram02z/tree-sitter-fish + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index cb91872b..24b75b64 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -9,6 +9,7 @@ | css | ✓ | | | | | dart | ✓ | | ✓ | `dart` | | elixir | ✓ | | | `elixir-ls` | +| fish | ✓ | ✓ | ✓ | | | glsl | ✓ | | ✓ | | | go | ✓ | ✓ | ✓ | `gopls` | | html | ✓ | | | | diff --git a/helix-syntax/languages/tree-sitter-fish b/helix-syntax/languages/tree-sitter-fish new file mode 160000 index 00000000..04e54ab6 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-fish @@ -0,0 +1 @@ +Subproject commit 04e54ab6585dfd4fee6ddfe5849af56f101b6d4f diff --git a/languages.toml b/languages.toml index 0695022e..61eb47ec 100644 --- a/languages.toml +++ b/languages.toml @@ -45,6 +45,17 @@ comment-token = "#" language-server = { command = "elixir-ls" } indent = { tab-width = 2, unit = " " } +[[language]] +name = "fish" +scope = "source.fish" +injection-regex = "fish" +file-types = ["fish"] +shebangs = ["fish"] +roots = [] +comment-token = "#" + +indent = { tab-width = 4, unit = " " } + [[language]] name = "mint" scope = "source.mint" diff --git a/runtime/queries/fish/highlights.scm b/runtime/queries/fish/highlights.scm new file mode 100644 index 00000000..def53931 --- /dev/null +++ b/runtime/queries/fish/highlights.scm @@ -0,0 +1,156 @@ +;; Operators + +[ + "&&" + "||" + "|" + "&" + "=" + "!=" + ".." + "!" + (direction) + (stream_redirect) + (test_option) +] @operator + +[ + "not" + "and" + "or" +] @keyword.operator + +;; Conditionals + +(if_statement +[ + "if" + "end" +] @keyword.control.conditional) + +(switch_statement +[ + "switch" + "end" +] @keyword.control.conditional) + +(case_clause +[ + "case" +] @keyword.control.conditional) + +(else_clause +[ + "else" +] @keyword.control.conditional) + +(else_if_clause +[ + "else" + "if" +] @keyword.control.conditional) + +;; Loops/Blocks + +(while_statement +[ + "while" + "end" +] @keyword.control.repeat) + +(for_statement +[ + "for" + "end" +] @keyword.control.repeat) + +(begin_statement +[ + "begin" + "end" +] @keyword.control.repeat) + +;; Keywords + +[ + "in" + (break) + (continue) +] @keyword + +"return" @keyword.control.return + +;; Punctuation + +[ + "[" + "]" + "{" + "}" + "(" + ")" +] @punctuation.bracket + +"," @punctuation.delimiter + +;; Commands + +(command + argument: [ + (word) @variable.parameter (#match? @variable.parameter "^-") + ] +) + +; non-bultin command names +(command name: (word) @function) + +; derived from builtin -n (fish 3.2.2) +(command + name: [ + (word) @function.builtin + (#match? @function.builtin "^(\.|:|_|alias|argparse|bg|bind|block|breakpoint|builtin|cd|command|commandline|complete|contains|count|disown|echo|emit|eval|exec|exit|fg|functions|history|isatty|jobs|math|printf|pwd|random|read|realpath|set|set_color|source|status|string|test|time|type|ulimit|wait)$") + ] +) + +(test_command "test" @function.builtin) + +;; Functions + +(function_definition ["function" "end"] @keyword.function) + +(function_definition + name: [ + (word) (concatenation) + ] +@function) + +(function_definition + option: [ + (word) + (concatenation (word)) + ] @variable.parameter (#match? @variable.parameter "^-") +) + +;; Strings + +[(double_quote_string) (single_quote_string)] @string +(escape_sequence) @constant.character.escape + +;; Variables + +(variable_name) @variable +(variable_expansion) @constant + +;; Nodes + +(integer) @constant.numeric.integer +(float) @constant.numeric.float +(comment) @comment +(test_option) @string + +((word) @constant.builtin.boolean +(#match? @constant.builtin.boolean "^(true|false)$")) + +;; Error + +(ERROR) @error diff --git a/runtime/queries/fish/indents.toml b/runtime/queries/fish/indents.toml new file mode 100644 index 00000000..6f1e563a --- /dev/null +++ b/runtime/queries/fish/indents.toml @@ -0,0 +1,12 @@ +indent = [ + "function_definition", + "while_statement", + "for_statement", + "if_statement", + "begin_statement", + "switch_statement", +] + +outdent = [ + "end" +] diff --git a/runtime/queries/fish/injections.scm b/runtime/queries/fish/injections.scm new file mode 100644 index 00000000..321c90ad --- /dev/null +++ b/runtime/queries/fish/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/fish/textobjects.scm b/runtime/queries/fish/textobjects.scm new file mode 100644 index 00000000..67fd6614 --- /dev/null +++ b/runtime/queries/fish/textobjects.scm @@ -0,0 +1 @@ +(function_definition) @function.around -- cgit v1.2.3-70-g09d2 From dba22c60ed7fc336ad619b1246333f0116b47bcd Mon Sep 17 00:00:00 2001 From: Midnight Exigent Date: Tue, 21 Dec 2021 10:22:15 +0100 Subject: Support dockerfiles (#1303) * allow language.config (in languages.toml) to be passed in as a toml object * Change config field for languages from json string to toml object * remove indents on languages.toml config * fix: remove patch version from serde_json import in helix-core * Use same tree-sitter-zig as upstream/master * fix(completion_popup): Fixes #1256 * Update helix-term/src/ui/completion.rs * feat(languages): Add support for `Dockerfile`s * docs(cargo-xtask-docgen): * improvement(langs-dockerfile): Add `injection-regex` to `languages.toml` for `Dockerfile` * improvement(langs-dockerfile): Add injections.scm * Update .gitmodules Co-authored-by: Blaž Hrastnik --- .gitmodules | 4 +++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-dockerfile | 1 + languages.toml | 11 ++++++ runtime/queries/dockerfile/highlights.scm | 51 +++++++++++++++++++++++++++ runtime/queries/dockerfile/injections.scm | 6 ++++ 6 files changed, 74 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-dockerfile create mode 100644 runtime/queries/dockerfile/highlights.scm create mode 100644 runtime/queries/dockerfile/injections.scm (limited to 'helix-syntax/languages') diff --git a/.gitmodules b/.gitmodules index dcec2813..edfe3c39 100644 --- a/.gitmodules +++ b/.gitmodules @@ -162,6 +162,10 @@ path = helix-syntax/languages/tree-sitter-dart url = https://github.com/UserNobody14/tree-sitter-dart.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-dockerfile"] + path = helix-syntax/languages/tree-sitter-dockerfile + url = https://github.com/camdencheek/tree-sitter-dockerfile.git + shallow = true [submodule "helix-syntax/languages/tree-sitter-fish"] path = helix-syntax/languages/tree-sitter-fish url = https://github.com/ram02z/tree-sitter-fish diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 24b75b64..c7054201 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -8,6 +8,7 @@ | cpp | ✓ | | | `clangd` | | css | ✓ | | | | | dart | ✓ | | ✓ | `dart` | +| dockerfile | ✓ | | | `docker-langserver` | | elixir | ✓ | | | `elixir-ls` | | fish | ✓ | ✓ | ✓ | | | glsl | ✓ | | ✓ | | diff --git a/helix-syntax/languages/tree-sitter-dockerfile b/helix-syntax/languages/tree-sitter-dockerfile new file mode 160000 index 00000000..7af32bc0 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-dockerfile @@ -0,0 +1 @@ +Subproject commit 7af32bc04a66ab196f5b9f92ac471f29372ae2ce diff --git a/languages.toml b/languages.toml index 61eb47ec..50c6f7f9 100644 --- a/languages.toml +++ b/languages.toml @@ -467,3 +467,14 @@ file-types = ["scala", "sbt"] comment-token = "//" indent = { tab-width = 2, unit = " " } language-server = { command = "metals" } + +[[language]] +name = "dockerfile" +scope = "source.dockerfile" +injection-regex = "docker|dockerfile" +roots = ["Dockerfile"] +file-types = ["Dockerfile"] +comment-token = "#" +indent = { tab-width = 2, unit = " " } +language-server = { command = "docker-langserver", args = ["--stdio"] } + diff --git a/runtime/queries/dockerfile/highlights.scm b/runtime/queries/dockerfile/highlights.scm new file mode 100644 index 00000000..5a945fb9 --- /dev/null +++ b/runtime/queries/dockerfile/highlights.scm @@ -0,0 +1,51 @@ +[ + "FROM" + "AS" + "RUN" + "CMD" + "LABEL" + "EXPOSE" + "ENV" + "ADD" + "COPY" + "ENTRYPOINT" + "VOLUME" + "USER" + "WORKDIR" + "ARG" + "ONBUILD" + "STOPSIGNAL" + "HEALTHCHECK" + "SHELL" + "MAINTAINER" + "CROSS_BUILD" +] @keyword + +[ + ":" + "@" +] @operator + +(comment) @comment + + +(image_spec + (image_tag + ":" @punctuation.special) + (image_digest + "@" @punctuation.special)) + +(double_quoted_string) @string + +(expansion + [ + "$" + "{" + "}" + ] @punctuation.special +) @none + +((variable) @constant + (#match? @constant "^[A-Z][A-Z_0-9]*$")) + + diff --git a/runtime/queries/dockerfile/injections.scm b/runtime/queries/dockerfile/injections.scm new file mode 100644 index 00000000..20396f1a --- /dev/null +++ b/runtime/queries/dockerfile/injections.scm @@ -0,0 +1,6 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +([(shell_command) (shell_fragment)] @injection.content + (#set! injection.language "bash")) + -- cgit v1.2.3-70-g09d2 From fd31662b70ee32d199950ba2873680fc9043c975 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Fri, 24 Dec 2021 12:44:45 -0600 Subject: add gitcommit grammar and language configuration --- .gitmodules | 6 +++++- book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-gitcommit | 1 + languages.toml | 8 ++++++++ 4 files changed, 15 insertions(+), 1 deletion(-) create mode 160000 helix-syntax/languages/tree-sitter-gitcommit (limited to 'helix-syntax/languages') diff --git a/.gitmodules b/.gitmodules index edfe3c39..ad100a00 100644 --- a/.gitmodules +++ b/.gitmodules @@ -165,8 +165,12 @@ [submodule "helix-syntax/languages/tree-sitter-dockerfile"] path = helix-syntax/languages/tree-sitter-dockerfile url = https://github.com/camdencheek/tree-sitter-dockerfile.git - shallow = true + shallow = true [submodule "helix-syntax/languages/tree-sitter-fish"] path = helix-syntax/languages/tree-sitter-fish url = https://github.com/ram02z/tree-sitter-fish shallow = true +[submodule "helix-syntax/languages/tree-sitter-gitcommit"] + path = helix-syntax/languages/tree-sitter-gitcommit + url = https://github.com/the-mikedavis/tree-sitter-gitcommit.git + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 2777dc4e..d6e0d9af 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -11,6 +11,7 @@ | dockerfile | ✓ | | | `docker-langserver` | | elixir | ✓ | | | `elixir-ls` | | fish | ✓ | ✓ | ✓ | | +| gitcommit | ✓ | | | | | glsl | ✓ | | ✓ | | | go | ✓ | ✓ | ✓ | `gopls` | | html | ✓ | | | | diff --git a/helix-syntax/languages/tree-sitter-gitcommit b/helix-syntax/languages/tree-sitter-gitcommit new file mode 160000 index 00000000..6a2ddbec --- /dev/null +++ b/helix-syntax/languages/tree-sitter-gitcommit @@ -0,0 +1 @@ +Subproject commit 6a2ddbecd49fa8e7e1fda24d43e363cfd9171ca0 diff --git a/languages.toml b/languages.toml index dd18fa19..f73011c8 100644 --- a/languages.toml +++ b/languages.toml @@ -473,3 +473,11 @@ file-types = ["Dockerfile", "dockerfile"] comment-token = "#" indent = { tab-width = 2, unit = " " } language-server = { command = "docker-langserver", args = ["--stdio"] } + +[[language]] +name = "gitcommit" +scope = "git.commitmsg" +roots = [] +file-types = ["COMMIT_EDITMSG"] +comment-token = "#" +indent = { tab-width = 2, unit = " " } -- cgit v1.2.3-70-g09d2 From c3fb86cbaa5c6973fe014a4401c4e0d6f663384d Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Fri, 24 Dec 2021 16:49:27 -0600 Subject: tree-sitter-gitcommit->tree-sitter-git-commit --- .gitmodules | 6 +++--- book/src/generated/lang-support.md | 2 +- helix-syntax/languages/tree-sitter-git-commit | 1 + helix-syntax/languages/tree-sitter-gitcommit | 1 - languages.toml | 2 +- runtime/queries/git-commit/highlights.scm | 18 ++++++++++++++++++ runtime/queries/git-commit/injections.scm | 15 +++++++++++++++ runtime/queries/gitcommit/highlights.scm | 18 ------------------ runtime/queries/gitcommit/injections.scm | 15 --------------- 9 files changed, 39 insertions(+), 39 deletions(-) create mode 160000 helix-syntax/languages/tree-sitter-git-commit delete mode 160000 helix-syntax/languages/tree-sitter-gitcommit create mode 100644 runtime/queries/git-commit/highlights.scm create mode 100644 runtime/queries/git-commit/injections.scm delete mode 100644 runtime/queries/gitcommit/highlights.scm delete mode 100644 runtime/queries/gitcommit/injections.scm (limited to 'helix-syntax/languages') diff --git a/.gitmodules b/.gitmodules index ad100a00..d5bd61c9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -170,7 +170,7 @@ path = helix-syntax/languages/tree-sitter-fish url = https://github.com/ram02z/tree-sitter-fish shallow = true -[submodule "helix-syntax/languages/tree-sitter-gitcommit"] - path = helix-syntax/languages/tree-sitter-gitcommit - url = https://github.com/the-mikedavis/tree-sitter-gitcommit.git +[submodule "helix-syntax/languages/tree-sitter-git-commit"] + path = helix-syntax/languages/tree-sitter-git-commit + url = https://github.com/the-mikedavis/tree-sitter-git-commit.git shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index d6e0d9af..9c42005b 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -11,7 +11,7 @@ | dockerfile | ✓ | | | `docker-langserver` | | elixir | ✓ | | | `elixir-ls` | | fish | ✓ | ✓ | ✓ | | -| gitcommit | ✓ | | | | +| git-commit | ✓ | | | | | glsl | ✓ | | ✓ | | | go | ✓ | ✓ | ✓ | `gopls` | | html | ✓ | | | | diff --git a/helix-syntax/languages/tree-sitter-git-commit b/helix-syntax/languages/tree-sitter-git-commit new file mode 160000 index 00000000..5cd4776c --- /dev/null +++ b/helix-syntax/languages/tree-sitter-git-commit @@ -0,0 +1 @@ +Subproject commit 5cd4776c86c82d9d6afdc8c73a47a08057aef618 diff --git a/helix-syntax/languages/tree-sitter-gitcommit b/helix-syntax/languages/tree-sitter-gitcommit deleted file mode 160000 index 6a2ddbec..00000000 --- a/helix-syntax/languages/tree-sitter-gitcommit +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6a2ddbecd49fa8e7e1fda24d43e363cfd9171ca0 diff --git a/languages.toml b/languages.toml index f73011c8..616ef234 100644 --- a/languages.toml +++ b/languages.toml @@ -475,7 +475,7 @@ indent = { tab-width = 2, unit = " " } language-server = { command = "docker-langserver", args = ["--stdio"] } [[language]] -name = "gitcommit" +name = "git-commit" scope = "git.commitmsg" roots = [] file-types = ["COMMIT_EDITMSG"] diff --git a/runtime/queries/git-commit/highlights.scm b/runtime/queries/git-commit/highlights.scm new file mode 100644 index 00000000..04d70416 --- /dev/null +++ b/runtime/queries/git-commit/highlights.scm @@ -0,0 +1,18 @@ +(subject) @markup.heading +(path) @string.special.path +(branch) @string.special.symbol +(commit) @constant +(item) @markup.link.url +(header) @tag + +(change kind: "new file" @diff.plus) +(change kind: "deleted" @diff.minus) +(change kind: "modified" @diff.delta) +(change kind: "renamed" @diff.delta.moved) + +[":" "->"] @punctuation.delimeter +(comment) @comment + +; once we have diff injections, @comment should become @none +((comment (scissors)) + (message)+ @comment) diff --git a/runtime/queries/git-commit/injections.scm b/runtime/queries/git-commit/injections.scm new file mode 100644 index 00000000..2837a586 --- /dev/null +++ b/runtime/queries/git-commit/injections.scm @@ -0,0 +1,15 @@ +; once a diff grammar is available, we can inject diff highlighting into the +; trailer after scissors (git commit --verbose) +; see https://github.com/helix-editor/helix/pull/1338#issuecomment-1000013539 +; +; ((comment (scissors)) +; (message) @injection.content +; (#set! injection.language "diff")) + +; --- + +; once a rebase grammar is available, we can inject rebase highlighting into +; interactive rebase summary sections like so: +; +; ((rebase_command) @injection.content +; (#set! injection.language "git-rebase")) diff --git a/runtime/queries/gitcommit/highlights.scm b/runtime/queries/gitcommit/highlights.scm deleted file mode 100644 index 04d70416..00000000 --- a/runtime/queries/gitcommit/highlights.scm +++ /dev/null @@ -1,18 +0,0 @@ -(subject) @markup.heading -(path) @string.special.path -(branch) @string.special.symbol -(commit) @constant -(item) @markup.link.url -(header) @tag - -(change kind: "new file" @diff.plus) -(change kind: "deleted" @diff.minus) -(change kind: "modified" @diff.delta) -(change kind: "renamed" @diff.delta.moved) - -[":" "->"] @punctuation.delimeter -(comment) @comment - -; once we have diff injections, @comment should become @none -((comment (scissors)) - (message)+ @comment) diff --git a/runtime/queries/gitcommit/injections.scm b/runtime/queries/gitcommit/injections.scm deleted file mode 100644 index 2837a586..00000000 --- a/runtime/queries/gitcommit/injections.scm +++ /dev/null @@ -1,15 +0,0 @@ -; once a diff grammar is available, we can inject diff highlighting into the -; trailer after scissors (git commit --verbose) -; see https://github.com/helix-editor/helix/pull/1338#issuecomment-1000013539 -; -; ((comment (scissors)) -; (message) @injection.content -; (#set! injection.language "diff")) - -; --- - -; once a rebase grammar is available, we can inject rebase highlighting into -; interactive rebase summary sections like so: -; -; ((rebase_command) @injection.content -; (#set! injection.language "git-rebase")) -- cgit v1.2.3-70-g09d2 From 8c29b76bccc51c19c90f7c9ee156fe2cb6f52e2c Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Wed, 29 Dec 2021 10:30:44 +0100 Subject: Improve llvm highlighting and queries (#1388) * Improve llvm highlighting and queries The llvm tree-sitter parser was updated to support scopes and more accurate highlighting. * Group highlight expressions better--- book/src/generated/lang-support.md | 2 +- helix-syntax/languages/tree-sitter-llvm | 2 +- runtime/queries/llvm/highlights.scm | 162 ++++++++++++++++++++++++++++++-- runtime/queries/llvm/indents.toml | 8 ++ runtime/queries/llvm/locals.scm | 14 +++ runtime/queries/llvm/textobjects.scm | 16 ++++ 6 files changed, 193 insertions(+), 11 deletions(-) create mode 100644 runtime/queries/llvm/indents.toml create mode 100644 runtime/queries/llvm/locals.scm create mode 100644 runtime/queries/llvm/textobjects.scm (limited to 'helix-syntax/languages') diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 28094484..5d172751 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -21,7 +21,7 @@ | julia | ✓ | | | `julia` | | latex | ✓ | | | | | ledger | ✓ | | | | -| llvm | ✓ | | | | +| llvm | ✓ | ✓ | ✓ | | | lua | ✓ | | ✓ | | | markdown | ✓ | | | | | mint | | | | `mint` | diff --git a/helix-syntax/languages/tree-sitter-llvm b/helix-syntax/languages/tree-sitter-llvm index d4f61bed..3b213925 160000 --- a/helix-syntax/languages/tree-sitter-llvm +++ b/helix-syntax/languages/tree-sitter-llvm @@ -1 +1 @@ -Subproject commit d4f61bed8ecb632addcd5e088c4f4cb9c1bf1c5b +Subproject commit 3b213925b9c4f42c1acfe2e10bfbb438d9c6834d diff --git a/runtime/queries/llvm/highlights.scm b/runtime/queries/llvm/highlights.scm index 73afe85e..cb705197 100644 --- a/runtime/queries/llvm/highlights.scm +++ b/runtime/queries/llvm/highlights.scm @@ -1,14 +1,158 @@ (type) @type -(statement) @keyword.operator +(type_keyword) @type.builtin + +(type [ + (local_var) + (global_var) + ] @type) + +(argument) @variable.parameter + +(_ inst_name: _ @keyword.operator) + +[ + "catch" + "filter" +] @keyword.operator + +[ + "to" + "nuw" + "nsw" + "exact" + "unwind" + "from" + "cleanup" + "swifterror" + "volatile" + "inbounds" + "inrange" + (icmp_cond) + (fcmp_cond) + (fast_math) +] @keyword.control + +(_ callee: _ @function) +(function_header name: _ @function) + +[ + "declare" + "define" + (calling_conv) +] @keyword.function + +[ + "target" + "triple" + "datalayout" + "source_filename" + "addrspace" + "blockaddress" + "align" + "syncscope" + "within" + "uselistorder" + "uselistorder_bb" + "module" + "asm" + "sideeffect" + "alignstack" + "inteldialect" + "unwind" + "type" + "global" + "constant" + "externally_initialized" + "alias" + "ifunc" + "section" + "comdat" + "thread_local" + "localdynamic" + "initialexec" + "localexec" + "any" + "exactmatch" + "largest" + "nodeduplicate" + "samesize" + "distinct" + "attributes" + "vscale" + "no_cfi" + (linkage_aux) + (dso_local) + (visibility) + (dll_storage_class) + (unnamed_addr) + (attribute_name) +] @keyword + + +(function_header [ + (linkage) + (calling_conv) + (unnamed_addr) + ] @keyword.function) + +[ + (string) + (cstring) +] @string + (number) @constant.numeric.integer (comment) @comment -(string) @string (label) @label -(keyword) @keyword -"ret" @keyword.control.return -(boolean) @constant.builtin.boolean +(_ inst_name: "ret" @keyword.control.return) (float) @constant.numeric.float -(constant) @constant -(identifier) @variable -(symbol) @punctuation.delimiter -(bracket) @punctuation.bracket + +[ + (local_var) + (global_var) +] @variable + +[ + (struct_value) + (array_value) + (vector_value) +] @constructor + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "<" + ">" + "<{" + "}>" +] @punctuation.bracket + +[ + "," + ":" +] @punctuation.delimiter + +[ + "=" + "|" + "x" + "..." +] @operator + +[ + "true" + "false" +] @constant.builtin.boolean + +[ + "undef" + "poison" + "null" + "none" + "zeroinitializer" +] @constant.builtin + +(ERROR) @error diff --git a/runtime/queries/llvm/indents.toml b/runtime/queries/llvm/indents.toml new file mode 100644 index 00000000..8cd603c8 --- /dev/null +++ b/runtime/queries/llvm/indents.toml @@ -0,0 +1,8 @@ +indent = [ + "function_body", + "instruction", +] + +outdent = [ + "}", +] diff --git a/runtime/queries/llvm/locals.scm b/runtime/queries/llvm/locals.scm new file mode 100644 index 00000000..1946c287 --- /dev/null +++ b/runtime/queries/llvm/locals.scm @@ -0,0 +1,14 @@ +; Scopes + +(function_body) @local.scope + +; Definitions + +(argument + (value (var (local_var) @local.definition))) + +(instruction + (local_var) @local.definition) + +; References +(local_var) @local.reference diff --git a/runtime/queries/llvm/textobjects.scm b/runtime/queries/llvm/textobjects.scm new file mode 100644 index 00000000..3738a3bb --- /dev/null +++ b/runtime/queries/llvm/textobjects.scm @@ -0,0 +1,16 @@ +(define + body: (_) @function.inside) @function.around + +(struct_type + (struct_body) @class.inside) @class.around + +(packed_struct_type + (struct_body) @class.inside) @class.around + +(array_type + (array_vector_body) @class.inside) @class.around + +(vector_type + (array_vector_body) @class.inside) @class.around + +(argument) @parameter.inside -- cgit v1.2.3-70-g09d2 From bcf3808e9763bfe1bbf70f6053f890c80639d7c9 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Wed, 29 Dec 2021 09:31:23 -0600 Subject: Add tree-sitter-git-diff (#1373) * add submodule on tree-sitter-git-diff * add git-diff highlights * inject git-diff into git-commit * update tree-sitter-git-commit with fix for bad diff case * add git-diff to language support docs * include-children in diff injections This ensures that children nodes of $.message are included in the injection, such as $.user or issue/pr numbers. Without this change, diffs containing '#' or '@' characters can trip up the injection and be parsed separately. See https://github.com/helix-editor/helix/pull/1373#issuecomment-1001215629 * set diff language's scope as source.diff--- .gitmodules | 4 ++++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-git-commit | 2 +- helix-syntax/languages/tree-sitter-git-diff | 1 + languages.toml | 9 +++++++++ runtime/queries/git-commit/highlights.scm | 4 ---- runtime/queries/git-commit/injections.scm | 13 ++++--------- runtime/queries/git-diff/highlights.scm | 6 ++++++ 8 files changed, 26 insertions(+), 14 deletions(-) create mode 160000 helix-syntax/languages/tree-sitter-git-diff create mode 100644 runtime/queries/git-diff/highlights.scm (limited to 'helix-syntax/languages') diff --git a/.gitmodules b/.gitmodules index d5bd61c9..422671b4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -174,3 +174,7 @@ path = helix-syntax/languages/tree-sitter-git-commit url = https://github.com/the-mikedavis/tree-sitter-git-commit.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-git-diff"] + path = helix-syntax/languages/tree-sitter-git-diff + url = https://github.com/the-mikedavis/tree-sitter-git-diff.git + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 5d172751..91575c62 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -12,6 +12,7 @@ | elixir | ✓ | | | `elixir-ls` | | fish | ✓ | ✓ | ✓ | | | git-commit | ✓ | | | | +| git-diff | ✓ | | | | | glsl | ✓ | | ✓ | | | go | ✓ | ✓ | ✓ | `gopls` | | html | ✓ | | | | diff --git a/helix-syntax/languages/tree-sitter-git-commit b/helix-syntax/languages/tree-sitter-git-commit index 5cd4776c..066e395e 160000 --- a/helix-syntax/languages/tree-sitter-git-commit +++ b/helix-syntax/languages/tree-sitter-git-commit @@ -1 +1 @@ -Subproject commit 5cd4776c86c82d9d6afdc8c73a47a08057aef618 +Subproject commit 066e395e1107df17183cf3ae4230f1a1406cc972 diff --git a/helix-syntax/languages/tree-sitter-git-diff b/helix-syntax/languages/tree-sitter-git-diff new file mode 160000 index 00000000..c12e6ecb --- /dev/null +++ b/helix-syntax/languages/tree-sitter-git-diff @@ -0,0 +1 @@ +Subproject commit c12e6ecb54485f764250556ffd7ccb18f8e2942b diff --git a/languages.toml b/languages.toml index 616ef234..c3ae9f62 100644 --- a/languages.toml +++ b/languages.toml @@ -481,3 +481,12 @@ roots = [] file-types = ["COMMIT_EDITMSG"] comment-token = "#" indent = { tab-width = 2, unit = " " } + +[[language]] +name = "git-diff" +scope = "source.diff" +roots = [] +file-types = ["diff"] +injection-regex = "diff" +comment-token = "#" +indent = { tab-width = 2, unit = " " } diff --git a/runtime/queries/git-commit/highlights.scm b/runtime/queries/git-commit/highlights.scm index a74bb381..ffcc31ae 100644 --- a/runtime/queries/git-commit/highlights.scm +++ b/runtime/queries/git-commit/highlights.scm @@ -13,7 +13,3 @@ [":" "->"] @punctuation.delimeter (comment) @comment - -; once we have diff injections, @comment should become @none -((comment (scissors)) - (message)+ @comment) diff --git a/runtime/queries/git-commit/injections.scm b/runtime/queries/git-commit/injections.scm index 2837a586..bd96f1de 100644 --- a/runtime/queries/git-commit/injections.scm +++ b/runtime/queries/git-commit/injections.scm @@ -1,12 +1,7 @@ -; once a diff grammar is available, we can inject diff highlighting into the -; trailer after scissors (git commit --verbose) -; see https://github.com/helix-editor/helix/pull/1338#issuecomment-1000013539 -; -; ((comment (scissors)) -; (message) @injection.content -; (#set! injection.language "diff")) - -; --- +((comment (scissors)) + (message) @injection.content + (#set! injection.include-children) + (#set! injection.language "diff")) ; once a rebase grammar is available, we can inject rebase highlighting into ; interactive rebase summary sections like so: diff --git a/runtime/queries/git-diff/highlights.scm b/runtime/queries/git-diff/highlights.scm new file mode 100644 index 00000000..1c1a8829 --- /dev/null +++ b/runtime/queries/git-diff/highlights.scm @@ -0,0 +1,6 @@ +[(addition) (new_file)] @diff.plus +[(deletion) (old_file)] @diff.minus + +(commit) @constant +(location) @attribute +(command) @markup.bold -- cgit v1.2.3-70-g09d2 From 8fda87af2bb0625c502a23ddbd78a7447ada7bcb Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Thu, 30 Dec 2021 16:58:47 -0600 Subject: add tree-sitter-git-rebase (#1402) * add submodule on tree-sitter-rebase, add to languages * add basic highlights query * inject bash in execute statements * update tree-sitter-rebase * tree-sitter-rebase->tree-sitter-git-rebase * get injection working with tree-sitter-git-commit * set scope under source.gitrebase * unset include-children on commit message injections * Revert "unset include-children on commit message injections" This reverts commit 2ecee155ea8e229651920b291062c2ee84b47944. * fix generated language docs * use rebase_command scopes from tree-sitter-git-commit--- .gitmodules | 4 ++++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-git-rebase | 1 + languages.toml | 9 +++++++++ runtime/queries/git-commit/highlights.scm | 1 - runtime/queries/git-commit/injections.scm | 8 +++----- runtime/queries/git-rebase/highlights.scm | 11 +++++++++++ runtime/queries/git-rebase/injections.scm | 4 ++++ 8 files changed, 33 insertions(+), 6 deletions(-) create mode 160000 helix-syntax/languages/tree-sitter-git-rebase create mode 100644 runtime/queries/git-rebase/highlights.scm create mode 100644 runtime/queries/git-rebase/injections.scm (limited to 'helix-syntax/languages') diff --git a/.gitmodules b/.gitmodules index 422671b4..22f70c80 100644 --- a/.gitmodules +++ b/.gitmodules @@ -178,3 +178,7 @@ path = helix-syntax/languages/tree-sitter-git-diff url = https://github.com/the-mikedavis/tree-sitter-git-diff.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-git-rebase"] + path = helix-syntax/languages/tree-sitter-git-rebase + url = https://github.com/the-mikedavis/tree-sitter-git-rebase.git + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 91575c62..09284d46 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -13,6 +13,7 @@ | fish | ✓ | ✓ | ✓ | | | git-commit | ✓ | | | | | git-diff | ✓ | | | | +| git-rebase | ✓ | | | | | glsl | ✓ | | ✓ | | | go | ✓ | ✓ | ✓ | `gopls` | | html | ✓ | | | | diff --git a/helix-syntax/languages/tree-sitter-git-rebase b/helix-syntax/languages/tree-sitter-git-rebase new file mode 160000 index 00000000..332dc528 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-git-rebase @@ -0,0 +1 @@ +Subproject commit 332dc528f27044bc4427024dbb33e6941fc131f2 diff --git a/languages.toml b/languages.toml index c3ae9f62..3d9bac7b 100644 --- a/languages.toml +++ b/languages.toml @@ -490,3 +490,12 @@ file-types = ["diff"] injection-regex = "diff" comment-token = "#" indent = { tab-width = 2, unit = " " } + +[[language]] +name = "git-rebase" +scope = "source.gitrebase" +roots = [] +file-types = ["git-rebase-todo"] +injection-regex = "git-rebase" +comment-token = "#" +indent = { tab-width = 2, unit = " " } diff --git a/runtime/queries/git-commit/highlights.scm b/runtime/queries/git-commit/highlights.scm index ffcc31ae..0b50d419 100644 --- a/runtime/queries/git-commit/highlights.scm +++ b/runtime/queries/git-commit/highlights.scm @@ -4,7 +4,6 @@ (commit) @constant (item) @markup.link.url (header) @tag -(rebase_command) @markup.raw (change kind: "new file" @diff.plus) (change kind: "deleted" @diff.minus) diff --git a/runtime/queries/git-commit/injections.scm b/runtime/queries/git-commit/injections.scm index bd96f1de..cf0657f7 100644 --- a/runtime/queries/git-commit/injections.scm +++ b/runtime/queries/git-commit/injections.scm @@ -3,8 +3,6 @@ (#set! injection.include-children) (#set! injection.language "diff")) -; once a rebase grammar is available, we can inject rebase highlighting into -; interactive rebase summary sections like so: -; -; ((rebase_command) @injection.content -; (#set! injection.language "git-rebase")) +((rebase_command) @injection.content + (#set! injection.include-children) + (#set! injection.language "git-rebase")) diff --git a/runtime/queries/git-rebase/highlights.scm b/runtime/queries/git-rebase/highlights.scm new file mode 100644 index 00000000..4f007037 --- /dev/null +++ b/runtime/queries/git-rebase/highlights.scm @@ -0,0 +1,11 @@ +(operation operator: ["p" "pick" "r" "reword" "e" "edit" "s" "squash" "m" "merge" "d" "drop" "b" "break" "x" "exec"] @keyword) +(operation operator: ["l" "label" "t" "reset"] @function) +(operation operator: ["f" "fixup"] @function.special) + +(option) @operator +(label) @string.special.symbol +(commit) @constant +"#" @punctuation.delimiter +(comment) @comment + +(ERROR) @error diff --git a/runtime/queries/git-rebase/injections.scm b/runtime/queries/git-rebase/injections.scm new file mode 100644 index 00000000..070129b6 --- /dev/null +++ b/runtime/queries/git-rebase/injections.scm @@ -0,0 +1,4 @@ +((operation + operator: ["x" "exec"] + (command) @injection.content) + (#set! injection.language "bash")) -- cgit v1.2.3-70-g09d2 From 8f2af713408b8b40cf71873bbc0ddc009a7b3da5 Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Mon, 3 Jan 2022 02:57:55 +0100 Subject: Add LLVM TableGen highlighting (#1409) Add a tree-sitter grammar and highlights for TableGen files. TableGen and its grammar are described here: https://llvm.org/docs/TableGen/index.html Co-authored-by: Blaž Hrastnik --- .gitmodules | 4 ++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-tablegen | 1 + languages.toml | 9 +++ runtime/queries/tablegen/highlights.scm | 90 +++++++++++++++++++++++++++++ runtime/queries/tablegen/indents.toml | 7 +++ runtime/queries/tablegen/injections.scm | 2 + runtime/queries/tablegen/textobjects.scm | 7 +++ 8 files changed, 121 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-tablegen create mode 100644 runtime/queries/tablegen/highlights.scm create mode 100644 runtime/queries/tablegen/indents.toml create mode 100644 runtime/queries/tablegen/injections.scm create mode 100644 runtime/queries/tablegen/textobjects.scm (limited to 'helix-syntax/languages') diff --git a/.gitmodules b/.gitmodules index 22f70c80..b617e60c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -178,6 +178,10 @@ path = helix-syntax/languages/tree-sitter-git-diff url = https://github.com/the-mikedavis/tree-sitter-git-diff.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-tablegen"] + path = helix-syntax/languages/tree-sitter-tablegen + url = https://github.com/Flakebi/tree-sitter-tablegen + shallow = true [submodule "helix-syntax/languages/tree-sitter-git-rebase"] path = helix-syntax/languages/tree-sitter-git-rebase url = https://github.com/the-mikedavis/tree-sitter-git-rebase.git diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 09284d46..73712ff2 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -40,6 +40,7 @@ | rust | ✓ | ✓ | ✓ | `rust-analyzer` | | scala | ✓ | | ✓ | `metals` | | svelte | ✓ | | ✓ | `svelteserver` | +| tablegen | ✓ | ✓ | ✓ | | | toml | ✓ | | | | | tsq | ✓ | | | | | tsx | ✓ | | | `typescript-language-server` | diff --git a/helix-syntax/languages/tree-sitter-tablegen b/helix-syntax/languages/tree-sitter-tablegen new file mode 160000 index 00000000..568dd8a9 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-tablegen @@ -0,0 +1 @@ +Subproject commit 568dd8a937347175fd58db83d4c4cdaeb6069bd2 diff --git a/languages.toml b/languages.toml index f088a3aa..7a895a60 100644 --- a/languages.toml +++ b/languages.toml @@ -436,6 +436,15 @@ file-types = ["ll"] comment-token = ";" indent = { tab-width = 2, unit = " " } +[[language]] +name = "tablegen" +scope = "source.tablegen" +roots = [] +file-types = ["td"] +comment-token = "//" +indent = { tab-width = 2, unit = " " } +injection-regex = "tablegen" + [[language]] name = "markdown" scope = "source.md" diff --git a/runtime/queries/tablegen/highlights.scm b/runtime/queries/tablegen/highlights.scm new file mode 100644 index 00000000..8ade5ba9 --- /dev/null +++ b/runtime/queries/tablegen/highlights.scm @@ -0,0 +1,90 @@ +[ + (comment) + (multiline_comment) +] @comment + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "<" + ">" +] @punctuation.bracket + +[ + "," + ";" + "." +] @punctuation.delimiter + +[ + "#" + "-" + "..." + ":" +] @operator + +[ + "=" + "!cond" + (operator_keyword) +] @function + +[ + "true" + "false" +] @constant.builtin.boolean + +[ + "?" +] @constant.builtin + +(var) @variable + +(template_arg (identifier) @variable.parameter) + +(_ argument: (value (identifier) @variable.parameter)) + +(type) @type + +"code" @type.builtin + +(number) @constant.numeric.integer +[ + (string_string) + (code_string) +] @string + +(preprocessor) @keyword.directive + +[ + "class" + "field" + "let" + "defvar" + "def" + "defset" + "defvar" + "assert" +] @keyword + +[ + "let" + "in" + "foreach" + "if" + "then" + "else" +] @keyword.operator + +"include" @keyword.control.import + +[ + "multiclass" + "defm" +] @namespace + +(ERROR) @error diff --git a/runtime/queries/tablegen/indents.toml b/runtime/queries/tablegen/indents.toml new file mode 100644 index 00000000..43532f4d --- /dev/null +++ b/runtime/queries/tablegen/indents.toml @@ -0,0 +1,7 @@ +indent = [ + "statement", +] + +outdent = [ + "}", +] diff --git a/runtime/queries/tablegen/injections.scm b/runtime/queries/tablegen/injections.scm new file mode 100644 index 00000000..0b476f86 --- /dev/null +++ b/runtime/queries/tablegen/injections.scm @@ -0,0 +1,2 @@ +([ (comment) (multiline_comment)] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/tablegen/textobjects.scm b/runtime/queries/tablegen/textobjects.scm new file mode 100644 index 00000000..2cb80268 --- /dev/null +++ b/runtime/queries/tablegen/textobjects.scm @@ -0,0 +1,7 @@ +(class + body: (_) @class.inside) @class.around + +(multiclass + body: (_) @class.inside) @class.around + +(_ argument: _ @parameter.inside) -- cgit v1.2.3-70-g09d2 From 641255ccc83648d164bf6e8e8e4e93460591830b Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Tue, 4 Jan 2022 02:52:34 +0100 Subject: Add llvm-mir highlighting (#1398) * Add injection regex for more languages To support embedding them in other languages like markdown. * Add llvm-mir highlighting LLVM Machine IR is dumped as yaml files that can embed LLVM IR and Machine IR. To support this, add a llvm-mir-yaml language that uses the yaml parser, but uses different injections to highlight IR and MIR. * Update submodule with fixed multiline comments Co-authored-by: Blaž Hrastnik --- .gitmodules | 4 + book/src/generated/lang-support.md | 2 + helix-core/src/indent.rs | 1 + helix-core/src/syntax.rs | 13 ++- helix-syntax/languages/tree-sitter-llvm-mir | 1 + languages.toml | 22 +++++ runtime/queries/llvm-mir-yaml/highlights.scm | 1 + runtime/queries/llvm-mir-yaml/indents.toml | 3 + runtime/queries/llvm-mir-yaml/injections.scm | 9 ++ runtime/queries/llvm-mir/highlights.scm | 136 +++++++++++++++++++++++++++ runtime/queries/llvm-mir/indents.toml | 7 ++ runtime/queries/llvm-mir/injections.scm | 2 + runtime/queries/llvm-mir/textobjects.scm | 3 + runtime/queries/yaml/injections.scm | 2 + 14 files changed, 203 insertions(+), 3 deletions(-) create mode 160000 helix-syntax/languages/tree-sitter-llvm-mir create mode 100644 runtime/queries/llvm-mir-yaml/highlights.scm create mode 100644 runtime/queries/llvm-mir-yaml/indents.toml create mode 100644 runtime/queries/llvm-mir-yaml/injections.scm create mode 100644 runtime/queries/llvm-mir/highlights.scm create mode 100644 runtime/queries/llvm-mir/indents.toml create mode 100644 runtime/queries/llvm-mir/injections.scm create mode 100644 runtime/queries/llvm-mir/textobjects.scm create mode 100644 runtime/queries/yaml/injections.scm (limited to 'helix-syntax/languages') diff --git a/.gitmodules b/.gitmodules index b617e60c..9297708a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -174,6 +174,10 @@ path = helix-syntax/languages/tree-sitter-git-commit url = https://github.com/the-mikedavis/tree-sitter-git-commit.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-llvm-mir"] + path = helix-syntax/languages/tree-sitter-llvm-mir + url = https://github.com/Flakebi/tree-sitter-llvm-mir.git + shallow = true [submodule "helix-syntax/languages/tree-sitter-git-diff"] path = helix-syntax/languages/tree-sitter-git-diff url = https://github.com/the-mikedavis/tree-sitter-git-diff.git diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 73712ff2..ee719b56 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -24,6 +24,8 @@ | latex | ✓ | | | | | ledger | ✓ | | | | | llvm | ✓ | ✓ | ✓ | | +| llvm-mir | ✓ | ✓ | ✓ | | +| llvm-mir-yaml | ✓ | | ✓ | | | lua | ✓ | | ✓ | | | markdown | ✓ | | | | | mint | | | | `mint` | diff --git a/helix-core/src/indent.rs b/helix-core/src/indent.rs index 28066aa6..1fc2b8a5 100644 --- a/helix-core/src/indent.rs +++ b/helix-core/src/indent.rs @@ -436,6 +436,7 @@ where comment_token: None, auto_format: false, diagnostic_severity: Severity::Warning, + tree_sitter_library: None, language_server: None, indent: Some(IndentationConfiguration { tab_width: 4, diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index cdae0210..5d37c219 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -67,6 +67,8 @@ pub struct LanguageConfiguration { #[serde(default)] pub diagnostic_severity: Severity, + pub tree_sitter_library: Option, // tree-sitter library name, defaults to language_id + // content_regex #[serde(default, skip_serializing, deserialize_with = "deserialize_regex")] pub injection_regex: Option, @@ -192,9 +194,14 @@ impl LanguageConfiguration { if highlights_query.is_empty() { None } else { - let language = get_language(&crate::RUNTIME_DIR, &self.language_id) - .map_err(|e| log::info!("{}", e)) - .ok()?; + let language = get_language( + &crate::RUNTIME_DIR, + self.tree_sitter_library + .as_deref() + .unwrap_or(&self.language_id), + ) + .map_err(|e| log::info!("{}", e)) + .ok()?; let config = HighlightConfiguration::new( language, &highlights_query, diff --git a/helix-syntax/languages/tree-sitter-llvm-mir b/helix-syntax/languages/tree-sitter-llvm-mir new file mode 160000 index 00000000..06fabca1 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-llvm-mir @@ -0,0 +1 @@ +Subproject commit 06fabca19454b2dc00c1b211a7cb7ad0bc2585f1 diff --git a/languages.toml b/languages.toml index 7a895a60..e8329fe7 100644 --- a/languages.toml +++ b/languages.toml @@ -334,6 +334,7 @@ file-types = ["yml", "yaml"] roots = [] comment-token = "#" indent = { tab-width = 2, unit = " " } +injection-regex = "yml|yaml" # [[language]] # name = "haskell" @@ -386,6 +387,7 @@ roots = [] comment-token = "#" indent = { tab-width = 2, unit = " " } language-server = { command = "cmake-language-server" } +injection-regex = "cmake" [[language]] name = "glsl" @@ -394,6 +396,7 @@ file-types = ["glsl", "vert", "tesc", "tese", "geom", "frag", "comp" ] roots = [] comment-token = "//" indent = { tab-width = 4, unit = " " } +injection-regex = "glsl" [[language]] name = "perl" @@ -435,6 +438,25 @@ roots = [] file-types = ["ll"] comment-token = ";" indent = { tab-width = 2, unit = " " } +injection-regex = "llvm" + +[[language]] +name = "llvm-mir" +scope = "source.llvm_mir" +roots = [] +file-types = [] +comment-token = ";" +indent = { tab-width = 2, unit = " " } +injection-regex = "mir" + +[[language]] +name = "llvm-mir-yaml" +tree-sitter-library = "yaml" +scope = "source.yaml" +roots = [] +file-types = ["mir"] +comment-token = "#" +indent = { tab-width = 2, unit = " " } [[language]] name = "tablegen" diff --git a/runtime/queries/llvm-mir-yaml/highlights.scm b/runtime/queries/llvm-mir-yaml/highlights.scm new file mode 100644 index 00000000..4ba254e8 --- /dev/null +++ b/runtime/queries/llvm-mir-yaml/highlights.scm @@ -0,0 +1 @@ +; inherits: yaml diff --git a/runtime/queries/llvm-mir-yaml/indents.toml b/runtime/queries/llvm-mir-yaml/indents.toml new file mode 100644 index 00000000..ddc3578b --- /dev/null +++ b/runtime/queries/llvm-mir-yaml/indents.toml @@ -0,0 +1,3 @@ +indent = [ + "block_mapping_pair", +] diff --git a/runtime/queries/llvm-mir-yaml/injections.scm b/runtime/queries/llvm-mir-yaml/injections.scm new file mode 100644 index 00000000..b3243022 --- /dev/null +++ b/runtime/queries/llvm-mir-yaml/injections.scm @@ -0,0 +1,9 @@ +; inherits: yaml + +((document (block_node (block_scalar) @injection.content)) + (#set! injection.language "llvm")) + +((document (block_node (block_mapping (block_mapping_pair + key: (flow_node (plain_scalar (string_scalar))) ; "body" + value: (block_node (block_scalar) @injection.content))))) + (#set! injection.language "mir")) diff --git a/runtime/queries/llvm-mir/highlights.scm b/runtime/queries/llvm-mir/highlights.scm new file mode 100644 index 00000000..79234612 --- /dev/null +++ b/runtime/queries/llvm-mir/highlights.scm @@ -0,0 +1,136 @@ +[ + (label) + (bb_ref) +] @label + +[ + (comment) + (multiline_comment) +] @comment + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "<" + ">" +] @punctuation.bracket + +[ + "," + ":" + "|" + "*" +] @punctuation.delimiter + +[ + "=" + "x" +] @operator + +[ + "true" + "false" +] @constant.builtin.boolean + +[ + "null" + "_" + "unknown-address" +] @constant.builtin + +[ + (stack_object) + (constant_pool_index) + (jump_table_index) + (var) + (physical_register) + (ir_block) + (external_symbol) + (global_var) + (ir_local_var) + (metadata_ref) + (mnemonic) +] @variable + +(low_level_type) @type + +[ + (immediate_type) + (primitive_type) +] @type.builtin + +(number) @constant.numeric.integer +(float) @constant.numeric.float +(string) @string + +(instruction name: _ @keyword.operator) + +[ + "successors" + "liveins" + "pre-instr-symbol" + "post-instr-symbol" + "heap-alloc-marker" + "debug-instr-number" + "debug-location" + "mcsymbol" + "tied-def" + "target-flags" + "CustomRegMask" + "same_value" + "def_cfa_register" + "restore" + "undefined" + "offset" + "rel_offset" + "def_cfa" + "llvm_def_aspace_cfa" + "register" + "escape" + "remember_state" + "restore_state" + "window_save" + "negate_ra_sign_state" + "intpred" + "floatpred" + "shufflemask" + "liveout" + "target-index" + "blockaddress" + "intrinsic" + "load" + "store" + "unknown-size" + "on" + "from" + "into" + "align" + "basealign" + "addrspace" + "call-entry" + "custom" + "constant-pool" + "stack" + "got" + "jump-table" + "syncscope" + "address-taken" + "landing-pad" + "inlineasm-br-indirect-target" + "ehfunclet-entry" + "bbsections" + + (intpred) + (floatpred) + (memory_operand_flag) + (atomic_ordering) + (register_flag) + (instruction_flag) + (float_keyword) +] @keyword + +(ERROR) @error diff --git a/runtime/queries/llvm-mir/indents.toml b/runtime/queries/llvm-mir/indents.toml new file mode 100644 index 00000000..6a70e5ad --- /dev/null +++ b/runtime/queries/llvm-mir/indents.toml @@ -0,0 +1,7 @@ +indent = [ + "basic_block", +] + +outdent = [ + "label", +] diff --git a/runtime/queries/llvm-mir/injections.scm b/runtime/queries/llvm-mir/injections.scm new file mode 100644 index 00000000..0b476f86 --- /dev/null +++ b/runtime/queries/llvm-mir/injections.scm @@ -0,0 +1,2 @@ +([ (comment) (multiline_comment)] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/llvm-mir/textobjects.scm b/runtime/queries/llvm-mir/textobjects.scm new file mode 100644 index 00000000..73f6f772 --- /dev/null +++ b/runtime/queries/llvm-mir/textobjects.scm @@ -0,0 +1,3 @@ +(basic_block) @function.around + +(argument) @parameter.inside diff --git a/runtime/queries/yaml/injections.scm b/runtime/queries/yaml/injections.scm new file mode 100644 index 00000000..39bda293 --- /dev/null +++ b/runtime/queries/yaml/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) -- cgit v1.2.3-70-g09d2 From a8fd33ac012a79069ef1409503a2edcf3a585153 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Thu, 6 Jan 2022 09:00:00 -0600 Subject: add tree-sitter-regex (#1362) * add tree-sitter-regex * adapt regex highlights from upstream * inject regex into elixir sigil_r/2 and sigil_R/2 * generate lang-support docs * capture interesting nodes in character-ranges * make $.character_class captures more consistent * fix fallthrough behavior for character classes * capture pattern characters as 'string' * use latest tree-sitter-regex * set elixir regex injections as combined * add link to upstream queries * inject regex in rust into 'Regex::new' raw string literals--- .gitmodules | 4 +++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-regex | 1 + languages.toml | 7 +++++ runtime/queries/elixir/injections.scm | 7 +++++ runtime/queries/regex/highlights.scm | 53 ++++++++++++++++++++++++++++++++ runtime/queries/rust/injections.scm | 14 +++++++++ 7 files changed, 87 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-regex create mode 100644 runtime/queries/regex/highlights.scm (limited to 'helix-syntax/languages') diff --git a/.gitmodules b/.gitmodules index 9297708a..f6a0fdc4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -190,3 +190,7 @@ path = helix-syntax/languages/tree-sitter-git-rebase url = https://github.com/the-mikedavis/tree-sitter-git-rebase.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-regex"] + path = helix-syntax/languages/tree-sitter-regex + url = https://github.com/tree-sitter/tree-sitter-regex.git + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index a1fbf172..daf8b006 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -38,6 +38,7 @@ | protobuf | ✓ | | ✓ | | | python | ✓ | ✓ | ✓ | `pylsp` | | racket | | | | `racket` | +| regex | ✓ | | | | | ruby | ✓ | | ✓ | `solargraph` | | rust | ✓ | ✓ | ✓ | `rust-analyzer` | | scala | ✓ | | ✓ | `metals` | diff --git a/helix-syntax/languages/tree-sitter-regex b/helix-syntax/languages/tree-sitter-regex new file mode 160000 index 00000000..e1cfca3c --- /dev/null +++ b/helix-syntax/languages/tree-sitter-regex @@ -0,0 +1 @@ +Subproject commit e1cfca3c79896ff79842f057ea13e529b66af636 diff --git a/languages.toml b/languages.toml index e8329fe7..3e2e7b15 100644 --- a/languages.toml +++ b/languages.toml @@ -530,3 +530,10 @@ file-types = ["git-rebase-todo"] injection-regex = "git-rebase" comment-token = "#" indent = { tab-width = 2, unit = " " } + +[[language]] +name = "regex" +scope = "source.regex" +injection-regex = "regex" +file-types = ["regex"] +roots = [] diff --git a/runtime/queries/elixir/injections.scm b/runtime/queries/elixir/injections.scm index 321c90ad..8370a0d8 100644 --- a/runtime/queries/elixir/injections.scm +++ b/runtime/queries/elixir/injections.scm @@ -1,2 +1,9 @@ ((comment) @injection.content (#set! injection.language "comment")) + +((sigil + (sigil_name) @_sigil_name + (quoted_content) @injection.content) + (#match? @_sigil_name "^(r|R)$") + (#set! injection.language "regex") + (#set! injection.combined)) diff --git a/runtime/queries/regex/highlights.scm b/runtime/queries/regex/highlights.scm new file mode 100644 index 00000000..9376caa9 --- /dev/null +++ b/runtime/queries/regex/highlights.scm @@ -0,0 +1,53 @@ +; upstream: https://github.com/tree-sitter/tree-sitter-regex/blob/e1cfca3c79896ff79842f057ea13e529b66af636/queries/highlights.scm + +[ + "(" + ")" + "(?" + "(?:" + "(?<" + ">" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "*" + "+" + "|" + "=" + "<=" + "!" + "" - "=>" ".?" ".*" - "=" "?" ] @operator diff --git a/runtime/queries/zig/indents.toml b/runtime/queries/zig/indents.toml index 88f88e16..36ba8e55 100644 --- a/runtime/queries/zig/indents.toml +++ b/runtime/queries/zig/indents.toml @@ -3,6 +3,9 @@ indent = [ "BlockExpr", "ContainerDecl", "SwitchExpr", + "AssignExpr", + "ErrorUnionExpr", + "Statement", "InitList" ] -- cgit v1.2.3-70-g09d2 From dd1f64d4dc6fa7a5a8f0b6404e7d30cedcb5b10a Mon Sep 17 00:00:00 2001 From: Daniel S Poulin Date: Sat, 15 Jan 2022 20:11:47 -0500 Subject: Update tree-sitter-php to latest upstream (#1521) Brings in PHP 8.1 features, like enums, union types and the like.--- helix-syntax/languages/tree-sitter-php | 2 +- runtime/queries/php/highlights.scm | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'helix-syntax/languages') diff --git a/helix-syntax/languages/tree-sitter-php b/helix-syntax/languages/tree-sitter-php index 0d63eaf9..57f85546 160000 --- a/helix-syntax/languages/tree-sitter-php +++ b/helix-syntax/languages/tree-sitter-php @@ -1 +1 @@ -Subproject commit 0d63eaf94e8d6c0694551b016c802787e61b3fb2 +Subproject commit 57f855461aeeca73bd4218754fb26b5ac143f98f diff --git a/runtime/queries/php/highlights.scm b/runtime/queries/php/highlights.scm index 46b5d26c..5379fa1e 100644 --- a/runtime/queries/php/highlights.scm +++ b/runtime/queries/php/highlights.scm @@ -5,7 +5,8 @@ (primitive_type) @type.builtin (cast_type) @type.builtin -(type_name (name) @type) +(named_type (name) @type) @type +(named_type (qualified_name) @type) @type ; Functions @@ -85,10 +86,12 @@ "endif" @keyword "endswitch" @keyword "endwhile" @keyword +"enum" @keyword "extends" @keyword "final" @keyword "finally" @keyword "foreach" @keyword +"fn" @keyword "function" @keyword "global" @keyword "if" @keyword @@ -97,6 +100,7 @@ "include" @keyword "insteadof" @keyword "interface" @keyword +"match" @keyword "namespace" @keyword "new" @keyword "private" @keyword -- cgit v1.2.3-70-g09d2 From 8ea5742b0899992cd7453c70a8a06cb76a703fdf Mon Sep 17 00:00:00 2001 From: Anders Christiansen Sørby Date: Mon, 17 Jan 2022 15:05:17 +0100 Subject: feat(languages): Lean experimental tree-sitter-lean (#1422) * Add experimental tree-sitter-lean * Run docgen * Copy over the queries from lean.nvim * Update .gitmodules Co-authored-by: Ivan Tham * Update lean highlights and run docgen * Update runtime/queries/lean/injections.scm Co-authored-by: Michael Davis * Lean: Move variable matcher to bottom * Update runtime/queries/lean/locals.scm Co-authored-by: Michael Davis Co-authored-by: Ivan Tham Co-authored-by: Michael Davis --- .gitmodules | 4 + book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-lean | 1 + languages.toml | 11 ++ runtime/queries/lean/folds.scm | 15 +++ runtime/queries/lean/highlights.scm | 217 ++++++++++++++++++++++++++++++++ runtime/queries/lean/injections.scm | 2 + runtime/queries/lean/locals.scm | 5 + 8 files changed, 256 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-lean create mode 100644 runtime/queries/lean/folds.scm create mode 100644 runtime/queries/lean/highlights.scm create mode 100644 runtime/queries/lean/injections.scm create mode 100644 runtime/queries/lean/locals.scm (limited to 'helix-syntax/languages') diff --git a/.gitmodules b/.gitmodules index 3442652a..1ccbe43b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -190,6 +190,10 @@ path = helix-syntax/languages/tree-sitter-git-rebase url = https://github.com/the-mikedavis/tree-sitter-git-rebase.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-lean"] + path = helix-syntax/languages/tree-sitter-lean + url = https://github.com/Julian/tree-sitter-lean + shallow = true [submodule "helix-syntax/languages/tree-sitter-regex"] path = helix-syntax/languages/tree-sitter-regex url = https://github.com/tree-sitter/tree-sitter-regex.git diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 87347819..fce14846 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -24,6 +24,7 @@ | json | ✓ | | ✓ | | | julia | ✓ | | | `julia` | | latex | ✓ | | | | +| lean | ✓ | | | `lean` | | ledger | ✓ | | | | | llvm | ✓ | ✓ | ✓ | | | llvm-mir | ✓ | ✓ | ✓ | | diff --git a/helix-syntax/languages/tree-sitter-lean b/helix-syntax/languages/tree-sitter-lean new file mode 160000 index 00000000..d9842610 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-lean @@ -0,0 +1 @@ +Subproject commit d98426109258b266e1e92358c5f11716d2e8f638 diff --git a/languages.toml b/languages.toml index af15c654..2896dd32 100644 --- a/languages.toml +++ b/languages.toml @@ -241,6 +241,17 @@ comment-token = "%" indent = { tab-width = 4, unit = "\t" } +[[language]] +name = "lean" +scope = "source.lean" +injection-regex = "lean" +file-types = ["lean"] +roots = [ "lakefile.lean" ] +comment-token = "--" +language-server = { command = "lean", args = [ "--server" ] } + +indent = { tab-width = 2, unit = " " } + [[language]] name = "julia" scope = "source.julia" diff --git a/runtime/queries/lean/folds.scm b/runtime/queries/lean/folds.scm new file mode 100644 index 00000000..2c2bbb33 --- /dev/null +++ b/runtime/queries/lean/folds.scm @@ -0,0 +1,15 @@ +[ + (namespace) + (section) + + (instance) + (def) + (theorem) + (example) + + (product) + (array) + (list) + + (string) +] @fold diff --git a/runtime/queries/lean/highlights.scm b/runtime/queries/lean/highlights.scm new file mode 100644 index 00000000..a64feb1d --- /dev/null +++ b/runtime/queries/lean/highlights.scm @@ -0,0 +1,217 @@ +(open + namespace: (identifier) @namespace) +(namespace + name: (identifier) @namespace) +(section + name: (identifier) @namespace) + +;; Identifier naming conventions +((identifier) @type + (#match? @type "^[A-Z]")) + +(arrow) @type +(product) @type + +;; Declarations + +[ + "abbrev" + "def" + "theorem" + "constant" + "instance" + "axiom" + "example" + "inductive" + "structure" + "class" + + "deriving" + + "section" + "namespace" +] @keyword + +(attributes + (identifier) @function) + +(abbrev + name: (identifier) @type) +(def + name: (identifier) @function) +(theorem + name: (identifier) @function) +(constant + name: (identifier) @type) +(instance + name: (identifier) @function) +(instance + type: (identifier) @type) +(axiom + name: (identifier) @function) +(structure + name: (identifier) @type) +(structure + extends: (identifier) @type) + +(where_decl + type: (identifier) @type) + +(proj + name: (identifier) @field) + +(binders + type: (identifier) @type) + +["if" "then" "else"] @keyword.control.conditional + +["for" "in" "do"] @keyword.control.repeat + +(import) @include + +; Tokens + +[ + "!" + "$" + "%" + "&&" + "*" + "*>" + "+" + "++" + "-" + "/" + "::" + ":=" + "<" + "<$>" + "<*" + "<*>" + "<=" + "<|" + "<|>" + "=" + "==" + "=>" + ">" + ">" + ">=" + ">>" + ">>=" + "@" + "^" + "|>" + "|>." + "||" + "←" + "→" + "↔" + "∘" + "∧" + "∨" + "≠" + "≤" + "≥" +] @operator + +[ + "@&" +] @operator + +[ + "attribute" + "by" + "end" + "export" + "extends" + "fun" + "let" + "have" + "match" + "open" + "return" + "universe" + "variable" + "where" + "with" + "λ" + (hash_command) + (prelude) + (sorry) +] @keyword + +[ + "prefix" + "infix" + "infixl" + "infixr" + "postfix" + "notation" + "macro_rules" + "syntax" + "elab" + "builtin_initialize" +] @keyword + +[ + "noncomputable" + "partial" + "private" + "protected" + "unsafe" +] @keyword + +[ + "apply" + "exact" + "rewrite" + "rw" + "simp" + (trivial) +] @keyword + +[ + "catch" + "finally" + "try" +] @exception + +((apply + name: (identifier) @exception) + (#match? @exception "throw")) + +[ + "unless" + "mut" +] @keyword + +[(true) (false)] @boolean + +(number) @constant.numeric.integer +(float) @constant.numeric.float + +(comment) @comment +(char) @character +(string) @string +(interpolated_string) @string +; (escape_sequence) @string.escape + +; Reset highlighing in string interpolation +(interpolation) @none + +(interpolation + "{" @punctuation.special + "}" @punctuation.special) + +["(" ")" "[" "]" "{" "}" "⟨" "⟩"] @punctuation.bracket + +["|" "," "." ":" ";"] @punctuation.delimiter + +(sorry) @error + +;; Error +(ERROR) @error + +; Variables +(identifier) @variable diff --git a/runtime/queries/lean/injections.scm b/runtime/queries/lean/injections.scm new file mode 100644 index 00000000..030714f1 --- /dev/null +++ b/runtime/queries/lean/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "markdown")) diff --git a/runtime/queries/lean/locals.scm b/runtime/queries/lean/locals.scm new file mode 100644 index 00000000..dd6c2036 --- /dev/null +++ b/runtime/queries/lean/locals.scm @@ -0,0 +1,5 @@ +[ + (module) + (namespace) + (section) +] @local.scope -- cgit v1.2.3-70-g09d2 From b2c8aa1ee709edcd5302b27f6d6467b7b624ca84 Mon Sep 17 00:00:00 2001 From: Jared Ramirez Date: Thu, 20 Jan 2022 07:47:23 -0800 Subject: feat(languages): Elm (#1514) * Add Elm language support * Fix docs gen * Updates based on PR feedback--- .gitmodules | 4 ++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-elm | 1 + languages.toml | 11 +++++ runtime/queries/elm/highlights.scm | 83 ++++++++++++++++++++++++++++++++++ runtime/queries/elm/injections.scm | 4 ++ runtime/queries/elm/locals.scm | 14 ++++++ runtime/queries/elm/tags.scm | 19 ++++++++ 8 files changed, 137 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-elm create mode 100644 runtime/queries/elm/highlights.scm create mode 100644 runtime/queries/elm/injections.scm create mode 100644 runtime/queries/elm/locals.scm create mode 100644 runtime/queries/elm/tags.scm (limited to 'helix-syntax/languages') diff --git a/.gitmodules b/.gitmodules index 1ccbe43b..118fa2d8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -206,3 +206,7 @@ path = helix-syntax/languages/tree-sitter-git-config url = https://github.com/the-mikedavis/tree-sitter-git-config.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-elm"] + path = helix-syntax/languages/tree-sitter-elm + url = https://github.com/elm-tooling/tree-sitter-elm + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index fce14846..bfaac97b 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -10,6 +10,7 @@ | dart | ✓ | | ✓ | `dart` | | dockerfile | ✓ | | | `docker-langserver` | | elixir | ✓ | | | `elixir-ls` | +| elm | ✓ | | | `elm-language-server` | | fish | ✓ | ✓ | ✓ | | | git-commit | ✓ | | | | | git-config | ✓ | | | | diff --git a/helix-syntax/languages/tree-sitter-elm b/helix-syntax/languages/tree-sitter-elm new file mode 160000 index 00000000..bd50ccf6 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-elm @@ -0,0 +1 @@ +Subproject commit bd50ccf66b42c55252ac8efc1086af4ac6bab8cd diff --git a/languages.toml b/languages.toml index 2896dd32..ea93df3a 100644 --- a/languages.toml +++ b/languages.toml @@ -567,3 +567,14 @@ file-types = [".gitmodules", ".gitconfig"] injection-regex = "git-config" comment-token = "#" indent = { tab-width = 4, unit = "\t" } + +[[language]] +name = "elm" +scope = "source.elm" +injection-regex = "elm" +file-types = ["elm"] +roots = ["elm.json"] +auto-format = true +comment-token = "--" +language-server = { command = "elm-language-server" } +indent = { tab-width = 4, unit = " " } diff --git a/runtime/queries/elm/highlights.scm b/runtime/queries/elm/highlights.scm new file mode 100644 index 00000000..3c8fd12d --- /dev/null +++ b/runtime/queries/elm/highlights.scm @@ -0,0 +1,83 @@ +; Keywords +[ + "if" + "then" + "else" + "let" + "in" + ] @keyword.control +(case) @keyword.control +(of) @keyword.control + +(colon) @keyword.operator +(backslash) @keyword +(as) @keyword +(port) @keyword +(exposing) @keyword +(alias) @keyword +(infix) @keyword + +(arrow) @keyword.operator +(dot) @keyword.operator + +(port) @keyword + +(type_annotation(lower_case_identifier) @function) +(port_annotation(lower_case_identifier) @function) +(file (value_declaration (function_declaration_left(lower_case_identifier) @function))) + +(field name: (lower_case_identifier) @attribute) +(field_access_expr(lower_case_identifier) @attribute) + +(operator_identifier) @keyword.operator +(eq) @keyword.operator.assignment + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +"|" @keyword +"," @punctuation.delimiter + +[ + "|>" +] @keyword + + +(import) @keyword.contol.import +(module) @keyword.other + +(number_constant_expr) @constant.numeric + +(type) @type + +(type_declaration(upper_case_identifier) @type) +(type_ref) @type +(type_alias_declaration name: (upper_case_identifier) @type) + +(union_pattern constructor: (upper_case_qid (upper_case_identifier) @label (dot) (upper_case_identifier) @variable.other.member)) +(union_pattern constructor: (upper_case_qid (upper_case_identifier) @variable.other.member)) + +(union_variant(upper_case_identifier) @variable.other.member) +(value_expr name: (value_qid (upper_case_identifier) @label)) +(value_expr (upper_case_qid (upper_case_identifier) @label (dot) (upper_case_identifier) @variable.other.member)) +(value_expr(upper_case_qid(upper_case_identifier)) @variable.other.member) + +; comments +(line_comment) @comment +(block_comment) @comment + +; strings +(string_escape) @constant.character.escape + +(open_quote) @string +(close_quote) @string +(regular_string_part) @string + +(open_char) @constant.character +(close_char) @constant.character diff --git a/runtime/queries/elm/injections.scm b/runtime/queries/elm/injections.scm new file mode 100644 index 00000000..83f8245c --- /dev/null +++ b/runtime/queries/elm/injections.scm @@ -0,0 +1,4 @@ +; Parse glsl where defined + +((glsl_content) @injection.content + (#set! injection.language "glsl")) diff --git a/runtime/queries/elm/locals.scm b/runtime/queries/elm/locals.scm new file mode 100644 index 00000000..ab103115 --- /dev/null +++ b/runtime/queries/elm/locals.scm @@ -0,0 +1,14 @@ +(value_declaration) @local.scope +(type_alias_declaration) @local.scope +(type_declaration) @local.scope +(type_annotation) @local.scope +(port_annotation) @local.scope +(infix_declaration) @local.scope +(let_in_expr) @local.scope + +(function_declaration_left (lower_pattern (lower_case_identifier)) @local.definition) +(function_declaration_left (lower_case_identifier) @local.definition) + +(value_expr(value_qid(upper_case_identifier)) @local.reference) +(value_expr(value_qid(lower_case_identifier)) @local.reference) +(type_ref (upper_case_qid) @local.reference) diff --git a/runtime/queries/elm/tags.scm b/runtime/queries/elm/tags.scm new file mode 100644 index 00000000..03999fb1 --- /dev/null +++ b/runtime/queries/elm/tags.scm @@ -0,0 +1,19 @@ +(value_declaration (function_declaration_left (lower_case_identifier) @name)) @definition.function + +(function_call_expr (value_expr (value_qid) @name)) @reference.function +(exposed_value (lower_case_identifier) @name) @reference.function +(type_annotation ((lower_case_identifier) @name) (colon)) @reference.function + +(type_declaration ((upper_case_identifier) @name) ) @definition.type + +(type_ref (upper_case_qid (upper_case_identifier) @name)) @reference.type +(exposed_type (upper_case_identifier) @name) @reference.type + +(type_declaration (union_variant (upper_case_identifier) @name)) @definition.union + +(value_expr (upper_case_qid (upper_case_identifier) @name)) @reference.union + + +(module_declaration + (upper_case_qid (upper_case_identifier)) @name +) @definition.module -- cgit v1.2.3-70-g09d2 From 0b55b21f3069640d37d2fa34bd413986177c0cd7 Mon Sep 17 00:00:00 2001 From: Jared Ramirez Date: Fri, 21 Jan 2022 06:16:40 -0800 Subject: feat(languages): GraphQL (#1515) * Add Graphql language support * Fix docs gen * Add JS Graphql injection query * Updates based on PR feedback Co-authored-by: Blaž Hrastnik --- .gitmodules | 4 + book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-graphql | 1 + languages.toml | 8 ++ runtime/queries/graphql/highlights.scm | 163 +++++++++++++++++++++++++++++ runtime/queries/javascript/injections.scm | 8 ++ 6 files changed, 185 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-graphql create mode 100644 runtime/queries/graphql/highlights.scm (limited to 'helix-syntax/languages') diff --git a/.gitmodules b/.gitmodules index 118fa2d8..780d1b63 100644 --- a/.gitmodules +++ b/.gitmodules @@ -206,6 +206,10 @@ path = helix-syntax/languages/tree-sitter-git-config url = https://github.com/the-mikedavis/tree-sitter-git-config.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-graphql"] + path = helix-syntax/languages/tree-sitter-graphql + url = https://github.com/bkegley/tree-sitter-graphql + shallow = true [submodule "helix-syntax/languages/tree-sitter-elm"] path = helix-syntax/languages/tree-sitter-elm url = https://github.com/elm-tooling/tree-sitter-elm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index bfaac97b..fa8aa3ef 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -18,6 +18,7 @@ | git-rebase | ✓ | | | | | glsl | ✓ | | ✓ | | | go | ✓ | ✓ | ✓ | `gopls` | +| graphql | ✓ | | | | | haskell | ✓ | | | | | html | ✓ | | | | | java | ✓ | | | | diff --git a/helix-syntax/languages/tree-sitter-graphql b/helix-syntax/languages/tree-sitter-graphql new file mode 160000 index 00000000..5e66e961 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-graphql @@ -0,0 +1 @@ +Subproject commit 5e66e961eee421786bdda8495ed1db045e06b5fe diff --git a/languages.toml b/languages.toml index ea93df3a..f9362eac 100644 --- a/languages.toml +++ b/languages.toml @@ -568,6 +568,14 @@ injection-regex = "git-config" comment-token = "#" indent = { tab-width = 4, unit = "\t" } +[[language]] +name = "graphql" +scope = "source.graphql" +injection-regex = "graphql" +file-types = ["gql", "graphql"] +roots = [] +indent = { tab-width = 2, unit = " " } + [[language]] name = "elm" scope = "source.elm" diff --git a/runtime/queries/graphql/highlights.scm b/runtime/queries/graphql/highlights.scm new file mode 100644 index 00000000..9fab4051 --- /dev/null +++ b/runtime/queries/graphql/highlights.scm @@ -0,0 +1,163 @@ +; Types +;------ + +(scalar_type_definition + (name) @type) + +(object_type_definition + (name) @type) + +(interface_type_definition + (name) @type) + +(union_type_definition + (name) @type) + +(enum_type_definition + (name) @type) + +(input_object_type_definition + (name) @type) + +(directive_definition + (name) @type) + +(directive_definition + "@" @type) + +(scalar_type_extension + (name) @type) + +(object_type_extension + (name) @type) + +(interface_type_extension + (name) @type) + +(union_type_extension + (name) @type) + +(enum_type_extension + (name) @type) + +(input_object_type_extension + (name) @type) + +(named_type + (name) @type) + +(directive) @type + +; Properties +;----------- + +(field + (name) @variable.other.member) + +(field + (alias + (name) @variable.other.member)) + +(field_definition + (name) @variable.other.member) + +(object_value + (object_field + (name) @variable.other.member)) + +(enum_value + (name) @variable.other.member) + +; Variable Definitions and Arguments +;----------------------------------- + +(operation_definition + (name) @variable) + +(fragment_name + (name) @variable) + +(input_fields_definition + (input_value_definition + (name) @variable.parameter)) + +(argument + (name) @variable.parameter) + +(arguments_definition + (input_value_definition + (name) @variable.parameter)) + +(variable_definition + (variable) @variable.parameter) + +(argument + (value + (variable) @variable)) + +; Constants +;---------- + +(string_value) @string + +(int_value) @constants.numeric.integer + +(float_value) @constants.numeric.float + +(boolean_value) @constants.builtin.boolean + +; Literals +;--------- + +(description) @comment + +(comment) @comment + +(directive_location + (executable_directive_location) @type.builtin) + +(directive_location + (type_system_directive_location) @type.builtin) + +; Keywords +;---------- + +[ + "query" + "mutation" + "subscription" + "fragment" + "scalar" + "type" + "interface" + "union" + "enum" + "input" + "extend" + "directive" + "schema" + "on" + "repeatable" + "implements" +] @keyword + +; Punctuation +;------------ + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +"=" @operator + +"|" @punctuation.delimiter +"&" @punctuation.delimiter +":" @punctuation.delimiter + +"..." @punctuation.special +"!" @punctuation.special diff --git a/runtime/queries/javascript/injections.scm b/runtime/queries/javascript/injections.scm index 5539241a..e8429111 100644 --- a/runtime/queries/javascript/injections.scm +++ b/runtime/queries/javascript/injections.scm @@ -9,6 +9,14 @@ ] arguments: (template_string) @injection.content) +; Parse the contents of gql template literals + +((call_expression + function: (identifier) @_template_function_name + arguments: (template_string) @injection.content) + (#eq? @_template_function_name "gql") + (#set! injection.language "graphql")) + ; Parse regex syntax within regex literals ((regex_pattern) @injection.content -- cgit v1.2.3-70-g09d2 From 7bce91556afd2430c336f2fe4a6ce3f7ce555be2 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Tue, 25 Jan 2022 00:50:34 -0600 Subject: add tree-sitter-iex (#1576) * add tree-sitter-iex * run docgen task * fix url for iex submodule--- .gitmodules | 4 ++++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-iex | 1 + languages.toml | 7 +++++++ runtime/queries/iex/highlights.scm | 1 + runtime/queries/iex/injections.scm | 6 ++++++ 6 files changed, 20 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-iex create mode 100644 runtime/queries/iex/highlights.scm create mode 100644 runtime/queries/iex/injections.scm (limited to 'helix-syntax/languages') diff --git a/.gitmodules b/.gitmodules index 780d1b63..247ac276 100644 --- a/.gitmodules +++ b/.gitmodules @@ -214,3 +214,7 @@ path = helix-syntax/languages/tree-sitter-elm url = https://github.com/elm-tooling/tree-sitter-elm shallow = true +[submodule "helix-syntax/languages/tree-sitter-iex"] + path = helix-syntax/languages/tree-sitter-iex + url = https://github.com/elixir-lang/tree-sitter-iex + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index e4070117..eff82226 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -21,6 +21,7 @@ | graphql | ✓ | | | | | haskell | ✓ | | | `haskell-language-server-wrapper` | | html | ✓ | | | | +| iex | ✓ | | | | | java | ✓ | | | | | javascript | ✓ | | ✓ | `typescript-language-server` | | json | ✓ | | ✓ | | diff --git a/helix-syntax/languages/tree-sitter-iex b/helix-syntax/languages/tree-sitter-iex new file mode 160000 index 00000000..3ec55082 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-iex @@ -0,0 +1 @@ +Subproject commit 3ec55082cf0be015d03148be8edfdfa8c56e77f9 diff --git a/languages.toml b/languages.toml index a589d7b8..02c64732 100644 --- a/languages.toml +++ b/languages.toml @@ -586,3 +586,10 @@ auto-format = true comment-token = "--" language-server = { command = "elm-language-server" } indent = { tab-width = 4, unit = " " } + +[[language]] +name = "iex" +scope = "source.iex" +injection-regex = "iex" +file-types = ["iex"] +roots = [] diff --git a/runtime/queries/iex/highlights.scm b/runtime/queries/iex/highlights.scm new file mode 100644 index 00000000..2847fbff --- /dev/null +++ b/runtime/queries/iex/highlights.scm @@ -0,0 +1 @@ +(prompt) @comment diff --git a/runtime/queries/iex/injections.scm b/runtime/queries/iex/injections.scm new file mode 100644 index 00000000..48863d9d --- /dev/null +++ b/runtime/queries/iex/injections.scm @@ -0,0 +1,6 @@ +((evaluation_block (prompt_line (expression) @injection.content)) + (#set! injection.language "elixir") + (#set! injection.combined)) + +((result) @injection.content + (#set! injection.language "elixir")) -- cgit v1.2.3-70-g09d2 From d6b6ad879e297ff786ce520acd3ce9c4ff3c2e8e Mon Sep 17 00:00:00 2001 From: Daniel S Poulin Date: Mon, 31 Jan 2022 22:35:07 -0500 Subject: epocsquadron/add tree sitter twig (#1602) * Add tree-sitter-twig grammer and highlights The gammar itself is quite basic, but is much better than nothing for working with real files consisting mostly of html. * Docgen for newly added grammar--- .gitmodules | 4 ++++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-twig | 1 + languages.toml | 9 +++++++++ runtime/queries/twig/highlights.scm | 16 ++++++++++++++++ runtime/queries/twig/injections.scm | 3 +++ 6 files changed, 34 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-twig create mode 100644 runtime/queries/twig/highlights.scm create mode 100644 runtime/queries/twig/injections.scm (limited to 'helix-syntax/languages') diff --git a/.gitmodules b/.gitmodules index 247ac276..d35b0f33 100644 --- a/.gitmodules +++ b/.gitmodules @@ -218,3 +218,7 @@ path = helix-syntax/languages/tree-sitter-iex url = https://github.com/elixir-lang/tree-sitter-iex shallow = true +[submodule "helix-syntax/languages/tree-sitter-twig"] + path = helix-syntax/languages/tree-sitter-twig + url = https://github.com/eirabben/tree-sitter-twig.git + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 85371773..d10b56f1 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -54,6 +54,7 @@ | toml | ✓ | | | | | tsq | ✓ | | | | | tsx | ✓ | | | `typescript-language-server` | +| twig | ✓ | | | | | typescript | ✓ | | ✓ | `typescript-language-server` | | vue | ✓ | | | | | wgsl | ✓ | | | | diff --git a/helix-syntax/languages/tree-sitter-twig b/helix-syntax/languages/tree-sitter-twig new file mode 160000 index 00000000..b7444181 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-twig @@ -0,0 +1 @@ +Subproject commit b7444181fb38e603e25ea8fcdac55f9492e49c27 diff --git a/languages.toml b/languages.toml index 02c64732..74c01da5 100644 --- a/languages.toml +++ b/languages.toml @@ -231,6 +231,15 @@ roots = [] indent = { tab-width = 4, unit = " " } +[[language]] +name = "twig" +scope = "source.twig" +injection-regex = "twig" +file-types = ["twig"] +roots = [] + +indent = { tab-width = 2, unit = " " } + [[language]] name = "latex" scope = "source.tex" diff --git a/runtime/queries/twig/highlights.scm b/runtime/queries/twig/highlights.scm new file mode 100644 index 00000000..2c95ab63 --- /dev/null +++ b/runtime/queries/twig/highlights.scm @@ -0,0 +1,16 @@ +(comment_directive) @comment + +[ + "{%" + "{%-" + "{%~" + "%}" + "-%}" + "~%}" + "{{" + "{{-" + "{{~" + "}}" + "-}}" + "~}}" +] @keyword diff --git a/runtime/queries/twig/injections.scm b/runtime/queries/twig/injections.scm new file mode 100644 index 00000000..f0822734 --- /dev/null +++ b/runtime/queries/twig/injections.scm @@ -0,0 +1,3 @@ +((content) @injection.content + (#set! injection.language "html") + (#set! injection.combined)) -- cgit v1.2.3-70-g09d2 From f5b95beef69bbd8e627b6b0e7ea69317fd12b763 Mon Sep 17 00:00:00 2001 From: Jared Ramirez Date: Sat, 5 Feb 2022 21:24:01 -0800 Subject: feat(languages): rescript (#1616) * Add rescript language support * cargo xtask docgen * Add textobjects & file line ending * Fix text objects & rerun docgen * Fix textobjects queries--- .gitmodules | 4 + book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-rescript | 1 + languages.toml | 11 ++ runtime/queries/rescript/highlights.scm | 179 ++++++++++++++++++++++++++++ runtime/queries/rescript/injections.scm | 8 ++ runtime/queries/rescript/textobjects.scm | 9 ++ 7 files changed, 213 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-rescript create mode 100644 runtime/queries/rescript/highlights.scm create mode 100644 runtime/queries/rescript/injections.scm create mode 100644 runtime/queries/rescript/textobjects.scm (limited to 'helix-syntax/languages') diff --git a/.gitmodules b/.gitmodules index d35b0f33..55ed97b3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -222,3 +222,7 @@ path = helix-syntax/languages/tree-sitter-twig url = https://github.com/eirabben/tree-sitter-twig.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-rescript"] + path = helix-syntax/languages/tree-sitter-rescript + url = https://github.com/jaredramirez/tree-sitter-rescript + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index d10b56f1..64dab6d3 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -46,6 +46,7 @@ | python | ✓ | ✓ | ✓ | `pylsp` | | racket | | | | `racket` | | regex | ✓ | | | | +| rescript | ✓ | ✓ | | `rescript-language-server` | | ruby | ✓ | | ✓ | `solargraph` | | rust | ✓ | ✓ | ✓ | `rust-analyzer` | | scala | ✓ | | ✓ | `metals` | diff --git a/helix-syntax/languages/tree-sitter-rescript b/helix-syntax/languages/tree-sitter-rescript new file mode 160000 index 00000000..761eb912 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-rescript @@ -0,0 +1 @@ +Subproject commit 761eb9126b65e078b1b5770ac296b4af8870f933 diff --git a/languages.toml b/languages.toml index 74c01da5..041d1564 100644 --- a/languages.toml +++ b/languages.toml @@ -602,3 +602,14 @@ scope = "source.iex" injection-regex = "iex" file-types = ["iex"] roots = [] + +[[language]] +name = "rescript" +scope = "source.rescript" +injection-regex = "rescript" +file-types = ["res"] +roots = ["bsconfig.json"] +auto-format = true +comment-token = "//" +language-server = { command = "rescript-language-server", args = ["--stdio"] } +indent = { tab-width = 2, unit = " " } diff --git a/runtime/queries/rescript/highlights.scm b/runtime/queries/rescript/highlights.scm new file mode 100644 index 00000000..b9ab8ea6 --- /dev/null +++ b/runtime/queries/rescript/highlights.scm @@ -0,0 +1,179 @@ +(comment) @comment + +; Identifiers +;------------ + +; Escaped identifiers like \"+." +((value_identifier) @function.macro + (#match? @function.macro "^\\.*$")) + +[ + (type_identifier) + (unit_type) + "list" +] @type + +[ + (variant_identifier) + (polyvar_identifier) +] @constant + +(property_identifier) @variable.other.member +(module_identifier) @namespace + +(jsx_identifier) @tag +(jsx_attribute (property_identifier) @variable.parameter) + +; Parameters +;---------------- + +(list_pattern (value_identifier) @variable.parameter) +(spread_pattern (value_identifier) @variable.parameter) + +; String literals +;---------------- + +[ + (string) + (template_string) +] @string + +(template_substitution + "${" @punctuation.bracket + "}" @punctuation.bracket) @embedded + +(character) @constant.character +(escape_sequence) @constant.character.escape + +; Other literals +;--------------- + +[ + (true) + (false) +] @constant.builtin + +(number) @constant.numeric +(polyvar) @constant +(polyvar_string) @constant + +; Functions +;---------- + +[ + (formal_parameters (value_identifier)) + (positional_parameter (value_identifier)) + (labeled_parameter (value_identifier)) +] @variable.parameter + +(function parameter: (value_identifier) @variable.parameter) + +; Meta +;----- + +[ + "@" + "@@" + (decorator_identifier) +] @label + +(extension_identifier) @keyword +("%") @keyword + +; Misc +;----- + +(subscript_expression index: (string) @variable.other.member) +(polyvar_type_pattern "#" @constant) + +[ + ("include") + ("open") +] @keyword + +[ + "as" + "export" + "external" + "let" + "module" + "mutable" + "private" + "rec" + "type" + "and" +] @keyword + +[ + "if" + "else" + "switch" +] @keyword + +[ + "exception" + "try" + "catch" + "raise" +] @keyword + +[ + "." + "," + "|" +] @punctuation.delimiter + +[ + "++" + "+" + "+." + "-" + "-." + "*" + "*." + "/" + "/." + "<" + "<=" + "==" + "===" + "!" + "!=" + "!==" + ">" + ">=" + "&&" + "||" + "=" + ":=" + "->" + "|>" + ":>" + (uncurry) +] @operator + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +(polyvar_type + [ + "[" + "[>" + "[<" + "]" + ] @punctuation.bracket) + +[ + "~" + "?" + "=>" + "..." +] @punctuation + +(ternary_expression ["?" ":"] @operator) diff --git a/runtime/queries/rescript/injections.scm b/runtime/queries/rescript/injections.scm new file mode 100644 index 00000000..201cce75 --- /dev/null +++ b/runtime/queries/rescript/injections.scm @@ -0,0 +1,8 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((raw_js) @injection.content + (#set! injection.language "javascript")) + +((raw_gql) @injection.content + (#set! injection.language "graphql")) diff --git a/runtime/queries/rescript/textobjects.scm b/runtime/queries/rescript/textobjects.scm new file mode 100644 index 00000000..7ee8cd1a --- /dev/null +++ b/runtime/queries/rescript/textobjects.scm @@ -0,0 +1,9 @@ +; Classes (modules) +;------------------ + +(module_declaration definition: ((_) @class.inside)) @class.around + +; Functions +;---------- + +(function body: (_) @function.inside) @function.around -- cgit v1.2.3-70-g09d2