Freaky fast fuzzy Denite/CtrlP matcher for vim/neovim

Overview

Freaky fast fuzzy Denite/CtrlP matcher for vim/neovim

Installation

In your .vimrc:

fruzzy#install()}} " optional - but recommended - see below let g:fruzzy#usenative = 1 " When there's no input, fruzzy can sort entries based on how similar they are to the current buffer " For ex: if you're on /path/to/somefile.h, then on opening denite, /path/to/somefile.cpp " would appear on the top of the list. " Useful if you're bouncing a lot between similar files. " To turn off this behavior, set the variable below to 0 let g:fruzzy#sortonempty = 1 " default value " tell denite to use this matcher by default for all sources call denite#custom#source('_', 'matchers', ['matcher/fruzzy']) " tell CtrlP to use this matcher let g:ctrlp_match_func = {'match': 'fruzzy#ctrlp#matcher'} let g:ctrlp_match_current_file = 1 " to include current file in matches">
" vim-plug; for other plugin managers, use what's appropriate
" if you don't want to trust a prebuilt binary, skip the 'do' part
" and build the binaries yourself. Instructions are further down
" and place them in the /path/to/plugin/rplugin/python3 folder

Plug 'raghur/fruzzy', {'do': { -> fruzzy#install()}}

" optional - but recommended - see below
let g:fruzzy#usenative = 1

" When there's no input, fruzzy can sort entries based on how similar they are to the current buffer
" For ex: if you're on /path/to/somefile.h, then on opening denite, /path/to/somefile.cpp
" would appear on the top of the list.
" Useful if you're bouncing a lot between similar files.
" To turn off this behavior, set the variable below  to 0

let g:fruzzy#sortonempty = 1 " default value

" tell denite to use this matcher by default for all sources
call denite#custom#source('_', 'matchers', ['matcher/fruzzy'])

" tell CtrlP to use this matcher
let g:ctrlp_match_func = {'match': 'fruzzy#ctrlp#matcher'}
let g:ctrlp_match_current_file = 1 " to include current file in matches

Native modules

Native module gives a 10 - 15x speedup over python - ~40-60μs!. Not that you’d notice it in usual operation (python impl is at 300 - 600μs)

  1. Run command :call fruzzy#install() if you’re not using vim-plug.

  2. restart nvim

Manual installation

  1. Download the module for your platform. If on mac, rename to fruzzy_mod.so

  2. place in /path/to/fruzzy/rplugin/python3

  3. Make sure you set the pref to use native module - g:fruzzy#usenative=1

  4. restart vim/nvim

Troubleshooting/Support

Raise a ticket - please include the following info:

Get the version
  1. Start vim/nvim

  2. Activate denite/ctrlp as the case may be.

  3. Execute :call fruzzy#version() - this will print one of the following

    1. version number and branch - all is good

    2. purepy - you’re using the pure python version.

    3. modnotfound - you requested the native mod with let g:fruzzy#usenative=1 but it could not be loaded

    4. outdated - native mod was loaded but it’s < v0.3. You can update the native mod from the releases.

  4. include output of the above

Describe the issue
  1. include the list of items

  2. include your query

  3. What it did vs what you expected it to do.

Development

Build native module
  1. install nim >= 0.19

  2. dependencies

    1. nimble install binaryheap

    2. nimble install nimpy

  3. cd rplugin/python3

  4. [Windows] nim c --app:lib --out:fruzzy_mod.pyd -d:release -d:removelogger fruzzy_mod

  5. [Linux] nim c --app:lib --out:fruzzy_mod.so -d:release -d:removelogger fruzzy_mod

  6. -d:removelogger

    • removes all log statements from code.

    • When removelogger is not defined, only info level logs are emitted

    • Debug builds (ie: without -d:release flag) also turns on additional debug level logs

Running tests
  1. cd rplugin

  2. pytest - run tests with python implementation

  3. FUZZY_CMOD=1 pytest - run tests with native module

Comments
  • Don't sort if there is not filtering input

    Don't sort if there is not filtering input

    Hi, if I use let g:fruzzy#usenative = 0 with Denite file_mru candidates are correctly ordered by the last recent one opened first:

    ~/OneDrive/jampp/repos/macross/docs/docs/macross/win_rate.md
    ~/OneDrive/jampp/repos/macross-daat/daat/model.py
    ~/OneDrive/jampp/repos/macross-daat/docs/docs/estimator.md
    ~/OneDrive/jampp/repos/macross/docs/docs/macross/model.md
    ~/git-repos/private/dotfiles/setup-new/yay.sh
    ~/git-repos/private/dotfiles/vim/ftplugin/python/python_settings.vim
    ~/OneDrive/arch/install_notes.md
    ~/git-repos/work/ausa/store/requirements.txt
    ~/git-repos/private/dotfiles/python/requirements.txt
    ~/git-repos/private/dotfiles/setup-new/brew.sh
    ~/OneDrive/varios/todos_coding_setup.md
    ~/git-repos/private/dotfiles/vim/mysnippets/vim.snippets
    ~/git-repos/private/dotfiles/bashrc
    ~/git-repos/private/dotfiles/vim/vimrc_min
    ~/git-repos/private/dotfiles/vimrc
     Denite  file_mru(235/236)                                                                                      [/home/pedro/git-repos/private/dotfiles]  235/235
    

    on the other hand if i use let g:fruzzy#usenative = 1 then I get:

    ~/Desktop/lela.md
    ~/Desktop/bar.sh
    /etc/resolv.conf
    ~/Desktop/baz.sh
    ~/Desktop/bar.py
    ~/Desktop/foo.md
    ~/Desktop/api.py
    ~/Desktop/foo.sh
    ~/Desktop/foo.py
    ~/Desktop/baz.py
    ~/.bash_history
    ~/.Xauthority
    ~/.mongorc.js
    ~/.lesshst
    ~/.fehbg
    

    So my question is: if fruzzy is a matching/filtering algorithm why is it also sorting candidates without any kind of filtering input? I expect it to honor the initial source sorting.

    Another thing I've noticed is that when using the native version I get the following message before executing a denite source:

    [denite] fruzzy_mod ver: rev: v0.3 on branch: master
    

    Can that message be suppressed? Thanks in advance

    opened by petobens 17
  • KeyError: bufnr

    KeyError: bufnr

    Consider the following minimal vimrc:

    set nocompatible
    
    let $DOTVIM = expand('$HOME/.config/nvim')
    
    set runtimepath+=$DOTVIM/bundle/repos/github.com/Shougo/denite.nvim
    set runtimepath+=$DOTVIM/bundle/repos/github.com/raghur/fruzzy
    filetype plugin indent on
    
    call denite#custom#source('_', 'matchers', ['matcher/fruzzy'])
    
    function! s:DeniteScanDir()
        let narrow_dir = input('Input narrowing directory: ', '', 'file')
        if narrow_dir == ''
            return
        endif
        call denite#start([{'name': 'file/rec', 'args': [narrow_dir]}])
    endfunction
    
    nnoremap <silent> ,sd :call <SID>DeniteScanDir()<CR>
    

    If I now type ,sd and then use . as narrowing dir then I get the following error:

    [denite] Traceback (most recent call last):
    [denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/init.vim/.dein/rplugin/python3/denite/__init__.py", line 29, in start
    [denite]     return ui.start(args[0], args[1])
    [denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/init.vim/.dein/rplugin/python3/denite/ui/default.py", line 71, in start
    [denite]     self._start(context['sources_queue'][0], context)
    [denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/init.vim/.dein/rplugin/python3/denite/ui/default.py", line 121, in _start
    [denite]     self.update_candidates()
    [denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/init.vim/.dein/rplugin/python3/denite/ui/default.py", line 312, in update_candidates
    [denite]     self._denite.filter_candidates(self._context)):
    [denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/init.vim/.dein/rplugin/python3/denite/denite.py", line 120, in filter_candidates
    [denite]     self.match_candidates(ctx, matchers)
    [denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/init.vim/.dein/rplugin/python3/denite/denite.py", line 159, in match_candidates
    [denite]     context['candidates'] = self.call_matchers(ctx, matchers)
    [denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/init.vim/.dein/rplugin/python3/denite/denite.py", line 163, in call_matchers
    [denite]     ctx['candidates'] = matcher.filter(ctx)
    [denite]   File "/home/pedro/.config/nvim/bundle/repos/github.com/raghur/fruzzy/rplugin/python3/denite/filter/matcher/fruzzymatcher.py", line 55, in filter
    [denite]     buffer = context['bufnr']
    [denite] KeyError: 'bufnr'
    [denite] Please execute :messages command.
    

    BTW: Thanks for this awesome matcher.

    opened by petobens 16
  • Too many data will crash native fruzzy matcher

    Too many data will crash native fruzzy matcher

    When I use Denite with command_history source that will list vim command history and use native fruzzy matcher, it will crash. The detail bug information can be found in Shougo/denite.nvim#636. When I use nvim -i NONE to ignore previous command history, the problem is gone. So I think it's probably because my vim command history is too large.

    opened by mars90226 12
  • Crash on quit.

    Crash on quit.

    Hi there,

    I got a crash today using fruzzy when I quit nvim (or so I believe, I'm not 100% sure). Nothing serious but I thought I'd post the crashlog here since it might be of help in solving some bugs.

    https://pastebin.com/eRaqjzSR

    Thanks for the awesome plugin,

    Greetings, Sander.

    opened by sandersantema 7
  • Is it possible to write a CtrlP matcher with this?

    Is it possible to write a CtrlP matcher with this?

    Based on the description, I suspect it should be possible to write a CtrlP matcher with this as a backend. Do you think this is possible?

    See also ctrlp-py-matcher and cpsm.

    opened by lervag 7
  • Dein Plugin Manager removes .so files from rplugin/python folder after update of plugins/ :UpdateRemotePlugins

    Dein Plugin Manager removes .so files from rplugin/python folder after update of plugins/ :UpdateRemotePlugins

    The dein plugin manager removes .so files from .config/dein/.cache/init.vim/.dein/rplugin/python3/ while it doesn't do so with other plugins which install to the same directory. Do you have any idea why this might be? The dein documentation doesn't mention anything about adding the files as a requirement for a plugin.

    opened by sandersantema 5
  • KeyError: action__path

    KeyError: action__path

    Consider the following minimal vimrc:

    set nocompatible
    
    let $DOTVIM = expand('$HOME/.config/nvim')
    
    set runtimepath+=$DOTVIM/bundle/repos/github.com/Shougo/denite.nvim
    set runtimepath+=$DOTVIM/bundle/repos/github.com/raghur/fruzzy
    filetype plugin indent on
    
    
    let g:fruzzy#usenative = 0
    call denite#custom#source('_', 'matchers', ['matcher/fruzzy',
            \ 'matcher/ignore_globs'])
    

    Now open vim/nvim and run :Denite command. I get the following error:

    [denite] Traceback (most recent call last):
    [denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/init.vim/.dein/rplugin/python3/denite/__init__.py", line 29, in start
    [denite]     return ui.start(args[0], args[1])
    [denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/init.vim/.dein/rplugin/python3/denite/ui/default.py", line 71, in start
    [denite]     self._start(context['sources_queue'][0], context)
    [denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/init.vim/.dein/rplugin/python3/denite/ui/default.py", line 121, in _start
    [denite]     self.update_candidates()
    [denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/init.vim/.dein/rplugin/python3/denite/ui/default.py", line 312, in update_candidates
    [denite]     self._denite.filter_candidates(self._context)):
    [denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/init.vim/.dein/rplugin/python3/denite/denite.py", line 120, in filter_candidates
    [denite]     self.match_candidates(ctx, matchers)
    [denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/init.vim/.dein/rplugin/python3/denite/denite.py", line 159, in match_candidates
    [denite]     context['candidates'] = self.call_matchers(ctx, matchers)
    [denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/init.vim/.dein/rplugin/python3/denite/denite.py", line 163, in call_matchers
    [denite]     ctx['candidates'] = matcher.filter(ctx)
    [denite]   File "/home/pedro/.config/nvim/bundle/repos/github.com/Shougo/denite.nvim/rplugin/python3/denite/filter/matcher/ignore_globs.py", line 42, in filter
    [denite]     return [x for x in context['candidates']
    [denite]   File "/home/pedro/.config/nvim/bundle/repos/github.com/Shougo/denite.nvim/rplugin/python3/denite/filter/matcher/ignore_globs.py", line 43, in <listcomp>
    [denite]     if not search(pattern, x['action__path'][:max_width])]
    [denite] KeyError: 'action__path'
    [denite] Please execute :messages command.
    

    Maybe it's something with recen updates with Denite @Shougo? Thanks

    opened by petobens 4
  • fruzzy install fail

    fruzzy install fail

    platform: macOS 10.14 neovim: 0.3.1 Python: 3.7.0 Error stack:

    Error detected while processing function fruzzy#install[1]..provider#python3#Call:
    line   18:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/Users/seekr/.vim/bundle/fruzzy/python3/fruzzy_installer.py", line 34, in install
        print("fruzzy: downloading %s to %s" % (asset['browser_download_url'],
    TypeError: 'NoneType' object is not subscriptable
    

    Although it downloads native mod fail, it still work well for me. Thanks for your work! Awesome matcher

    opened by numbcoder 4
  • Crash on dein#recache_runtimepath()

    Crash on dein#recache_runtimepath()

    When doing call dein#recache_runtimepath(), I get this error:

    [dein] "C:/Users/cbrunel/AppData/Local/nvim/dein/.cache/init.vim/.dein" cannot be removed.
    [dein] cmdline is "rmdir /S /Q "C:\\Users\\cbrunel\\AppData\\Local\\nvim\\dein\\.cache\\init.vim\\.dein"".
    

    After trying to remove it with PowerShell, I saw that the file fruzzy_mod.pyd is still in use and therefore cannot be deleted. Is there any way to get over this issue?

    opened by Luxed 2
  • [python]: Bug - does not find match

    [python]: Bug - does not find match

    from PR #7

        l = ['.gitignore', 'README.adoc', 'python3/ctrlp.py',
                 'plugin/fruzzy.vim', 'autoload/fruzzy.vim',
                 'autoload/fruzzy/ctrlp.vim', 'rplugin/python3/fruzzy.py',
                 'rplugin/python3/qc-fast.py', 'python3/fruzzy_installer.py',
                 'rplugin/python3/neomru_file', 'rplugin/python3/qc-single.py',
                 'rplugin/python3/fruzzy_mod.nim', 'rplugin/python3/fruzzy_test.py',
                 'rplugin/python3/denite/filter/matcher/fruzzymatcher.py']
        results = scoreMatches("fmf", l, 10, True)
    

    Python version does not find rplugin/python3/denite/filter/matcher/fruzzymatcher.py

    opened by raghur 1
  • fix install for native module on mac

    fix install for native module on mac

    Current binary file not works on mac, as described at #2. I've uploaded the binary for mac at https://github.com/raghur/fruzzy/files/2433524/fruzzy.zip it need to be unzipped and upload to the release page as fruzzy_mod_mac.so

    opened by chemzqm 1
  • Set match limit to 1000

    Set match limit to 1000

    Constraining the match limit to winheight provides the user too few matches.

    Raising the limit to 1,000 makes the plugin behavior consistent with other filters, e.g., cpsm.

    opened by gotgenes 0
  • Feature request: Add deoplete matcher filter

    Feature request: Add deoplete matcher filter

    For comparison:

    • denite: https://github.com/Shougo/denite.nvim/blob/609c85797a5f6acc2e2357cf56e7f6c78c561145/rplugin/python3/denite/filter/matcher/cpsm.py
    • Deoplete: https://github.com/Shougo/deoplete.nvim/blob/bbec852adee45a1500fa817a3c17889dc328cad0/rplugin/python3/deoplete/filter/matcher_cpsm.py

    They're pretty similar, aside from matcher_fruzzy instead of matcher/fruzzy. :)

    opened by bb010g 0
Releases(v0.4)
Owner
Raghu
Raghu
A helper program to play wordle

A helper program to play wordle

1 Jan 22, 2022
Autosub - Command-line utility for auto-generating subtitles for any video file

Auto-generated subtitles for any video Autosub is a utility for automatic speech recognition and subtitle generation. It takes a video or an a

Anastasis Germanidis 3.9k Jan 05, 2023
Themes for Windows Terminal

Windows Terminal Themes Preview and copy themes for the new Windows Terminal. Use the project at windowsterminalthemes.dev How to use the themes This

Tom 1.1k Jan 03, 2023
CmdTube is a Python CLI library for searching, downloading, and watching YouTube tutorials

CmdTube is a Python CLI library for searching, downloading, and watching YouTube tutorials. This library was made with programmers in mind and it's dedicated to every programmer who watches YouTube v

Samuel Ayomide Ogunleke 2 Aug 22, 2022
A command line tool to hide and reveal information inside images (works for both PNGs and JPGs)

Imgrerite A command line tool to hide and reveal information inside images (works for both PNGs and JPGs) Dependencies Python 3 Git Most of the Linux

Jigyasu 10 Jul 27, 2022
A minimal todo list for your terminal.

todo A minimal todo list for your terminal. Installation Run the following command. pip install git+https://github.com/piero-vic/todo.git Usage todo

Piero Lescano 7 Aug 08, 2022
alternative cli util for update-alternatives

altb altb is a cli utility influenced by update-alternatives of ubuntu. Linked paths are added to $HOME/.local/bin according to XDG Base Directory Spe

Elran Shefer 8 Dec 07, 2022
Lsp Plugin for working with Python virtual environments

py_lsp.nvim What is py_lsp? py_lsp.nvim is a neovim plugin that helps with using the lsp feature for python development. It tackles the problem about

Patrick Haller 55 Dec 27, 2022
An question and answer shell environment based on xonsh using ansible for setup

An question and answer shell environment based on xonsh using ansible for setup

Steven Hollingsworth 2 Jan 11, 2022
Pyrdle - Play Wordle in the CLI. Write an algorithm to play Wordle for you. Ruin all of the fun you've been having

Pyrdle - Play Wordle in the CLI. Write an algorithm to play Wordle for you. Ruin all of the fun you've been having

Charles Tapley Hoyt 11 Feb 11, 2022
A Tempmail Tool for Terminal and Termux.

A Tempmail Tool for Terminal and Termux.

MAO-COMMUNITY 8 Oct 19, 2022
CLI tool to develop StarkNet projects written in Cairo

⛵ Nile Navigate your StarkNet projects written in Cairo. Installation pip install cairo-nile Usage Install Cairo Use nile to install a given version o

Martín Triay 305 Dec 30, 2022
spid-sp-test is a SAML2 SPID/CIE Service Provider validation tool that can be executed from the command line.

spid-sp-test spid-sp-test is a SAML2 SPID/CIE Service Provider validation tool that can be executed from the command line. This tool was born by separ

Developers Italia 30 Nov 08, 2022
Cthulhu is a simple python CLI application that streams torrents directly from 1337x.

Cthulhu is a simple python CLI application that facilitates the streaming of torrents directly from 1337x. It uses webtorrent to stream video

Raiyan 27 Dec 27, 2022
A python command line tool to calculate options max pain for a given company symbol and options expiry date.

Options-Max-Pain-Calculator A python command line tool to calculate options max pain for a given company symbol and options expiry date. Overview - Ma

13 Dec 26, 2022
Simple CLI interface for linear task manager

Linear CLI (Unmaintained) Simple CLI interface for linear task manager Usage Install: pip install linearcli Setup: Generate a pe

Mike Lyons 1 Jan 07, 2022
Juniper Command System is a Micro CLI Tool that allows you to manage your files, launch applications, as well as providing extra tools for OS Management.

Juniper Command System is a Micro CLI Tool that allows you to manage your files, launch applications, as well as providing extra tools for OS Management.

Juan Carlos Juárez 1 Feb 02, 2022
git-partial-submodule is a command-line script for setting up and working with submodules while enabling them to use git's partial clone and sparse checkout features.

Partial Submodules for Git git-partial-submodule is a command-line script for setting up and working with submodules while enabling them to use git's

Nathan Reed 15 Sep 22, 2022
A Python module and command line utility for working with web archive data using the WACZ format specification

py-wacz The py-wacz repository contains a Python module and command line utility for working with web archive data using the WACZ format specification

Webrecorder 14 Oct 24, 2022
CLI utility to search and download torrents from major torrent sites

CLI Torrent Downloader About CLI Torrent Downloader provides convenient and quick way to search torrent magnet links (and to run associated torrent cl

x0r0x 86 Dec 19, 2022