add tree-sitter syntax highlighting via dart:ffi
Vendor libtree-sitter.so (v0.26.8, wasmtime 44.0 statically linked) and call its C API through dart:ffi. Grammar WASM files are loaded by tree-sitter's embedded wasmtime engine via ts_wasm_store_load_language. 48 grammars compiled with tree-sitter build --wasm, 48 highlight queries (42 from upstream repos, 6 written in-house for comment, erlang, gdscript, gitignore, hcl, hlsl, swift). SQLite grammar replaces full SQL (974K-line parser exhausted RAM at compile time). Removes wasm_run and wasm_run_flutter — they downloaded a 22 MB binary from GitHub at first launch, violating the no-network-on- default-launch-path policy. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,203 @@
|
||||
[
|
||||
(php_tag)
|
||||
(php_end_tag)
|
||||
] @tag
|
||||
|
||||
; Keywords
|
||||
|
||||
[
|
||||
"and"
|
||||
"as"
|
||||
"break"
|
||||
"case"
|
||||
"catch"
|
||||
"class"
|
||||
"clone"
|
||||
"const"
|
||||
"continue"
|
||||
"declare"
|
||||
"default"
|
||||
"do"
|
||||
"echo"
|
||||
"else"
|
||||
"elseif"
|
||||
"enddeclare"
|
||||
"endfor"
|
||||
"endforeach"
|
||||
"endif"
|
||||
"endswitch"
|
||||
"endwhile"
|
||||
"enum"
|
||||
"exit"
|
||||
"extends"
|
||||
"finally"
|
||||
"fn"
|
||||
"for"
|
||||
"foreach"
|
||||
"function"
|
||||
"global"
|
||||
"goto"
|
||||
"if"
|
||||
"implements"
|
||||
"include"
|
||||
"include_once"
|
||||
"instanceof"
|
||||
"insteadof"
|
||||
"interface"
|
||||
"match"
|
||||
"namespace"
|
||||
"new"
|
||||
"or"
|
||||
"print"
|
||||
"require"
|
||||
"require_once"
|
||||
"return"
|
||||
"switch"
|
||||
"throw"
|
||||
"trait"
|
||||
"try"
|
||||
"use"
|
||||
"while"
|
||||
"xor"
|
||||
"yield"
|
||||
"yield from"
|
||||
(abstract_modifier)
|
||||
(final_modifier)
|
||||
(readonly_modifier)
|
||||
(static_modifier)
|
||||
(visibility_modifier)
|
||||
] @keyword
|
||||
|
||||
(function_static_declaration "static" @keyword)
|
||||
|
||||
; Namespace
|
||||
|
||||
(namespace_definition
|
||||
name: (namespace_name
|
||||
(name) @module))
|
||||
|
||||
(namespace_name
|
||||
(name) @module)
|
||||
|
||||
(namespace_use_clause
|
||||
[
|
||||
(name) @type
|
||||
(qualified_name
|
||||
(name) @type)
|
||||
alias: (name) @type
|
||||
])
|
||||
|
||||
(namespace_use_clause
|
||||
type: "function"
|
||||
[
|
||||
(name) @function
|
||||
(qualified_name
|
||||
(name) @function)
|
||||
alias: (name) @function
|
||||
])
|
||||
|
||||
(namespace_use_clause
|
||||
type: "const"
|
||||
[
|
||||
(name) @constant
|
||||
(qualified_name
|
||||
(name) @constant)
|
||||
alias: (name) @constant
|
||||
])
|
||||
|
||||
(relative_name "namespace" @module.builtin)
|
||||
|
||||
; Variables
|
||||
|
||||
(relative_scope) @variable.builtin
|
||||
|
||||
(variable_name) @variable
|
||||
|
||||
(method_declaration name: (name) @constructor
|
||||
(#eq? @constructor "__construct"))
|
||||
|
||||
(object_creation_expression [
|
||||
(name) @constructor
|
||||
(qualified_name (name) @constructor)
|
||||
(relative_name (name) @constructor)
|
||||
])
|
||||
|
||||
((name) @constant
|
||||
(#match? @constant "^_?[A-Z][A-Z\\d_]+$"))
|
||||
((name) @constant.builtin
|
||||
(#match? @constant.builtin "^__[A-Z][A-Z\d_]+__$"))
|
||||
(const_declaration (const_element (name) @constant))
|
||||
|
||||
; Types
|
||||
|
||||
(primitive_type) @type.builtin
|
||||
(cast_type) @type.builtin
|
||||
(named_type [
|
||||
(name) @type
|
||||
(qualified_name (name) @type)
|
||||
(relative_name (name) @type)
|
||||
]) @type
|
||||
(named_type (name) @type.builtin
|
||||
(#any-of? @type.builtin "static" "self"))
|
||||
|
||||
(scoped_call_expression
|
||||
scope: [
|
||||
(name) @type
|
||||
(qualified_name (name) @type)
|
||||
(relative_name (name) @type)
|
||||
])
|
||||
|
||||
; Functions
|
||||
|
||||
(array_creation_expression "array" @function.builtin)
|
||||
(list_literal "list" @function.builtin)
|
||||
(exit_statement "exit" @function.builtin "(")
|
||||
|
||||
(method_declaration
|
||||
name: (name) @function.method)
|
||||
|
||||
(function_call_expression
|
||||
function: [
|
||||
(qualified_name (name))
|
||||
(relative_name (name))
|
||||
(name)
|
||||
] @function)
|
||||
|
||||
(scoped_call_expression
|
||||
name: (name) @function)
|
||||
|
||||
(member_call_expression
|
||||
name: (name) @function.method)
|
||||
|
||||
(function_definition
|
||||
name: (name) @function)
|
||||
|
||||
; Member
|
||||
|
||||
(property_element
|
||||
(variable_name) @property)
|
||||
|
||||
(member_access_expression
|
||||
name: (variable_name (name)) @property)
|
||||
(member_access_expression
|
||||
name: (name) @property)
|
||||
|
||||
; Basic tokens
|
||||
[
|
||||
(string)
|
||||
(string_content)
|
||||
(encapsed_string)
|
||||
(heredoc)
|
||||
(heredoc_body)
|
||||
(nowdoc_body)
|
||||
] @string
|
||||
(boolean) @constant.builtin
|
||||
(null) @constant.builtin
|
||||
(integer) @number
|
||||
(float) @number
|
||||
(comment) @comment
|
||||
|
||||
((name) @variable.builtin
|
||||
(#eq? @variable.builtin "this"))
|
||||
|
||||
"$" @operator
|
||||
Reference in New Issue
Block a user