Skip to content

artronics/match-finder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MatchFinder

A fuzzy finder similar to fzf-native-vim but with different scoring algorithm.

NOTE: This is not a CLI tool but a library.

Search term

The search term is backward compatible with fzf.

foo -> fuzzy
'foo -> exact
^foo -> prefix-exact
foo$ -> suffix-exact
!foo -> inverse-exact
!^foo -> inverse-prefix-exact
!foo$ -> inverse-suffix-exact

// Note that OR has precedence over AND
foo ^bar baz$ ->  (and (and foo ^bar) baz$)
'foo | !bar !baz$ | !^bax ->  (and (or 'foo !bar) (or !baz$ !^bax))

Usage

See main.zig tests for more examples.

test "example usage" {
    const a = testing.allocator;

    const texts = &[_][]const u8{ "unique", "foo", "foobar", "barfoo", "$order^^^", "xyz_", "abxy", "$order^", "$order^^" };
    var matcher = MatchFinder.init(a, texts);
    defer matcher.deinit();

    {
        const or_bin = try matcher.search("unique | foo");
        defer a.free(or_bin);
        try expect(or_bin.len == 4);

        const and_bin = try matcher.search("foo bar");
        defer a.free(and_bin);
        try expect(and_bin.len == 2);

        const or_and = try matcher.search("foo foo | bar");
        defer a.free(or_and);
        try expect(or_and.len == 3);
    }
}

About

A fuzzy finder library written in zig

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages