Fix HDL and Hack Assembly syntax highlighting and queries

- Fixed HDL highlights query syntax error with #match? predicate
- Replaced #match? with #any-of? for exact string matching
- Fixed Hack Assembly outline query invalid field name
- Improved HDL syntax highlighting with comprehensive patterns
- Added HDL bracket matching for all syntax types
- Fixed XML scope mismatch from text.xml to source.xml
- Enhanced outline queries for better code navigation
This commit is contained in:
2025-09-11 11:24:24 -04:00
commit c231dbfd27
133 changed files with 2792 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
; Bracket matching for Jack
("{" @open "}" @close)
("(" @open ")" @close)

View File

@@ -0,0 +1,8 @@
name = "Jack"
grammar = "jack"
scope = "source.jack"
path_suffixes = ["jack"]
line_comments = ["// "]
block_comments = [["/*", "*/"]]
tab_size = 4
hard_tabs = false

View File

@@ -0,0 +1,101 @@
; Jack syntax highlighting queries for tree-sitter
; Keywords as string terminals
"class" @keyword
"static" @keyword
"function" @keyword
"constructor" @keyword
"method" @keyword
"field" @keyword
"var" @keyword
"let" @keyword
"do" @keyword
"if" @keyword
"else" @keyword
"while" @keyword
"return" @keyword
; Operators and punctuation
"=" @operator
"+" @operator
"-" @operator
"*" @operator
"/" @operator
"&" @operator
"|" @operator
"<" @operator
">" @operator
"~" @operator
";" @punctuation.delimiter
"," @punctuation.delimiter
"." @punctuation.delimiter
"{" @punctuation.bracket
"}" @punctuation.bracket
"(" @punctuation.bracket
")" @punctuation.bracket
"[" @punctuation.bracket
"]" @punctuation.bracket
; Special alias nodes (these are created by the grammar)
(this) @variable.builtin
(true) @boolean
(false) @boolean
(null) @constant.builtin
; Class declarations
(class_declaration
name: (identifier) @type)
; Class name references
(class_name) @type
; Subroutine declarations
(subroutine_declaration
name: (identifier) @function)
; Parameters
(parameter
(identifier) @variable.parameter)
; Variable declarations
(class_variable_declaration
(identifier) @property)
(local_variable_declaration
(identifier) @variable)
; Function calls
(call_expression
function: (identifier) @function)
(call_expression
function: (member_expression
property: (identifier) @function))
; Member access
(member_expression
object: (identifier) @variable
property: (identifier) @property)
; Subscript access
(subscript_expression
object: (identifier) @variable)
; Let statement variable
(let_statement
(identifier) @variable)
(let_statement
(subscript_expression
object: (identifier) @variable))
; General identifiers
(identifier) @variable
; Literals
(integer) @number
(string) @string
; Comments
(comment) @comment
(doc_comment) @comment.doc

View File

@@ -0,0 +1,16 @@
; Jack indentation rules
; Indent inside class body
(class_body) @indent
; Indent inside subroutine body
(subroutine_body) @indent
; Indent inside statement blocks
(statement_block) @indent
; Indent inside formal parameters
(formal_parameters) @indent
; Indent inside arguments
(arguments) @indent

View File

@@ -0,0 +1,26 @@
; Jack outline queries for code structure
; Class declarations as main outline items
(class_declaration
name: (identifier) @name) @item
; Subroutine declarations
(subroutine_declaration
kind: "constructor"
name: (identifier) @name) @item
(subroutine_declaration
kind: "function"
name: (identifier) @name) @item
(subroutine_declaration
kind: "method"
name: (identifier) @name) @item
; Class variable declarations (field and static)
(class_variable_declaration
(identifier) @name) @item
; Local variable declarations
(local_variable_declaration
(identifier) @name) @item