Code Monkey home page Code Monkey logo

fuzzyy's Introduction

Fuzzyy

A fuzzy picker for files, strings, help documents and many other things.

It ultilizes vim's native matchfuzzypos function and popup window feature.

Screenshots

screenshot

gif

Requirements

  • vim > 9.0
    • The maintained version is written in vim9, but it also has a vim8 branch for older vim.
  • any of grep, ag or rg
  • find or fd
  • vim-devicons (optional)

Install

Any plugin manager will work.

For vim-plug

Plug 'Donaldttt/fuzzyy'

Commands

Command Description Default Keymap
FuzzyGrep <args> grep string in project. if argument is given, it will search the <args> <leader>fr
FuzzyFiles search files in project <leader>ff
FuzzyHelps search :help documents <leader>fd
FuzzyColors search installed colorscheme <leader>fc
FuzzyInBuffer <args> search lines in current buffer. if argument is given, it will search the <args> <leader>fb
FuzzyCommands search commands <leader>fi
FuzzyBuffers search opened buffers <leader>ft
FuzzyHighlights search highlights <leader>fh
FuzzyMRUFiles search the most recent used files. set g:enable_fuzzyy_MRU_files = 1 to enable this command(not enable by default) <leader>fm
FuzzyGitFiles like FuzzyFiles but only shows file in git project None
  • For FuzzyGrep and FuzzyInBuffer, you can define a keymap like this to search the word under cursor.

        nnoremap <Space>f :FuzzyGrep <C-R><C-W><CR>
  • FuzzyGrep requires any of grep, ag or rg command.

  • FuzzyFiles uses find command in unix (if not found it will use vim's glob function, which is blocking) or powershell's Get-ChildItem in windows. (if fd is installed, it will be used)

Navigation

Arrow keys or ctrl + p/ ctrl + n moves up/down the menu

ctrl + u/ctrl + d moves up/down the buffer in preview window

you can set g:fuzzyy_keymaps to change these defaults.

Command Specific keymaps

  • FuzzyHighlights

    • ctrl + k toggle white preview background color
    • Enter will copy selected highlight
  • FuzzyMRUFiles

    • ctrl + k toggle global or project MRU files
  • FuzzyBuffers, FuzzyMRUFiles, FuzzyFiles, FuzzyGitFiles

    • ctrl + s open selected file in horizontal spliting
    • ctrl + v open selected file in vertical spliting
    • ctrl + t open selected file in new tab page

Default Keymaps

you can set g:enable_fuzzyy_keymaps = 0 to disable default keymaps

nnoremap <silent> <leader>fb :FuzzyInBuffer<CR>
nnoremap <silent> <leader>fc :FuzzyColors<CR>
nnoremap <silent> <leader>fd :FuzzyHelps<CR>
nnoremap <silent> <leader>ff :FuzzyFiles<CR>
nnoremap <silent> <leader>fi :FuzzyCommands<CR>
nnoremap <silent> <leader>fr :FuzzyGrep<CR>
nnoremap <silent> <leader>ft :FuzzyBuffers<CR>
nnoremap <silent> <leader>fh :FuzzyHighlights<CR>

Options

" Set to 0 to disable default keybindings
" Default to 1
let g:enable_fuzzyy_keymaps = 0

" Make FuzzyFiles respect .gitignore if set to 1
" only work when
" 1. inside a git repository and git is installed
" 2. or fd is installed
" Default to 0
let g:files_respect_gitignore = 1

" Change navigation keymaps
" The following is the default
let g:fuzzyy_keymaps = {
\     'menu_up': ["\<c-p>", "\<Up>"],
\     'menu_down': ["\<c-n>", "\<Down>"],
\     'menu_select': ["\<CR>"],
\     'preview_up': ["\<c-u>"],
\     'preview_down': ["\<c-d>"],
\     'cursor_begining': ["\<c-a>"],          " move cursor to the begining of the line in the prompt
\     'cursor_end': ["\<c-e>"],               " move cursor to the end of the line in the prompt
\     'delete_all': ["\<c-k>"],               " delete whole line of the prompt
\.    'delete_prefix': [],                    " delete to the start of the line
\     'exit': ["\<Esc>", "\<c-c>", "\<c-[>"], " exit fuzzyy
\ }

" Change highlight of the matched text when searching
" Default to cursearch
let g:fuzzyy_menu_matched_hl = 'cursearch'

" Whether show devicons when using FuzzyFiles or FuzzyBuffers
" Requires vim-devicons
" Default to 1 if vim-devicons is installed, 0 otherwise
let g:fuzzyy_devicons = 1

" Enable dropdown theme
" Default to 0
let g:fuzzyy_dropdown = 1

" Enable FuzzyMRUFiles command.
" If enabled, the MRU list will be recorded into ~/.vim_mru_files in Unix
" and ~/_vim_mru_files in Windows
" Default to 0
let g:enable_fuzzyy_MRU_files = 1

" FuzzyMRUFiles default shows MRU files that are in the current project
" default to 0
let g:fuzzyy_mru_project_only = 0

" window layout configuraton
" you can override it by setting g:fuzzyy_window_layout
" e.g. You can disable preview window for FuzzyFiles command by doing this:
" let g:fuzzyy_window_layout = { 'FuzzyFiles': { 'preview': 0 } }
" default value:
{
    'FuzzyFiles': {
        'preview': 1,         " 1 means enable preview window, 0 means disable
        'preview_ratio': 0.5, " 0.5 means preview window will take 50% of the layout
        'width': 0.8,         " 0.8 means total width of the layout will take 80% of the screen
    },
    'FuzzyGrep': {
        'preview': 1,
        'preview_ratio': 0.5,
        'width': 0.8,
    },
    'FuzzyBuffers': {
        'preview': 1,
        'preview_ratio': 0.5,
        'width': 0.8,
    },
    'FuzzyMRUFiles': {
        'preview': 1,
        'preview_ratio': 0.5,
        'width': 0.8,
    },
    'FuzzyHighlights': {
        'preview': 1,
        'preview_ratio': 0.7,
        'width': 0.8,
    },
}

Credit

The code in autoload/utils/mru.vim is modified from yegappan/mru.

fuzzyy's People

Contributors

donaldttt avatar ilango100 avatar xaizek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fuzzyy's Issues

Search that respects caps

Hello,

Great work on this plugin!
Is there a way to configure this plugin to respect caps in my search query?

E121: Undefined variable: files

I get this error for all of the defined commands (replace 'files' with 'colors', 'ag', etc.), updated to latest commit just now and I'm on macvim 9.0.1403.

[Feature Request] Readline bindings for the finder prompt

I'm not sure if its just me, but I am very dug in on using the readline keybindings when navigating a line editor.
Ctrp-{p,n} is implemented and works great, but i would like to be able to use Ctrl-{a,k,e} do navigate to the beginning and end of the line aswell as kill the line completly.

Is there anyway for me to create these mappings using the current state of the plugin ?

Killer plugin tho! Love it
Best regards

Key not present in Dictionary: "delete_prefix"

Hello,
after the latest commit I'm getting the following error when executing any fuzzyy command (e.g. :FuzzyGitFiles) , which blocks keyboard from interacting with the plugin:

Error detected while processing function <SNR>92_PromptFilter:                                                                                                                          
line   47:
E716: Key not present in Dictionary: "delete_prefix"
Press ENTER or type command to continue

Environment: Fedora 38 + Vim 9, specifically:

vim --version
VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Dec 15 2023 00:00:00)
Included patches: 1-2167
Modified by <[email protected]>
Compiled by <[email protected]>
Huge version without GUI.  Features included (+) or not (-):
+acl               +file_in_path      +mouse_urxvt       -tag_any_white
+arabic            +find_in_path      +mouse_xterm       -tcl
+autocmd           +float             +multi_byte        +termguicolors
+autochdir         +folding           +multi_lang        +terminal
-autoservername    -footer            -mzscheme          +terminfo
-balloon_eval      +fork()            +netbeans_intg     +termresponse
+balloon_eval_term +gettext           +num64             +textobjects
-browse            -hangul_input      +packages          +textprop
++builtin_terms    +iconv             +path_extra        +timers
+byte_offset       +insert_expand     +perl/dyn          +title
+channel           +ipv6              +persistent_undo   -toolbar
+cindent           +job               +popupwin          +user_commands
-clientserver      +jumplist          +postscript        +vartabs
-clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +vim9script
+cmdline_hist      +langmap           -python            +viminfo
+cmdline_info      +libcall           +python3/dyn       +virtualedit
+comments          +linebreak         +quickfix          +visual
+conceal           +lispindent        +reltime           +visualextra
+cryptv            +listcmds          +rightleft         +vreplace
+cscope            +localmap          +ruby/dyn          +wildignore
+cursorbind        +lua/dyn           +scrollbind        +wildmenu
+cursorshape       +menu              +signs             +windows
+dialog_con        +mksession         +smartindent       +writebackup
+diff              +modify_fname      +sodium            -X11
+digraphs          +mouse             -sound             +xattr
-dnd               -mouseshape        +spell             -xfontset
-ebcdic            +mouse_dec         +startuptime       -xim
+emacs_tags        +mouse_gpm         +statusline        -xpm
+eval              -mouse_jsbterm     -sun_workshop      -xsmp
+ex_extra          +mouse_netterm     +syntax            -xterm_clipboard
+extra_search      +mouse_sgr         +tag_binary        -xterm_save
-farsi             -mouse_sysmouse    -tag_old_static    
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DSYS_VIMRC_FILE=/etc/vimrc -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 
Linking: gcc -Wl,--enable-new-dtags -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes -L/usr/local/lib -o vim -lm -lselinux -lncurses -lsodium -lacl -lattr -lgpm 

