Text processing library for Rust
  • Rust 99.1%
  • HTML 0.8%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Tayfun Bocek 2f4927d336
Some checks failed
Release-plz / Release-plz release (push) Has been cancelled
Release-plz / Release-plz PR (push) Has been cancelled
Merge pull request #5 from airblast-dev/release-plz-2026-01-21T08-31-44Z
chore: release v0.2.2
2026-01-21 12:47:13 +03:00
.github/workflows maybe fix repo owner in release-plz repo owner 2025-03-26 14:46:25 +03:00
benches test: add benchmark for replace_full 2026-01-21 12:45:21 +03:00
src perf: reuse eol indexes buffer in replace_full 2026-01-21 12:11:11 +03:00
.gitignore init 2024-10-25 15:55:40 +03:00
Cargo.lock chore: release v0.2.2 2026-01-21 09:46:30 +00:00
Cargo.toml chore: release v0.2.2 2026-01-21 09:46:30 +00:00
CHANGELOG.md chore: release v0.2.2 2026-01-21 09:46:30 +00:00
ci.sh add shell script for quick local CI tests 2024-11-09 19:41:59 +03:00
LICENSE.md add license 2024-11-27 18:31:20 +03:00
README.md docs: replace versioned URL's with latest 2025-03-26 23:17:56 +03:00
release-plz.toml docs: add release-plz config for pretty changelogs 2025-03-26 23:30:24 +03:00

crates.io docs.rs tests License: MIT

Texter is a crate that aims to simplify creating an LSP that uses tree-sitter and wants to benefit from incremental updates.

Examples

A list of projects that use texter.

LSP Server for Trunk (trunkls)

An LSP server that provides completions and hover information to editors for trunk's custom HTML attributes. The sections where texter is used are fairly simple to follow. If you intend to take a look on how texter can be used in an LSP, this is likely a good starting point as it demonstrates how easy it is to integrate with an LSP server.

image

See trunkls for more information.

Performance

texter is pretty fast, and not just because it enables incremental updates. Expensive or hot functions are heavily optimized and leverage SIMD via memchr. To see the exact numbers you can run the benchmarks by running cargo bench.

That being said, the library prioritizes ease of use, instead of performance in some cases. For files that are under twenty thousand lines texter is generally on par with more advanced string data structures, making it suitable for majority of use cases.

Design

The interface is designed to be easy to integrate with an LSP server. In case you don't use lsp-types or tree-sitter, you can implement Updateable for your own type and still benefit from using texter. All of the position encodings that are supported by the LSP specification are also supported in texter (UTF-8, UTF-16, and UTF-32).

Testing

Every function in texter is tested using ASCII and multibyte unicode characters. CI is implemented via Github actions to make sure things don't break.

FAQ

Can I use this in an editor?

While technically possible, texter is not optimized for very large files (though it still does have some optimizations compared to calling methods on a String). The goal of texter is to just introduce a high level way to enable incremental updates for an LSP server with minimal boilerplate to the code.

Why create a library for this?

While attempting to implement an LSP using tree-sitter, I had some trouble setting up incremental updates in a practical way. Out of curiosity I decided to check out other LSP servers implemented in Rust.

I noticed two common patterns in their implementation. They either don't bother with incremental changes, and fully update the tree-sitter Tree which is innefficient, or they attempt to implement incremental changes on a per project basis. This first case is functionally good, however in the second case the problems are more subtle.

Since the incremental updates are not the main point of the project when developing an LSP server, it often ends up with lesser testing, usability, and extensibility.

While developing my own LSP server I ran into these problems myself, and decided to create this library with the goal of being a well tested and high performance solution.