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,5 @@
; VM language bracket matching
; No brackets are used in VM language syntax
; VM language is line-based with simple command structure
; No nested structures or bracket pairs to match

7
languages/vm/config.toml Normal file
View File

@@ -0,0 +1,7 @@
name = "VM"
grammar = "vm"
scope = "source.vm"
path_suffixes = ["vm"]
line_comments = ["// "]
tab_size = 4
hard_tabs = false

View File

@@ -0,0 +1,54 @@
; VM language syntax highlighting queries based on actual node types
; Arithmetic and logical commands
(arithmetic_command) @keyword
; Memory access commands
"push" @keyword
"pop" @keyword
; Memory segments
(memory_segment) @type
; Program flow commands
"label" @keyword.control
"goto" @keyword.control
"if-goto" @keyword.control
; Function commands
"function" @keyword.function
"call" @keyword.function
(return_command) @keyword.function
; Numbers (indices, counts)
(index) @constant.numeric
(local_vars_count) @constant.numeric
(args_count) @constant.numeric
; Identifiers
(label_name) @label
(function_name) @function
; Comments
(comment) @comment
; Specific memory segments highlighting
"argument" @type.builtin
"local" @type.builtin
"static" @type.builtin
"constant" @type.builtin
"this" @type.builtin
"that" @type.builtin
"pointer" @type.builtin
"temp" @type.builtin
; Arithmetic operations
"add" @operator
"sub" @operator
"neg" @operator
"eq" @operator
"gt" @operator
"lt" @operator
"and" @operator
"or" @operator
"not" @operator

14
languages/vm/indents.scm Normal file
View File

@@ -0,0 +1,14 @@
; VM language indentation rules
; No special indentation rules needed for VM language
; since it's a flat, line-based language with simple command structure
; All commands should be at the same indentation level
; Optional: indent commands inside function bodies for readability
; but this is not required by the VM specification
; Function declarations can be at base level
; with their contents optionally indented
(function_declaration) @indent
; No other special indentation patterns needed

17
languages/vm/outline.scm Normal file
View File

@@ -0,0 +1,17 @@
; VM language outline queries
; Show function declarations in the outline
(function_declaration
(function_name) @name) @item
; Show label declarations for program flow
(label_command
(label_name) @name) @item
; Show function calls as outline items for navigation
(call_command
(function_name) @name) @item
; Show comments that look like section headers
(comment) @item
(#match? @item "^//\\s*[A-Z].*|^//.*[Ss]ection|^//.*[Pp]art|^//.*[Ff]unction|^//.*[Cc]lass")