typo in ag.vim

in ag.vim, first line, vimscrip -> vimscript.

Thx for the great plugin btw. instant i gave โญ.
instead of 2 separate plugin(fzf & fzf.vim) just one simple and lean plugin. thank you

General use of fuzzy finder

Is there any way to use the fuzzy finder to filter arbitrary data? (e.g. by piping in commit history from Git)

Got the idea from fzf.vim, which uses fzf to filter through commit history, in addition to jumps, marks, :- and /-history, and others.

Splitting terminal buffer using :FuzzyBuffers opens incorrect buffer

When using :FuzzyBuffers to select a terminal buffer opened by :term works fine, but it fails to open the proper buffer when using split or tab keymaps <C-s>, <C-v> or <C-t>.

To reproduce:

# Open vim
:terminal
<C-w>c  # closes terminal window
:FuzzyBuffers
# Select terminal buffer
<C-s>

It works fine if I use <CR> instead of <C-s> or <C-v>

Once again, thanks for the plugin and quick response to issues!

Disable preview window

Is there a way to disable the preview window?
I haven't found anything in the documentation or the options.

I used to disable preview window in FZF using:

g:fzf_preview_window = []

Usually preview window is a useful feature, but sometimes there are some ftplugins that cause issues like chrisbra/csv.vim.
My preference is to disable it too, as I don't like unnecessary IO of reading a file when I've not decided to open it.

Thanks a lot for the plugin!

Install with packer

Is it possible? I'm using:

  use { 'Donaldttt/fuzzyy'}

And Packer shows it's installing it with no warnings or errors. But none of the Fuzzy* commands actually work:

Not an editor command: FuzzyFiles

Am I missing something? I'm using Neovim, if that matters.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.