From 2ef2e743857f77b29dca646e1e20904235457751 Mon Sep 17 00:00:00 2001 From: Miles Wirht <114884788+philocalyst@users.noreply.github.com> Date: Tue, 11 Nov 2025 09:35:35 -0500 Subject: [PATCH] Added haxe language support (#14699) --- book/src/generated/lang-support.md | 1 + languages.toml | 21 ++++ runtime/queries/haxe/folds.scm | 4 + runtime/queries/haxe/highlights.scm | 146 ++++++++++++++++++++++++++++ runtime/queries/haxe/injections.scm | 6 ++ runtime/queries/haxe/locals.scm | 12 +++ runtime/queries/haxe/tags.scm | 0 7 files changed, 190 insertions(+) create mode 100644 runtime/queries/haxe/folds.scm create mode 100644 runtime/queries/haxe/highlights.scm create mode 100644 runtime/queries/haxe/injections.scm create mode 100644 runtime/queries/haxe/locals.scm create mode 100644 runtime/queries/haxe/tags.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 6805a062..6784a0db 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -109,6 +109,7 @@ | haskell | ✓ | ✓ | | | | `haskell-language-server-wrapper` | | haskell-literate | ✓ | | | | | `haskell-language-server-wrapper` | | haskell-persistent | ✓ | | | | | | +| haxe | ✓ | | | ✓ | | | | hcl | ✓ | ✓ | ✓ | | | `terraform-ls` | | hdl | ✓ | | | | | `hdls` | | heex | ✓ | ✓ | | | | `elixir-ls`, `expert` | diff --git a/languages.toml b/languages.toml index 9486892a..12ada74e 100644 --- a/languages.toml +++ b/languages.toml @@ -4976,3 +4976,24 @@ indent = {tab-width = 2, unit = " "} [[grammar]] name = "bovex" source = { git = "https://github.com/mi2ebi/tree-sitter-bovex", rev = "de7657a9cc3525b9b77c6d268da09dad5b1346b0" } + +[[language]] +name = "haxe" +scope = "source.haxe" +injection-regex = "hx|haxe" +file-types = ["hx"] +roots = ["haxelib.json", "project.xml", "build.hxml"] +shebangs = [] +auto-format = true +comment-tokens = ["//", "///"] +block-comment-tokens = [ + { start = "/*", end = "*/" }, + { start = "/**", end = "*/" }, +] +language-servers = ["haxe-language-server"] +indent = { tab-width = 4, unit = " " } +persistent-diagnostic-sources = ["haxe"] + +[[grammar]] +name = "haxe" +source = { git = "https://github.com/vantreeseba/tree-sitter-haxe", rev = "a55f3e2cf1e4449200fd089a80d3af642bcf5f94" } diff --git a/runtime/queries/haxe/folds.scm b/runtime/queries/haxe/folds.scm new file mode 100644 index 00000000..31976f5b --- /dev/null +++ b/runtime/queries/haxe/folds.scm @@ -0,0 +1,4 @@ +[ + (block) + (array) +] @fold diff --git a/runtime/queries/haxe/highlights.scm b/runtime/queries/haxe/highlights.scm new file mode 100644 index 00000000..f499b30c --- /dev/null +++ b/runtime/queries/haxe/highlights.scm @@ -0,0 +1,146 @@ +(identifier) @variable +(comment) @comment + +; Preprocessor Statement +; -------- +(preprocessor_statement) @tag +; (metadata name: (identifier) @type) @tag + +; MetaData +; -------- +(metadata) @tag +(metadata name: (identifier) @type) @tag + +; Generic/Type Params +; -------------- +(type_params + "<" @punctuation.bracket + ">" @punctuation.bracket +) + +; Declarations +; ------------ + +(class_declaration name: (identifier) @type.definition) +(interface_declaration name: (identifier) @type.definition) +(typedef_declaration name: (identifier) @type.definition) + +(function_declaration name: (identifier) @function) +(function_arg name: (identifier) @variable.parameter) + +; Expressions +; ----------- +; (call_expression name: (identifier) @variable.parameter) + +; TODO: Figure out how to determined when "nested member call" is last ident. +; apparently this is a known issue https://github.com/tree-sitter/tree-sitter/issues/880 +(call_expression object: [ + (_) @function + (_ (identifier) @function .) +; (_(_ (identifier) @function .)) +; (_(_(_ (identifier) @function .))) +; (_(_(_(_ (identifier) @function .)))) +; (_(_(_(_(_ (identifier) @function .))))) +]) + +; Literals +; -------- +; [(keyword) (null)] @keyword +; (type) @type +(type_name) @type +(package_name) @namespace +(type (identifier) !built_in) @type +(type built_in: (identifier)) @type.builtin +(integer) @constant.numeric.integer +(float) @constant.numeric.float +(string) @string +(bool) @constant.builtin.boolean +(operator) @operator +(escape_sequence) @punctuation +(null) @constant.builtin +(access_identifiers "null" @keyword) + +; Keywords +; -------- +[ + "abstract" + "as" + "break" + "case" + "cast" + "catch" + "class" + "continue" + "default" + "do" + "dynamic" + "else" + "enum" + "extends" + "extern" + "final" + "for" + "function" + "if" + "implements" + "import" + "in" + "inline" + "interface" + "macro" + "operator" + "overload" + "override" + "package" + "private" + "public" + "return" + "static" + "switch" + "this" + "throw" + "try" + "typedef" + "untyped" + "using" + "var" + "while" +] @keyword + +(function_declaration name: "new" @constructor) +(call_expression + "new" @keyword + constructor: (type_name) @constructor +) + +; Tokens +; ------ + +(":") @punctuation.special +(pair [":" "=>"] @punctuation.special) + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket +; +[ +; ";" +; "?." +; "." + "," +] @punctuation.delimiter + + +; Interpolation +; ------------- +(interpolation "$" @punctuation.special) +(interpolation + "${" @punctuation.special + "}" @punctuation.special +) @embedded + diff --git a/runtime/queries/haxe/injections.scm b/runtime/queries/haxe/injections.scm new file mode 100644 index 00000000..2241ab1f --- /dev/null +++ b/runtime/queries/haxe/injections.scm @@ -0,0 +1,6 @@ +((interpolation) @injection.content + (#set! injection.language "haxe")) +((comment) @injection.content + (#set! injection.language "jsdoc")) +; ((comment) @injection.content +; (#set! injection.language "comment")) diff --git a/runtime/queries/haxe/locals.scm b/runtime/queries/haxe/locals.scm new file mode 100644 index 00000000..bc58c10d --- /dev/null +++ b/runtime/queries/haxe/locals.scm @@ -0,0 +1,12 @@ +; Scopes +[ + (block) + (function_declaration) +] @local.scope + +; Definitions +(function_arg name: (identifier) @local.definition.variable.parameter) +(variable_declaration name: (identifier) @local.definition.variable) + +; References +(block (identifier)) @local.reference diff --git a/runtime/queries/haxe/tags.scm b/runtime/queries/haxe/tags.scm new file mode 100644 index 00000000..e69de29b -- 2.51.2