FZF sorter for telescope written in c

Overview

telescope-fzf-native.nvim

fzf-native is a c port of fzf. It only covers the algorithm and implements few functions to support calculating the score.

Installation

To get fzf-native working, you need to run make at the root directory. As of now, we do not ship binaries.

vim-plug

Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'make' }

packer.nvim

use {'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }

Telescope Setup and Configuration:

require('telescope').setup {
  extensions = {
    fzf = {
      override_generic_sorter = false, -- override the generic sorter
      override_file_sorter = true,     -- override the file sorter
      case_mode = "smart_case",        -- or "ignore_case" or "respect_case"
                                       -- the default case_mode is "smart_case"
    }
  }
}
-- To get fzf loaded and working with telescope, you need to call
-- load_extension, somewhere after setup function:
require('telescope').load_extension('fzf')

Developer Interface

This section is only addressed towards developers who plan to use the library (c or lua bindings). This section is not addressed towards users of the telescope extension.

C Interface

slab_t *slab = make_slab(100 * 1024, 2048);
/* case_mode enum: case_smart = 0, case_ignore, case_respect
 * normalize bool: always set to false because its not implemented yet. This
 *                 is reserved for future use
 * pattern char* : pattern you want to match. e.g. "src | lua !.c$
 */
pattern_t *pattern = parse_pattern(case_smart, false, "src | lua !.c$");

/* you can get the score/position for as many items as you want */
get_score(line, pattern, slab);
get_positions(line, pattern, slab);

free_pattern(pattern);
free_slab(slab);

Lua Interface

local fzf = require('fzf_lib')

local slab = fzf.allocate_slab()
-- pattern: string
-- case_mode: number with 0 = smart_case, 1 = ignore_case, 2 = respect_case
local pattern_obj = fzf.parse_pattern(pattern, case_mode)

-- you can get the score/position for as many items as you want
-- line: string
fzf.get_score(line, pattern_obj, slab)
fzf.get_pos(line, pattern_obj, slab)

fzf.free_pattern(pattern_obj)
fzf.free_slab(slab)

Disclaimer

This project is work in progress and might not be complete compared to fzf. But i think we are at a pretty usable state already.

Another point to mention is that, this will not compare 1:1 with fzf, because telescope handles the sorting, this extension is only handling the calculation of the score. This means that the order of items with the same score might be different in telescope compared to fzf.

Example for this behaivor is this pattern in this repository: src | lua. All files that match this pattern have the same score which results in a slightly different order for telescope compared to fzf.

TODO

Stuff still missing that is present in fzf.

  • normalize
  • case for unicode (i don't think this works currently)
  • and probably more

Credit

All credit for the algorithm goes to junegunn and his work on fzf. This is merely a c fork distributed under MIT for telescope.

Issues
  •  This extension doesn't exist or is not installed: fzf

    This extension doesn't exist or is not installed: fzf

    I'm getting the following error when I startup neovim:

     This extension doesn't exist or is not installed: fzf
    

    Not sure what is happening here, if I'm correct the binary should be build automatically.

    opened by tamis-laan 18
  • How can I help with Windows support?

    How can I help with Windows support?

    Hey @Conni2461,

    You may remember me when we you helped me with a couple of PRs for telescope a while ago.

    Anyway, I am primarily a Windows user and spend a bunch of my time helping fix Windows issues with the nvim ecosystem. I can see that this plugin here requires "extra" work for Windows users that probably is not needed if we just bundle the dll with. Unlike Linux, this dll will work on Windows unchanged as it's very simple. Probably doesn't need to be built on the user's machine.

    How can I help? I can see a couple of challenges:

    • How to keep the dll updated as you make changes. I can help here of course by providing a latest. But I can see that as being a problem for scaling. Having said that, it seems that you're not making frequent changes to the code really.
    • How do you/anyone trust that the dll I am producing is safe? I can inject randomness in there. Not sure how to help with that.

    Anyway, I am available to help if it's something you need. This plugin seems almost core to Telescope now from a perf point of view. Windows users will probably not use it since compiling it locally requires extra steps. In the meantime, I will see if there's something I can do to help make building it easier?

    Thanks!

    opened by Nazeehe 14
  • seqmentation fault code dumed

    seqmentation fault code dumed

    while i use grep with this plugin with this command :lua require("telescope.builtin").grep_string({previewer = false, only_sort_text = true, cmd = os.getenv("CD"), search = vim.fn.input("Grep For > ")})

    i am testing in the moodle src code for a project with 27k files and i try to search with grep and type html and then in the result window type html and nvim core dumped

    seqmentation fault (code dumed)

    what do you need more ? ps. the src for moodle can be found in https://download.moodle.org/releases/latest

    opened by seocamo 12
  • Failed to install

    Failed to install

    Hi. I have the following packer config:

     use {                                                        
       'nvim-telescope/telescope.nvim',                           
       requires = {                                               
         {'nvim-lua/popup.nvim'},                                 
         {'nvim-lua/plenary.nvim'},                               
         {'nvim-telescope/telescope-fzy-native.nvim', run="make"},
         {'nvim-telescope/telescope-symbols.nvim'},               
       },                                                         
     }                                                            
    

    After adding run="make" clause I get

    ✗ Failed to install nvim-telescope/telescope-fzy-native.nvim
    

    message when trying to install.

    However, the plugin is installed and I can do

    require("telescope").load_extension("fzy_native")
    

    perfectly fine. I still cannot check if it is really working though.

    opened by horseinthesky 8
  • bug: items with the same score should consider length

    bug: items with the same score should consider length

    FZF uses string length as a tiebreaker by default when the score is tied between two results. Would it be possible to implement it in telescope-fzf-native too?

    In FZF:

    image

    In telescope-fzf-native:

    image

    Here in junegunn/fzf the tiebreaker logic is implemented.

    bug 
    opened by ajitid 7
  • build system: windows support + stylua style checker

    build system: windows support + stylua style checker

    Close #24

    @luisiacc Can you try if this works now? Out of the box. So checkout branch and make clean && make

    @ryanreno Can you check if OpenBSD still works after that. I need to force CC=gcc for windows. windows doesn't have cc. I only set it if the OS is windows but i still wanted to ask, if you can test it. Thanks :)

    opened by Conni2461 7
  • :Telescope fzf yields E5108: Error executing lua ...ck/packer/start/telescope.nvim/lua/telescope/command.lua:184: attempt to call a nil value

    :Telescope fzf yields E5108: Error executing lua ...ck/packer/start/telescope.nvim/lua/telescope/command.lua:184: attempt to call a nil value

    After successful :PackerSync and restart, I still cannot run :Telescope fzf. I get the following error:

    E5108: Error executing lua ...ck/packer/start/telescope.nvim/lua/telescope/command.lua:184: attempt to call a nil value 
    

    This is the relevant part of my config (packer-based, obvs)

        use {
          "nvim-telescope/telescope.nvim",
          requires = {
            "sharkdp/fd",
            "nvim-lua/plenary.nvim",
            {"nvim-telescope/telescope-packer.nvim", requires = "wbthomason/packer.nvim"},
            {"nvim-telescope/telescope-fzf-native.nvim", run = "make"}
          },
          config = function()
            local tscope = require("telescope")
            tscope.setup {}
            tscope.load_extension "packer"
            tscope.load_extension "fzf"
          end
        }
    
    
    opened by elmarsto 6
  • Not a valid Win32 application.

    Not a valid Win32 application.

    I am building libfzf.dll like this:

    gcc -O3 -Wall -Werror -fpic -shared src/fzf.c -o build/libfzf.dll

    gcc --version output:

    gcc.exe (MinGW.org GCC-6.3.0-1) 6.3.0
    Copyright (C) 2016 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    

    gcc -v output:

    Using built-in specs.
    COLLECT_GCC=C:\MinGW\bin\gcc.exe
    COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/lto-wrapper.exe
    Target: mingw32
    Configured with: ../src/gcc-6.3.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --target=mingw32 --with-gmp=/mingw --with-mpfr --with-mpc=/mingw --with-isl=/mingw --prefix=/mingw --disable-win32-registry --with-arch=i586 --with-tune=generic --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-pkgversion='MinGW.org GCC-6.3.0-1' --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --enable-libgomp --disable-libvtv --enable-nls
    Thread model: win32
    gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)
    
    Error detected while processing C:\Users\samet\AppData\Local\nvim\init.vim:
    line  149:
    E5108: Error executing lua ...lugged\telescope.nvim\lua\telescope\_extensions\init.lua:11: This extension doesn't exist or is not installed: fzf
    ...t\.vim\plugged\telescope-fzf-native.nvim\lua\fzf_lib.lua:11: cannot load module 'C:\Users\samet\.vim\plugged\telescope-fzf-native.nvim\lua\../build/libfzf.dll': %1 is not a valid Win32 application.
    

    I am currently stuck with this issue!

    opened by sametaylak 6
  • Better windows support (makefile)

    Better windows support (makefile)

    Got this error while compiling the plugin with make

    mkdir -p build
    cc -O3 -Wall -Werror -fpic -shared src/fzf.c -o build/libfzf.so
    process_begin: CreateProcess(NULL, cc -O3 -Wall -Werror -fpic -shared src/fzf.c -o build/libfzf.so, ...) failed.
    make (e=2): The system cannot find the file specified.
    make: *** [Makefile:8: build/libfzf.so] Error 2
    

    make version:

    GNU Make 4.3
    Built for Windows32
    Copyright (C) 1988-2020 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    

    As you can see, I'm on Windows 10. Same error on powershell, cmd and alacritty.

    • Tried with version 3.81 of make, same error.
    opened by luisiacc 5
  • telescope-fzf-native doesn't work with Apple M1

    telescope-fzf-native doesn't work with Apple M1

    Hey guys, i've been using fzf with telescope for a while but i recently bought a new MBP with Apple Silicon. When i try to follow the installation and setup instructions, it fails with the following error: telescope-fzf-on-m1-error

    opened by jay-dee7 5
  • allocate_slab (nil value)

    allocate_slab (nil value)

    Good day to you!

    I've got an up to date plugin and telescope I'm using default packer installation and default setup and config

    Running any command with fzf-native showing me this error:

    image

    opened by fedoranvar 5
  • Error executing Lua callback | libfzf.dll was built

    Error executing Lua callback | libfzf.dll was built

    Hello, my first github issue, not too sure where to file this.

    I followed the steps and installed the latest build that supports Windows and I've checked and indeed the dll is created in "\Local\nvim-data\site\pack\packer\start\telescope-fzf-native.nvim\build\libfzf.dll". When I relaunch nvim (version 0.7) I still get the following error:

    Error executing Lua callback: ...ck\packer\start\telescope.nvim/lua/telescope/command.lua:193: attempt to call a nil value stack traceback: ...ck\packer\start\telescope.nvim/lua/telescope/command.lua:193: in function 'run_command' ...ck\packer\start\telescope.nvim/lua/telescope/command.lua:253: in function 'load_command' ...te\pack\packer\start\telescope.nvim\plugin\telescope.lua:109: in function <...te\pack\packer\start\telescope.nvim\plugin\telescope.lua:108>

    If this is not the place to ask, thats cool.. just tell me to go pound sand.

    I did my best trying to look at the error and look at the calls provided by the error msg, but I just don't know Lua (at all) and nothing really jumped out at me. So it's not the fact that the dll isn't being created, because it is...

    really wanted to try this plugin/addon

    opened by markguzzo 2
  • Is it possible to enable the sorter for all the pickers?

    Is it possible to enable the sorter for all the pickers?

    Hi, I've been trying to make the fzf native sorter the default sorter for all the pickers but I keep finding on the sorter working only on a few of them like the find_files picker, but for example not in the lsp ones, tags or even the grep_search.

    My question is, is this a config issue on my end or a plugin issue?

    opened by SoryEscobar 1
  • [Feature request] Adding end criterion

    [Feature request] Adding end criterion

    As file name appear at the end of its path, enabling end criterion would result in accurate matches. This feature would also be helpful in the case of :Telescope tags where in the symbols are present at the end of the line.

    PS: I'm aware about this package of not keeping feature parity with original FZF. If you find this too much of a work or if this feature feels out of scope for this plugin, we can close this issue.

    opened by ajitid 1
  • Inconsistent syntax with original fzf

    Inconsistent syntax with original fzf

    Combination of NOT (!) operator and OR (|) works differently than in vanilla fzf.

    For example (on this repo with default telescope + fzf-native config):

    image

    whereas command line fzf gives me

    image
    opened by simonmandlik 4
Owner
nvim-telescope
An organization to help foster a community around telescope.nvim
nvim-telescope
Parallel bitonic sorter with limited enclave page cache (default 80MB).

Parallel Oblivious Sorter with SGX Parallel bitonic sorter with limited Intel SGX enclave page cache (default 80MB). Compile and Run Compile make clea

ZHENG Leqian 2 May 8, 2022
Connect 4 clone written with c++ with the RSGL library. Based on my connect 4 clone written in python/pygame and my SDL port of that same repo. Along with 3DS support by SaCode

RSGL-Connect-4 Building linux git clone https://github.com/RSGL-Org/RSGL-Connect-4.git cd RSGL-Connect-4 make ./Connect4 Bulding 3ds (3ds support

RSGL 2 Dec 11, 2021
KoanLogic 378 Jun 22, 2022
Single file audio playback and capture library written in C.

A single file library for audio playback and capture. Example - Documentation - Supported Platforms - Backends - Major Features - Building - Unofficia

David Reid 2.3k Jun 29, 2022
A hybrid thread / fiber task scheduler written in C++ 11

Marl Marl is a hybrid thread / fiber task scheduler written in C++ 11. About Marl is a C++ 11 library that provides a fluent interface for running tas

Google 1.4k Jun 24, 2022
A lightweight game engine written in modern C++

Halley Game Engine A lightweight game engine written in C++17. It has been used to ship Wargroove, a turn-based strategy game, on Windows, Mac (experi

Rodrigo Braz Monteiro 3k Jun 19, 2022
Horde3D is a small 3D rendering and animation engine. It is written in an effort to create an engine being as lightweight and conceptually clean as possible.

Horde3D Horde3D is a 3D rendering engine written in C++ with an effort being as lightweight and conceptually clean as possible. Horde3D requires a ful

Volker Vogelhuber 1.2k Jun 22, 2022
Very low footprint JSON parser written in portable ANSI C

Very low footprint JSON parser written in portable ANSI C. BSD licensed with no dependencies (i.e. just drop the C file into your project) Never recur

James McLaughlin 1.2k Jun 15, 2022
Lightweight JSON library written in C.

About Parson is a lightweight json library written in C. Features Full JSON support Lightweight (only 2 files) Simple API Addressing json values with

Krzysztof Gabis 1.1k Jun 18, 2022
LibTomMath is a free open source portable number theoretic multiple-precision integer library written entirely in C.

libtommath This is the git repository for LibTomMath, a free open source portable number theoretic multiple-precision integer (MPI) library written en

libtom 520 Jun 25, 2022
SymEngine is a fast symbolic manipulation library, written in C++

SymEngine SymEngine is a standalone fast C++ symbolic manipulation library. Optional thin wrappers allow usage of the library from other languages, e.

null 859 Jun 25, 2022
tiny HTTP parser written in C (used in HTTP::Parser::XS et al.)

PicoHTTPParser Copyright (c) 2009-2014 Kazuho Oku, Tokuhiro Matsuno, Daisuke Murase, Shigeo Mitsunari PicoHTTPParser is a tiny, primitive, fast HTTP r

H2O 1.5k Jun 22, 2022
:hocho: Strictly RFC 3986 compliant URI parsing and handling library written in C89; moved from SourceForge to GitHub

uriparser uriparser is a strictly RFC 3986 compliant URI parsing and handling library written in C89 ("ANSI C"). uriparser is cross-platform, fast, su

uriparser 243 Jun 26, 2022
SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages.

SWIG (Simplified Wrapper and Interface Generator) Version: 4.1.0 (in progress) Tagline: SWIG is a compiler that integrates C and C++ with languages

SWIG 4.5k Jun 25, 2022
Vireo is a lightweight and versatile video processing library written in C++11

Overview Vireo is a lightweight and versatile video processing library that powers our video transcoding service, deep learning recognition systems an

Twitter 852 Jun 27, 2022
TinyVM is a small, fast, lightweight virtual machine written in pure ANSI C.

TinyVM is a virtual machine with the goal of having a small footprint. Low memory usage, a small amount of code, and a small binary. Building can be

Joseph Kogut 2.9k Jun 22, 2022
Semantic version library written in ANSI C

semver.c Semantic version v2.0 parser and render written in ANSI C with zero dependencies. Features Standard compliant (otherwise, open an issue) Vers

Tom 169 May 16, 2022
Cross-platform, Serial Port library written in C++

Serial Communication Library (Linux and OS X) (Windows) This is a cross-platform library for interfacing with rs-232 serial like ports written in C++.

William Woodall 1.5k Jun 19, 2022
A portable, simple zip library written in C

A portable (OSX/Linux/Windows), simple zip library written in C This is done by hacking awesome miniz library and layering functions on top of the min

Kuba Podgórski 925 Jun 28, 2022
A library for high-performance, modern 2D graphics with SDL written in C.

SDL_gpu, a library for making hardware-accelerated 2D graphics easy. by Jonathan Dearborn SDL_gpu is licensed under the terms of the MIT License. See

Jonathan Dearborn 1k Jun 28, 2022
A library for high-performance, modern 2D graphics with SDL written in C.

SDL_gpu, a library for making hardware-accelerated 2D graphics easy. by Jonathan Dearborn SDL_gpu is licensed under the terms of the MIT License. See

Jonathan Dearborn 1k Jun 20, 2022
An easy to use and powerful open source websocket library written in C.

libwebsock Easy to use C library for websockets This library allows for quick and easy development of applications that use the websocket protocol, wi

Jonathan Hall 46 May 4, 2022
a software library containing BLAS functions written in OpenCL

Build Status Build branch master develop GCC/Clang x64 Visual Studio x64 clBLAS This repository houses the code for the OpenCL™ BLAS portion of clMath

null 774 Jun 23, 2022
nml is a simple matrix and linear algebra library written in standard C.

nml is a simple matrix and linear algebra library written in standard C.

Andrei Ciobanu 33 Jun 4, 2022
Multiplayer Voxel Survival in C99, includes a badly written implementation of LISP

Imagine a mix between Minecraft, Quake ]I[ and Emacs. Apart from that there is no clear plan for this game, just a bunch of ideas that hopefully will turn out to be fun. Some of these are stored here in this repo, others have been talked about on Twitch during dev streams.

Ben 72 Jun 20, 2022
Jittey - A public domain text editor written in C and Win32

Jittey (Jacob's Terrific Text Editor) is a single-file basic text editor written in pure C and Win32, there is no real reason to use it, but it

Jakub Šebek 24 Feb 22, 2022
This is the source code of SATCH a SAT solver written from scratch in C.

The main purpose of this solver is to provide a simple and clean code base for explaining and experimenting with SAT solvers. It is simpler than the source code of CaDiCaL and of Kissat in particular, while still featuring most important implementation techniques needed to obtain a state-of-the-art SAT solver

Armin Biere 64 Jun 18, 2022
My CS:GO cheat, written with performance in mind.

sinclair_csgo My CS:GO cheat, written with performance in mind. Currently in development, and I plan to keep this as such!

Gabriel 25 Apr 9, 2022
A virtual processor with a unique instruction set written in C++

Processor-Project A virtual processor with an instruction set similar to ARM made in C++. How it works This virtual processor allows the user to write

null 20 May 27, 2022