Add v0.1 scaffold: tree-sitter-p8-cart grammar and Zed extension
The grammar parses the .p8 cartridge container ( header, version, and the named __lua__/__gfx__/__gff__/__label__/__map__/__sfx__/__music__ sections, plus a fallback unknown_section ). The Zed language definition hands the __lua__ body to Zed's built-in Lua via injections.scm, so non-dialect Lua code highlights correctly today; PICO-8-specific syntax (?, +=, !=, single-line if, etc.) will fall back to error highlighting in those regions only — see README roadmap for the dialect grammar fork. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
name = "Pico-8 Cartridge"
|
||||
grammar = "p8_cart"
|
||||
path_suffixes = ["p8"]
|
||||
line_comments = []
|
||||
hard_tabs = false
|
||||
tab_size = 1
|
||||
@@ -0,0 +1,13 @@
|
||||
; The cartridge magic header and version line are metadata, not content.
|
||||
(header) @comment.doc
|
||||
(version) @comment.doc
|
||||
|
||||
; Section markers ( __lua__, __gfx__, etc. ) are structural tokens.
|
||||
(lua_marker) @keyword
|
||||
(gfx_marker) @keyword
|
||||
(gff_marker) @keyword
|
||||
(label_marker) @keyword
|
||||
(map_marker) @keyword
|
||||
(sfx_marker) @keyword
|
||||
(music_marker) @keyword
|
||||
(section_marker) @keyword
|
||||
@@ -0,0 +1,11 @@
|
||||
; Inject Lua syntax highlighting into the __lua__ section.
|
||||
;
|
||||
; NOTE: This injects Zed's built-in Lua grammar, which does not
|
||||
; understand Pico-8 dialect extensions ( ?, +=, !=, single-line
|
||||
; `if (cond) stmt`, binary literals, memory peek prefix operators,
|
||||
; etc. ). Code that uses those forms will produce parse errors
|
||||
; locally, with degraded highlighting in those regions only — the
|
||||
; rest of the file will still render correctly. A future Pico-8
|
||||
; Lua grammar fork will replace this; see README for status.
|
||||
((lua_content) @injection.content
|
||||
(#set! injection.language "lua"))
|
||||
@@ -0,0 +1,9 @@
|
||||
; Show each cart section as an outline entry, named by its marker.
|
||||
(lua_section (lua_marker) @name) @item
|
||||
(gfx_section (gfx_marker) @name) @item
|
||||
(gff_section (gff_marker) @name) @item
|
||||
(label_section (label_marker) @name) @item
|
||||
(map_section (map_marker) @name) @item
|
||||
(sfx_section (sfx_marker) @name) @item
|
||||
(music_section (music_marker) @name) @item
|
||||
(unknown_section (section_marker) @name) @item
|
||||
Reference in New Issue
Block a user