Git Product home page Git Product logo

vim-fz's Introduction

vim-fz

Ultra Fast Fuzzy finder for Vim8 and NeoVim.

But very very experimental!

Fz

Usage

:Fz

Or type ,f

APIs

type: cmd

nnoremap <C-p> :execute system('git rev-parse --is-inside-work-tree') =~ 'true'
      \ ? fz#run({ 'type': 'cmd', 'cmd': 'git ls-files' })
      \ : 'Fz'<CR>

type: list

command! FzColors call fz#run({
    \ 'type': 'list',
    \ 'list': uniq(map(split(globpath(&rtp, "colors/*.vim"), "\n"), "substitute(fnamemodify(v:val, ':t'), '\\..\\{-}$', '', '')")),
    \ 'accept': {result->execute('colorscheme ' . result['items'][0])},
    \ })

Requirements

  • gof
  • vim8 or neovim

Installation

$ go get github.com/mattn/gof
  • Pathogen
    • git clone https://github.com/mattn/vim-fz.git ~/.vim/bundle/vim-fz
  • vim-plug
    • Plug 'mattn/vim-fz'
  • Vim packages
    • git clone https://github.com/mattn/vim-fz.git ~/.vim/pack/plugins/start/vim-fz

License

MIT

Author

Yasuhiro Matsumoto (a.k.a. mattn)

vim-fz's People

Contributors

heavenshell avatar mattn avatar prabirshrestha 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  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-fz's Issues

Add open command variable

I want to use :split command if current buffer is readonly (like terminal window).
Otherwise, use :edit.

Solution

  • [vim-fz] Add variable to open vim-fz buffer
  • [my config] Define Open command for vim-fz to behave like above specify :drop command to the variable

fz#run not working as expected.

Starting from 0d7a1ad the following command seem to not be working.

if executable('gof') && executable('files')
    nmap ,f <Plug>(fz)
    let g:ctrlp_map = ''
    nnoremap <c-p> :call fz#run({ 'type': 'cmd', 'cmd': 'git ls-files'] })<CR>
endif

VimLang suggestion

Hi there. Great plugin.

Suggestion when using the function type(). Use the v:t_<type> built-in variables. Like this:

if type("hello") == v:t_string
  echo "it's a string"
endif

Take a look at :help type().

Add vim help

and should write detailed descriptions about variables.

allow vim-fz to be extended

Would it be possible to support an api so that we can use vim-fz for other things rather than just files something similar to fzf https://github.com/junegunn/fzf/wiki/Examples-(vim). I would like to replace Ctrl+P and fzf features with it.

Here is what I'm thinking.

  • Make vim-fz only expose the core api and allow other plugin author to use it for something else.
  • Create another repo that is specific to vim. Might be name something like basic-vim-fz? This would then support commands like :FzColors, :FzFiletypes, :FzLines, :FzTags, :FzQuickFix, :FzBookmarks and so on. You could also move :FzFiles and :FzDirs in this repo.
  • Create another repo that is specific to source controls. For example, git-vim-fz which contains :FzGitFiles, :FzGitBranch, :FzGitStashedFiles. If someone uses mercurial, svn the can go ahead and create hg-vim-fzf or svn-vim-fzf.

Here is what the core api could look like. This is a very simplified version of the api.

fz#run({
    \ 'type': 'cmd',
    \ 'cmd': ['git', 'ls-files'],
    \ 'accept': {files-> exec 'edit files[0]'},
\ })

fz#run({
    \ 'type': 'list',
    \ 'list': ['Item1', 'Item2'],
    \ 'accept': {items -> .. do something with items ...},
\ })

fz#run({
    \ 'type': 'file',
    \ 'file': expand('~/somefile'),
    \ 'accept': {result-> ... do something with the result },
})

It would be also good to have first class async support. This is a place where most of the plugins doesn't support it.

" if type is not specified it could default to manual, then user can use fz#append(id, list) and fz#clear(id)
let l:id= fz#run({
    \ 'accept': {result-> ... do something with the result },
\ })

let s:counter = 0
function! s:some_async_function(t) abort
    let s:counter = s:counter + 1
    call fz#append(l:id, [s:counter])
    if s:counter == 100
        call fz#clean(l:id)
        let s:counter = 0
    endif
endfunction

call timer_start(2000, function('s:some_async_function'), { 'repeat': -1 })

If I wanted to create a command I can easily use command! FzGitFiles call fz#run(....)

This is useful when I'm searching for vim-lsp case where I could be opening multiple language servers and would like to append to the same list. Also useful when streaming support for language server protocol is implemented.

There is also another async feature that would make sense but this might be difficult until gof or fzf supports it first. Basically as I type the search text I would also like to be notified about the search text. There are cases where the results is too large. For example when implementing a UI for npm install I would like to search the npmjs.org repository. This means I would most likely want to make a new http request every time the user presses a key.

let l:id= fz#run({
    \ 'type': 'manual',
    \ 'accept': {result-> ... do something with the result },
    \ 'search_changed': function('s:on_search_text_changed'),
\ })

function! s:on_search_text_changed(id, search_text) abort
    let l:result = http#get('http://npmjs.org/search?q=' . a:search_text)
    call fz#clear(a:id)
    call fz#append(a:id, l:result)
endfunction

There are cases when list can be just string. For example: for files, filetypes, colorschemes. But there are cases when list needs to be a bit more complicated might be something like how omnifunc works ie. list of completeitem, it would be good to support ['item1', 'item2'] as well as [ { 'text': 'class HelloWorld', 'data': { 'file': 'hello.js', 'line': 1, 'col: 1 } } ]. This way when I implement get current document symbols, I can show HelloWorld in results, but when I click enter in the accept method I can look at the data and edit the file and navigate to that particular line and col.

accept function might want to return a dictionary instead of just the selected items so that it can be future proof. For example, the user might type Ctrl+t, Ctrl+v and Ctrl+s instead of enter. This would allow the plugin author to know that the user pressed Ctrl+v so it will open the file in vertical split but if the user pressed Ctrl+t it can open in new tab.

function! s:on_accept(option) abort
     a:option.id " id of the fz#run
     a:options.items " list of items, since sometimes it is ok to select multiple items
     a:options.selection_type " Ctrl+t, Ctrl+v and so on
endfunction

Also would be good if the same api could be ported to CtrlP so supporting both UI would be easy.

Thoughts?

fztags support

I hope I'm not asking for something that is out of scope for this project but I'm finding it difficult to find a fast fuzzy finder based on the content of all files in a big project.
I'm basically looking for fuzzy navigator for cscope or ctags.
Or can we maybe create a vim function with gof for g:ctrlp_match_func in ctrlp?

tnoremap

I want to map Esc to normal mode for all terminal (tnoremap <Esc> <C-\><C-n>) except for vim-fz where I want to exit the terminal. Any idea how to achieve this?

doesn't work in vim on mac

Running directly on command line seems to work but not inside vim. Running inside neovim on mac seems to work. Haven't tried on linux yet. I'm guessing vim parses command line differently when running in terminal?

screen shot 2017-08-21 at 11 20 19 pm

Should we be using arrays instead of string for cmds? let job = job_start(["/bin/sh", "-c", "echo hello"]). This is what I do in async.vim to have maximum compatibility between vim and neovim as well as mac, linux and windows.

Note: I temporarily commented out closing the terminal so can see the actual output and added echom for cmd

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.