nucleo-picker

Crates.ionucleo-picker
lib.rsnucleo-picker
version0.5.0
sourcesrc
created_at2024-08-20 23:15:30.754365
updated_at2024-11-07 20:12:34.99991
descriptionA fuzzy picker tui library based on nucleo
homepage
repositoryhttps://github.com/autobib/nucleo-picker
max_upload_size
id1345860
size67,831
Alex Rutar (alexrutar)

documentation

README

Current crates.io release Documentation

nucleo-picker

Yet another fuzzy picker library. This library provides a TUI for the nucleo crate, but otherwise attempts to be a relatively thin wrapper.

As a result, you get the great features of nucleo for freeā„¢. This crate tries not to interfere with the API choices made by nucleo.

See the examples directory for implementation examples, or try it out with cargo run --example blocking.

Currently, we only directly load two dependencies:

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 very inconvenient since the original item cannot be recovered from the match. skim also contains a large amount of dependency baggage.
  • fuzzypicker is based on skim and inherits skim's problems.
  • nucleo-ui only has a blocking API and only supports matching on String.
  • fuzzy-select only has a blocking API.
  • dialoguer FuzzySelect only has a blocking API and only supports matching on String. The terminal handling also has a few strange bugs.

Query syntax

The query syntax is as documented in the nucleo-matcher crate.

Essentially, each query is parsed as a sequence of whitespace-separated "atoms", such as a1 a2 a3. By default, each atom corresponds to a fuzzy match: that is, higher score is assigned for a closer match, but exact match is not required. There is also a special syntax for various types of exact matches.

  • 'foo match an exact substring, with negation !foo
  • ^foo must match an exact prefix, with negation !^foo
  • foo$ must match an exact suffix, with negation !foo$
  • ^foo$ must match the entire string exactly, with negation !^foo$

Whitespace and control symbols '^$! can also be interpreted literally by escaping with a backslash \.

For example, the query foo ^bar means that we match for strings which contain foo (or similar), and which begin with the exact string bar.

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).

This crate is not affiliated with the authors of nucleo, but if they have comments / complaints I am very glad to hear them!

Commit count: 53

cargo fmt