7 releases (4 breaking)
new 0.5.0 | Nov 7, 2024 |
---|---|
0.4.1 | Sep 7, 2024 |
0.3.0 | Aug 31, 2024 |
0.2.1 | Aug 22, 2024 |
0.1.0 | Aug 20, 2024 |
#225 in Command-line interface
21 downloads per month
Used in autobib
42KB
707 lines
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 inheritsskim
'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 onString
. 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!
Dependencies
~4–12MB
~165K SLoC