tuil
ReferencePackages

@mwillbanks/tuil-code

Incremental parser-pluggable code highlighting and terminal code view models for tuil.

View rawEdit

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-code

How it operates

Code documents detect languages, parse through pluggable parsers, apply incremental edits, and project tokens, diagnostics, folds, search results, and terminal lines.

Documentation flow diagram. create source; detect/parse; edit; search/fold; render; S0 leads to S1; S1 leads to S2; S2 leads to S3
Documentation flow diagram. create source; detect/parse; edit; search/fold; render; S0 leads to S1; S1 leads to S2; S2 leads to S3

API

APISignatureDescription
CodeDiagnosticinterface CodeDiagnosticPublic interface CodeDiagnostic.
CodeParserinterface CodeParserPublic interface CodeParser.
CodeParseResultinterface CodeParseResultPublic interface CodeParseResult.
CodeSpaninterface CodeSpanPublic interface CodeSpan.
CodeThemeinterface CodeThemePublic interface CodeTheme.
createBundledCodeParsersfunction createBundledCodeParsersPublic function createBundledCodeParsers.
detectCodeLanguagefunction detectCodeLanguagePublic function detectCodeLanguage.
IncrementalSyntaxEngineinterface IncrementalSyntaxEnginePublic interface IncrementalSyntaxEngine.
IncrementalSyntaxNodeinterface IncrementalSyntaxNodePublic interface IncrementalSyntaxNode.
IncrementalSyntaxTreeinterface IncrementalSyntaxTreePublic interface IncrementalSyntaxTree.
RegexCodeParserclass RegexCodeParserPublic class RegexCodeParser.
TreeSitterCodeParserclass TreeSitterCodeParserPublic 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);

On this page