Created
August 8, 2015 20:50
-
-
Save drewdeponte/a900322903197b8f4fe4 to your computer and use it in GitHub Desktop.
An attempt at implementing support for selecta in neovim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! SelectaCommand(choice_command, selecta_args, vim_command) | |
let dict = { 'vim_command': a:vim_command, 'temps': { 'result': tempname() }, 'name': 'SelectaCommand' } | |
function! dict.on_exit(id, code) | |
bd! " close terminal buffer | |
if a:code == 0 " success | |
if filereadable(self.temps.result) | |
let l:selection = readfile(self.temps.result)[0] | |
echom "selecta: selected: ".selection | |
exec self.vim_command." ".l:selection | |
else | |
echom "selecta: error: can't read selection from (".self.temps.result.")" | |
endif | |
else | |
echom "selecta: error: command exited (".string(a:code).")" | |
endif | |
endfunction | |
call termopen(a:choice_command." | ~/.nvim/bin/selecta ".a:selecta_args." > ".dict.temps.result, dict) | |
startinsert | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment