mirror of
https://github.com/soconnor0919/nand2tetris-zed.git
synced 2025-12-15 08:34:44 -05:00
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:
3
languages/jack/brackets.scm
Normal file
3
languages/jack/brackets.scm
Normal file
@@ -0,0 +1,3 @@
|
||||
; Bracket matching for Jack
|
||||
("{" @open "}" @close)
|
||||
("(" @open ")" @close)
|
||||
8
languages/jack/config.toml
Normal file
8
languages/jack/config.toml
Normal 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
|
||||
101
languages/jack/highlights.scm
Normal file
101
languages/jack/highlights.scm
Normal 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
|
||||
16
languages/jack/indents.scm
Normal file
16
languages/jack/indents.scm
Normal 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
|
||||
26
languages/jack/outline.scm
Normal file
26
languages/jack/outline.scm
Normal 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
|
||||
Reference in New Issue
Block a user