• Stars
    star
    130
  • Rank 269,687 (Top 6 %)
  • Language
    Lua
  • License
    MIT License
  • Created over 2 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

native telescope bindings to zf for sorting results

telescope-zf-native.nvim

native telescope bindings to zf for sorting results.

In short, zf is a filepath fuzzy finder. It is designed for better matching on filepaths than fzf or fzy. Matches on filenames are prioritized, and the strict path matching feature helps narrow down directory trees with precision. See the zf repo for full details. Some highlights:

  • a match on the filename is prioritized over a match on the full path
  • a search including path separators enables "strict path matching"
    • this means each path segment in the query must be found in a path segment of the file
    • src/ would match src/index.js but not tests/routes/client/index.js
  • the search query is space-separated to make narrowing down results easier
    • searching for init.py would find several __init__.py files in a Python project
    • but a search for init.py c would match ./config/__init__.py (or any other paths also containing c)

Why

By default, telescope uses a sorter implemented in Lua. This is fine, but performance can suffer on larger lists of data.

telescope-zf-native.nvim is a telescope extension that provides a more performant natively-compiled sorter written in Zig with more accurate filename matching using the zf algorithm. Pre-compiled libzf binaries are included. See below for the current list of supported platforms and architectures.

The zf algorithm

See the zf repo for more information on the algorithm and standalone executable (a replacement for fzf or fzy). But here's a short summary:

After analyzing filenames from over 50 git repositories selected randomly from GitHub, I concluded that the majority of filenames are unique in a project. I used this in designing the zf algorithm to make a fuzzy-finder that is optimized for filtering filepaths.

  • Matches on filenames are highly favored over filepath matches
  • Matches on the beginning of a word are prioritized over matches in the middle of a word
  • Non-sequential character matches are penalized

With these heuristics, zf does a really good job sorting the desired file to the top of the results list. But there are plenty of files that share the same or similar names like init.lua or __init__.py for example. zf parses the query string as a list of space-delimited tokens to easily refine the search results when the first match isn't the wanted file. Simply append further terms to the query to narrow down the results.

Installation

Install in neovim with a package manager like packer.nvim or vim-plug.

--- packer
use "natecraddock/telescope-zf-native.nvim"

Then load the extension in telescope with default settings.

require("telescope").load_extension("zf-native")

The default config replaces the default telescope sorters with zf for all sorting. To confirm that the extension loaded properly, and to view the current settings, run :checkhealth zf-native.

For additional configuration, use the following:

require("telescope").setup({
    extensions = {
        ["zf-native"] = {
            -- options for sorting file-like items
            file = {
                -- override default telescope file sorter
                enable = true,

                -- highlight matching text in results
                highlight_results = true,

                -- enable zf filename match priority
                match_filename = true,
            },

            -- options for sorting all other items
            generic = {
                -- override default telescope generic item sorter
                enable = true,

                -- highlight matching text in results
                highlight_results = true,

                -- disable zf filename match priority
                match_filename = false,
            },
        }
    },
})

require("telescope").load_extension("zf-native")

The above settings are the default, so if you are satisfied with the defaults there is no need to change anything.

Supported Platforms

The lib/ directory contains libzf pre-compiled libraries for:

  • linux (x86 and arm)
  • macos (x86 and arm)
  • windows (x86)

If your OS is not supported, or there are issues loading the libraries please submit an issue. For requests of support of new platforms or any other issue, please include the output of :checkhealth zf-native in the issue.

Related

I also thank the developers who worked on these projects as my reference for using the LuaJIT FFI.

More Repositories

1

zf

a commandline fuzzy finder designed for filtering filepaths
Zig
327
star
2

workspaces.nvim

a simple plugin to manage workspace directories in neovim
Lua
270
star
3

projectile

An artist-friendly tool for throwing stuff around inside Blender
Python
149
star
4

sessions.nvim

a simple session manager plugin
Lua
125
star
5

ziglua

Zig bindings for the Lua C API
C
81
star
6

open-reckless-drivin

A work-in-progress open source reimplementation of the classic Macintosh shareware game Reckless Drivin'
C
33
star
7

nvim-find

A fast and simple finder plugin for Neovim
Lua
15
star
8

AddonDevelopmentTool

A Blender addon to aid in the development of Blender addons by providing quick access to repetitive operations
Python
11
star
9

terminal-tetris

C
5
star
10

dotfiles

My configurations for linux
Lua
5
star
11

pixel-maker

Blender Pixel Maker Addon
Python
4
star
12

aoc

Advent of Code puzzle solutions
Zig
4
star
13

ninsheetmusic-search

A simple flask app to add search to the ninsheetmusic dataset
Python
4
star
14

page-zipper

Merges (zips) right and left captured pages of books
Python
3
star
15

dr-epilepsy

A 2.80 update of the classic Blender addon. Dr Epilepsy will melt your brain!
Python
2
star
16

pilaroid-camera

A raspberry pi Polaroid camera
Python
2
star
17

taps

Homebrew taps
2
star
18

tabstash

Like `git stash` but for tabs
TypeScript
1
star
19

audio-vis

A Blender python addon that allows for very easy audio visualizations.
Python
1
star
20

graphics_project

JavaScript
1
star
21

website

CSS
1
star
22

sandbox

a public place for my experiments
Zig
1
star
23

zygrader

A Python 3 ncurses tool to facilitate grading student submissions on the zyBooks online programming system
Python
1
star
24

chip-8

C
1
star
25

scriptures-search

JavaScript
1
star