Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added nvim function to README docs (Issue #64) #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ruifm
Copy link

@ruifm ruifm commented Jun 16, 2019

From this discussion.
Tested it on both neovim 0.3.7 and vim 8.1.1-1467.

@gpanders
Copy link
Contributor

gpanders commented Oct 6, 2019

For Vim 8.1 and higher (with terminal support), this is more concise and doesn't offer two separate implementations for vim/nvim:

function! s:completed(winid, filename, action, ...) abort
    bdelete!
    call win_gotoid(a:winid)
    if filereadable(a:filename)
      let lines = readfile(a:filename)
      if !empty(lines)
        exe a:action . ' ' . lines[0]
      endif
      call delete(a:filename)
    endif
endfunction

function! FzyCommand(choice_command, vim_command)
    let file = tempname()
    let winid = win_getid()
    let cmd = split(&shell) + split(&shellcmdflag) + [a:choice_command . ' | fzy > ' . file]
    let F = function('s:completed', [winid, file, a:vim_command])
    botright 10 new
    if has('*termopen')
        call termopen(cmd, {'on_exit': F})
    else
        call term_start(cmd, {'exit_cb': F, 'curwin': 1})
    endif
    startinsert
endfunction

@keith
Copy link
Contributor

keith commented Mar 1, 2020

@jhawthorn probably worth merging this, it works great for neovim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants