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
Get latest astronomy job and rumor news in your command line

astrojobs Tired of checking the AAS job register and astro rumor mill for job news? Get the latest updates in the command line! astrojobs automaticall

Philip Mocz 19 Jul 20, 2022
This is a tool for managing file notes through the command line

This is a tool for managing file notes through the command line

2 Jun 22, 2022
A supercharged AWS command line interface (CLI).

SAWS Motivation AWS CLI Although the AWS CLI is a great resource to manage your AWS-powered services, it's tough to remember usage of: 70+ top-level c

Donne Martin 5.1k Jan 05, 2023
A CLI tool for using GLIDE to generate images from text.

Text-Glided-Diffusion Installation First clone this repository: git clone https://github.com/afiaka87/text-glided-diffusion.git cd text-glided-diffusi

Clay Mullis 68 Dec 30, 2022
Code for "Salient Deconvolutional Networks, Aravindh Mahendran, Andrea Vedaldi, ECCV 2016"

deconvnet_analysis Code for "Salient Deconvolutional Networks, Aravindh Mahendran, Andrea Vedaldi, ECCV 2016" Parts of this code Generate figures in t

Aravindh Mahendran 12 Jan 25, 2021
Free and Open-Source Command Line tool for Text Replacement

Sniplet Free and Open Source Text Replacement Tool Description: Sniplet is a work in progress CLI tool which can do text replacement globally in Linux

Veeraraghavan Narasimhan 13 Nov 28, 2022
A simple CLI to convert snapshots into EAVT log, and EAVT log into SCD.

EAVT helper CLI Simple CLI to convert snapshots into eavt log, and eavt log into slowly changing dimensions Usage Installation Snapshot to EAVT log EA

2 Apr 07, 2022
Command line tool for interacting and testing warehouse components

Warehouse debug CLI Example usage for Zumo debugging See all messages queued and handled. Enable by compiling the zumo-controller with -DDEBUG_MODE_EN

1 Jan 03, 2022
Display Images in your terminal with python

A python library to display images in the terminal

Pranav Baburaj 57 Dec 30, 2022
A simple file transfer tools, similar to rz / sz but compatible with tmux (control mode), which works with iTerm2 and has a nice progress bar

trzsz A simple file transfer tools, similar to rz/sz but compatible with tmux (control mode), which works with iTerm2 and has a nice progress bar. Why

561 Jan 05, 2023
Python-based implementation and comparison of strategies to guess words at Wordle

Solver and comparison of strategies for Wordle Motivation The goal of this repository is to compare, in terms of performance, strategies that minimize

Ignacio L. Ibarra 4 Feb 16, 2022
💻 Physics2Calculator - A simple and powerful calculator for Physics 2

💻 Physics2Calculator A simple and powerful calculator for Physics 2 🔌 Predefined constants pi = 3.14159... k = 8988000000 (coulomb constant) e0 = 8.

Dylan Tintenfich 4 Dec 01, 2021
🌌 A Python script to generate blog banners from command line.

Auto Blog Banner Generator A Python script to generate blog banners. This script is used at RavSam. The following image is an example of the blog bann

RavSam 10 Sep 20, 2022
PyWordle: A Python-made wordle manual solver

PyWordle: A Python-made wordle manual solver How to use it Start the program with python3 pywordlesolver.py. How it works The program has a simple 5-l

Federico Torrielli 5 Nov 24, 2022
Plumbum: Shell Combinators

Plumbum: Shell Combinators Ever wished the compactness of shell scripts be put into a real programming language? Say hello to Plumbum Shell Combinator

Tomer Filiba 2.5k Dec 28, 2022
Stephen's Obsessive Note-Storage Engine.

Latest Release · PyPi Package · Issues · Changelog · License # Get Sonse and tell it where your notes are... $ pip install sonse $ export SONSE="$HOME

Stephen Malone 23 Jun 10, 2022
AthenaCLI is a CLI tool for AWS Athena service that can do auto-completion and syntax highlighting.

Introduction AthenaCLI is a command line interface (CLI) for the Athena service that can do auto-completion and syntax highlighting, and is a proud me

dbcli 192 Jan 07, 2023
Run an FFmpeg command and see the percentage progress and ETA.

Run an FFmpeg command and see the percentage progress and ETA.

25 Dec 22, 2022
PwnWiki command line searching tool & bindings written in Python

pwsearch PwnWiki 数据库搜索命令行工具。 安装 您可以直接用 pip 命令从 PyPI 安装 pwsearch: pip3 install -U pwsearch 您也可以 clone 该仓库并直接从源码启动

PwnWiki 20 Jun 21, 2021
Objexplore is an interactive Python object explorer for the terminal.

Objexplore is an interactive Python object explorer for the terminal. Use it while debugging, or exploring a new library, or whatever! 9D1FAC73-B2A5-4

kylepollina 249 Dec 23, 2022