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
f90nml - A Fortran namelist parser, generator, and editor

f90nml - A Fortran namelist parser, generator, and editor A Python module and command line tool for parsing Fortran namelist files Documentation The c

Marshall Ward 110 Dec 14, 2022
Oil is a new Unix shell. It's our upgrade path from bash to a better language and runtime

Oil is a new Unix shell. It's our upgrade path from bash to a better language and runtime. It's also for Python and JavaScript users who avoid shell!

2.4k Jan 08, 2023
WA Terminal is a CLI application that allows us to login and send message with WhatsApp with a single command.

WA Terminal is a CLI application that allows us to login and send message with WhatsApp with a single command.

Aziz Fikri 15 Apr 15, 2022
A simple script that outputs the current date on the user interface/terminal.

Py-Date A simple script that outputs the current date on the user interface/terminal. How to Run Open your terminal and cd into the folder containi

Arinzechukwu Okoye 1 Jan 13, 2022
Euporie is a text-based user interface for running and editing Jupyter notebooks

Euporie is a text-based user interface for running and editing Jupyter notebooks

781 Jan 01, 2023
Python3 parser for Apple's crash reports

pyCrashReport in intended for analyzing crash reports from Apple devices into a clearer view, without all the thread listing and loaded images, just the actual data you really need to debug the probl

7 Aug 19, 2022
🌈 Lightweight Python package that makes it easy and fast to print terminal messages in colors. 🌈

🌈 Colorist for Python 🌈 Lightweight Python package that makes it easy and fast to print terminal messages in colors. Prerequisites Python 3.9 or hig

Jakob Bagterp 1 Feb 05, 2022
keep your machine's shell history synchronize

SyncShell Yet another tool for laziness Keep your machine's shell history synchronize Get SyncShell Currently, SyncShell is just available on PyPi and

Masoud Ghorbani 53 Dec 12, 2022
A tool to automatically convert old string literal formatting to f-strings

flynt - string formatting converter flynt is a command line tool to automatically convert a project's Python code from old "%-formatted" and .format(.

Elijah K 551 Jan 06, 2023
Linux commands Interpreter for Windows and Mac based systems using Python

DBHTermEcIbP Linux commands Interpreter for Windows and Mac based systems using Python Basic Linux commands supported viewing current working director

Vraj Patel 1 Dec 26, 2021
Trans is a dependency-free CLI for Google Translate

Trans is a dependency-free CLI for Google Translate

11 Jan 04, 2022
Apple Silicon 'top' CLI

asitop pip install asitop What A nvtop/htop style/inspired command line tool for Apple Silicon (aka M1) Macs. Note that it requires sudo to run due to

Timothy Liu 1.2k Dec 31, 2022
A terminal tool for git. When we use git, do you feel very uncomfortable with too long commands

PIGIT A terminal tool for git. When we use git, do you feel very uncomfortable with too long commands. For example: git status --short, this project c

Zachary 1 Apr 09, 2022
Declarative CLIs with argparse and dataclasses

argparse_dataclass Declarative CLIs with argparse and dataclasses. Features Features marked with a ✓ are currently implemented; features marked with a

Mike DePalatis 29 Dec 06, 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 (work

Jigyasu 10 Jul 27, 2022
A Command Line Error Parser Built using Python.

"Stalk Overflow with debuggy" Error Parser Everything is done in Python so it's extremely easy to install and use. Supports Python 3. Debuggy is used

Derhnyel 22 Nov 10, 2022
Play videos in the terminal.

Termvideo Play videos in the terminal (stdout). python main.py /path/to/video.mp4 Terminal size: -x output_width, -y output_height. Default autodetect

Patrick 11 Jun 13, 2022
Animefetch is an anime command-line system information tool written in python

Animefetch - v0.0.3 An anime command-line system information tool written in python. Description Animefetch is an anime command-line system informatio

Thadeuks 6 Jun 17, 2022
Limit your docker image size with a simple CLI command. Perfect to be used inside your CI process.

docker-image-size-limit Limit your docker image size with a simple CLI command. Perfect to be used inside your CI process. Read the announcing post. I

wemake.services 102 Dec 14, 2022
Execute shell command lines in parallel on Slurm, S(on) of Grid Engine (SGE), PBS/Torque clusters

qbatch Execute shell command lines in parallel on Slurm, S(on) of Grid Engine (SGE), PBS/Torque clusters qbatch is a tool for executing commands in pa

Jon Pipitone 26 Dec 12, 2022