ReferencePackages
@mwillbanks/tuil-code
Incremental parser-pluggable code highlighting and terminal code view models for tuil.
Overview
Incremental parser-pluggable code highlighting and terminal code view models for tuil.
@mwillbanks/tuil-code is independently installable and also participates in the
umbrella @mwillbanks/tuil runtime where applicable.
Installation
npm install @mwillbanks/tuil-codeHow it operates
Code documents detect languages, parse through pluggable parsers, apply incremental edits, and project tokens, diagnostics, folds, search results, and terminal lines.
API
| API | Signature | Description |
|---|---|---|
CodeDiagnostic | interface CodeDiagnostic | Public interface CodeDiagnostic. |
CodeParser | interface CodeParser | Public interface CodeParser. |
CodeParseResult | interface CodeParseResult | Public interface CodeParseResult. |
CodeSpan | interface CodeSpan | Public interface CodeSpan. |
CodeTheme | interface CodeTheme | Public interface CodeTheme. |
createBundledCodeParsers | function createBundledCodeParsers | Public function createBundledCodeParsers. |
detectCodeLanguage | function detectCodeLanguage | Public function detectCodeLanguage. |
IncrementalSyntaxEngine | interface IncrementalSyntaxEngine | Public interface IncrementalSyntaxEngine. |
IncrementalSyntaxNode | interface IncrementalSyntaxNode | Public interface IncrementalSyntaxNode. |
IncrementalSyntaxTree | interface IncrementalSyntaxTree | Public interface IncrementalSyntaxTree. |
RegexCodeParser | class RegexCodeParser | Public class RegexCodeParser. |
TreeSitterCodeParser | class TreeSitterCodeParser | Public class TreeSitterCodeParser. |
Events and lifecycle
Parsing and projection are explicit async operations with cancellation rather than global events.
All subscriptions and registrations return a disposer or belong to an owning runtime that disposes them in reverse order.
Example
const document = new CodeDocument("const ready = true");
await document.parse(signal);