From 5cb19c686eed198292ee03eeb9d904b10e0988ca Mon Sep 17 00:00:00 2001 From: Matt <85322+mattmassicotte@users.noreply.github.com> Date: Fri, 9 Feb 2024 07:04:44 -0500 Subject: [PATCH] Some reorganizing, clarify TextKit 2 issues --- README.md | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 279657a..9caf347 100644 --- a/README.md +++ b/README.md @@ -61,18 +61,6 @@ Many of these support versionable content. If you are working with a backing sto It might be surprising to see that many of the types in RangeState are marked `@MainActor`. Right now, I have found no way to both support the hybrid sync/async functionality while also not being tied to a global actor. I think this is the most resonable trade-off, but I would very much like to lift this restriction. However, I believe it will require [language changes](https://forums.swift.org/t/isolation-assumptions/69514/47). -### TreeSitterClient - -This library is a hybrid sync/async interface to [SwiftTreeSitter][SwiftTreeSitter]. It features: - -- UTF-16 code-point (`NSString`-compatible) API for edits, invalidations, and queries -- Processing edits of `String` objects, or raw bytes -- Invalidation translation to the current content state regardless of background processing -- On-demand nested language resolution via tree-sitter's injection system -- Background processing when needed to scale to large documents - -Tree-sitter uses separate compiled parsers for each language. There are a variety of ways to use tree-sitter parsers with SwiftTreeSitter. Check out that project for details. - ### Neon The top-level module includes systems for managing text styling. It is also text-system independent. It makes very few assumptions about how text is stored, displayed, or styled. It also includes some components for use with stock AppKit and UIKit systems. These are provided for easy integration, not maximum performance. @@ -85,6 +73,18 @@ The top-level module includes systems for managing text styling. It is also text There is also an example project that demonstrates how to use `TextViewHighlighter` for macOS and iOS. +### TreeSitterClient + +This library is a hybrid sync/async interface to [SwiftTreeSitter][SwiftTreeSitter]. It features: + +- UTF-16 code-point (`NSString`-compatible) API for edits, invalidations, and queries +- Processing edits of `String` objects, or raw bytes +- Invalidation translation to the current content state regardless of background processing +- On-demand nested language resolution via tree-sitter's injection system +- Background processing when needed to scale to large documents + +Tree-sitter uses separate compiled parsers for each language. There are a variety of ways to use tree-sitter parsers with SwiftTreeSitter. Check out that project for details. + ### Token Data Sources Neon was designed to accept and overlay token data from multiple sources simultaneously. Here's a real-world example of how this is used: @@ -105,6 +105,8 @@ In a traditional `NSTextStorage`-backed system (TextKit 1 and 2), it can be chal But, even that isn't quite enough unfortunately. You still need to precisely control the timing of invalidation and styling. This is where `RangeInvalidationBuffer` comes in. +I have not yet figured out a way to do this with TextKit 2, and it may not be possible without new API. + ## Usage ### TreeSitterClient