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
Standalone script written in Python 3 for generating Reverse Shell one liner snippets and handles the communication between target and client using custom Netcat binaries

Standalone script written in Python 3 for generating Reverse Shell one liner snippets and handles the communication between target and client using custom Netcat binaries. It automates the boring stu

Yash Bhardwaj 3 Sep 27, 2022
Command line interface for unasync

CLI for unasync Command line interface for unasync Getting started Install Run the following command to install the package with pip: pip install unas

Leynier Gutiérrez González 3 Apr 04, 2022
Simple subcommand CLIs with argparse

multicommand Simple subcommand CLIs with argparse. multicommand uses only the standard library and is ~150 lines of code (modulo comments and whitespa

Andrew Ross 10 Aug 01, 2022
A python script that enables a raspberry pi sd card through the CLI and automates the process of configuring network details and ssh.

This project is one script (wpa_helper.py) written in python that will allow for the user to automate the proccess of setting up a new boot disk and configuring ssh and network settings for the pi

Theo Kirby 6 Jun 24, 2021
Chameleon is yet another PowerShell obfuscation tool designed to bypass AMSI and commercial antivirus solutions.

Chameleon is yet another PowerShell obfuscation tool designed to bypass AMSI and commercial antivirus solutions. The tool has been developed as a Python port of the Chimera project, by tokioneon_.

332 Dec 26, 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
A dashboard for your Terminal written in the Python 3 language,

termDash is a handy little program, written in the Python 3 language, and is a small little dashboard for your terminal, designed to be a utility to help people, as well as helping new users get used

Rebecca White 2 Dec 03, 2021
liquidctl – liquid cooler control Cross-platform tool and drivers for liquid coolers and other devices

Cross-platform CLI and Python drivers for AIO liquid coolers and other devices

1.7k Jan 08, 2023
Password manager for the CLI simps.

CLI Password Manager Password manager for the CLI simps. Free software: MIT license

1 Dec 30, 2021
bsp_tool provides a Command Line Interface for analysing .bsp files

bsp_tool Python library for analysing .bsp files bsp_tool provides a Command Line Interface for analysing .bsp files Current development is focused on

Jared Ketterer 64 Dec 28, 2022
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
Simple tool, to update linux kernel on ubuntu

Kerbswap Simple tool, to update linux kernel on ubuntu Information At the moment, this tool only supports "Ubuntu" distributions, but will be expanded

dword 1 Oct 31, 2021
Salesforce object access auditor

Salesforce object access auditor Released as open source by NCC Group Plc - https://www.nccgroup.com/ Developed by Jerome Smith @exploresecurity (with

NCC Group Plc 90 Sep 19, 2022
A python based command line tool to compare Github Users or Repositories

gitcomp A simple python package with a CLI to compare GitHub users and repositories by associating a git_score to each entry which is a weighted sum o

Anirudh Vaish 5 Mar 26, 2022
a-shell: A terminal for iOS, with multiple windows

a-shell: A terminal for iOS, with multiple windows

Nicolas Holzschuch 1.7k Jan 02, 2023
A Python-based Wordle solver and CLI player

Wordle A Python-based Wordle solver and CLI player This was created using Python 3.9.7. SPOILER ALERT: the data directory contains spoilers for upcomi

Will Fitzgerald 1 Jul 24, 2022
Notion-cli-list-manager - A simple command-line tool for managing Notion databases

A simple command-line tool for managing Notion List databases. ✨

Giacomo Salici 75 Dec 04, 2022
Wordle helper: help you print posible 5-character words based on you input

Wordle Helper This program help you print posible 5-character words based on you

Gwan Thanakrit Juthamongkhon 4 Jan 19, 2022
pypinfo is a simple CLI to access PyPI download statistics via Google's BigQuery.

pypinfo: View PyPI download statistics with ease. pypinfo is a simple CLI to access PyPI download statistics via Google's BigQuery. Installation pypin

Ofek Lev 351 Dec 26, 2022