nucleo-picker
A native Rust library which enables you to incorporate a highly performant and Unicode-aware fuzzy picker directly in your own terminal application.
This library provides a TUI for the nucleo crate with an interface similar to the fzf command-line tool.
- For implementation examples, jump to the fzf example or see the
examplesdirectory. - For documentation of interactive usage of the picker, see the
USAGE.mdfile. - For a list of recent changes, see the
CHANGELOG.mdfile.
Elevator pitch
Why use this library instead of a general-purpose fuzzy-finder such as fzf or a lower level library such as nucleo?
- Much tighter integration between your data source and your application.
Instead of reading from a SQLite database with
sqlite3and then parsing raw text, read directly into in-memory data structures withrusqliteand render the in-memory objects in the picker. - Skip the subprocess overhead and improve startup time.
Instead of starting up a subprocess to call
fzf, have the picker integrated directly into your binary. - Distinguish items from their matcher representation.
Instead of writing your data structure to a string, passing it to
fzf, and then parsing the resulting match string back into your data structure, directly obtain the original data structure when matching is complete. - Don't spend time debugging terminal rendering edge cases.
Out-of-the-box,
nucleo-pickerhandles terminal rendering subtleties such as multiline rendering, double-width Unicode, automatic overflow scrollthrough, and grapheme-aware query input so you don't have to.
Features
- Highly optimized matching.
- Robust rendering:
- Full Unicode handling with Unicode text segmentation and Unicode width.
- Match highlighting with automatic scroll-through.
- Correctly render multi-line or overflowed items, with standard and reversed item order.
- Responsive interface with batched keyboard input.
- Ergonomic API:
- Fully concurrent lock- and wait-free streaming of input items.
- Generic
Pickerfor any typeTwhich isSend + Sync + 'static. - Customizable rendering of crate-local and foreign types with the
Rendertrait.
- Fully configurable event system:
- Easily customizable keybindings.
- Run the picker concurrently with a your application using a flexible
Eventsystem supporting standard picker operations, along with more complex features such as interactive restarting. - Flexible error propagation generics so your application errors can interface cleanly with the picker.
Example
Implement a heavily simplified fzf clone in 25 lines of code.
Try it out with:
cargo build --release --example fzf
cat myfile.txt | ./target/release/examples/fzf
The code to create the binary:
use ;
use ;
Related crates
This crate mainly exists as a result of the author's annoyance with pretty much every fuzzy picker TUI in the rust ecosystem.
- skim's
Arc<dyn SkimItem>is inconvenient for a variety of reasons.skimalso has a large number of dependencies and is designed more as a binary than a library. - fuzzypicker is based on
skimand inheritsskim's problems. - nucleo-ui only has a blocking API and only supports matching on
String. It also seems to be un-maintained. - fuzzy-select only has a blocking API.
- dialoguer
FuzzySelectonly has a blocking API and only supports matching onString. The terminal handling also has a few strange bugs.
Disclaimer
The feature set of this library is quite minimal (by design) but may be expanded in the future. There are a currently a few known problems which have not been addressed (see the issues page on GitHub for a list).