3 Commits

Author SHA1 Message Date
kistaro ba2dd6a9a2 Cart injection: use the literal language name "Pico-8 Lua"
Zed resolves `injection.language` by matching it against the target
language's `name` field ( config.toml ) via UniCase, which folds case
but does NOT treat `-` as equivalent to ` `. The previous string
"pico-8-lua" therefore did not resolve to any registered language and
the entire __lua__ section rendered with zero highlights inside Zed.

Per `LanguageRegistry::language_for_name_or_extension` in
crates/language/src/language_registry.rs, only the `name` field and
`path_suffixes` are consulted — the directory under languages/, the
grammar `name`, the `scope`, and the tree-sitter.json `injection-regex`
field are all ignored. ( `injection-regex` is a Helix/Neovim
convention; Zed's production code never reads it. )

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 13:20:57 -07:00
kistaro 39d77a8cae v0.2: Pico-8 Lua dialect grammar and language
Reorganize into grammars/<name>/ subdirs ( Zed's [grammars.*] supports
a `path` field, so both grammars ship from this repo without a sibling-
repo split ). Vendor tree-sitter-lua as the fork base for tree-sitter-
pico8-lua; upstream MIT license preserved at grammars/pico-8-lua/
UPSTREAM-LICENSE.md.

Dialect features added: != as ~= alias, \ integer divide, ^^ binary xor,
>>> / <<> / >>< shifts and rotates, compound-assignment statements,
memory peek prefixes @ % $ (% coexists with binary modulo), single-line
`if (cond) stmt [else stmt]` and `while (cond) stmt`, statement-level
print shorthand ?, and `#include path` directives. Identifier rule no
longer accepts ! ? @ $ ( upstream did ).

Pico-8 Lua language ( languages/pico-8-lua/, suffix .p8lua ) ships
highlights with the full ~110 PICO-8 builtins as @function.builtin.
The cart injection now hands __lua__ bodies to pico-8-lua, so .p8 carts
and bare .p8lua files share the dialect-aware grammar. Examples updated
to exercise the dialect end-to-end.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 12:50:41 -07:00
kistaro 3f209efa89 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>
2026-05-01 11:50:47 -07:00