Skip to content

Commit

Permalink
System call should be done in the python process to avoid blocking Vim
Browse files Browse the repository at this point in the history
  • Loading branch information
thalesmello committed Jan 30, 2017
1 parent b6fe12c commit c0e1f2b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 11 additions & 1 deletion autoload/tmuxcomplete.vim
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ endfunction

let s:script = expand('<sfile>:h:h') . "/sh/tmuxcomplete"

function! tmuxcomplete#completions(base, capture_args, splitmode)
function! s:build_command(base, capture_args, splitmode)
let pattern = '^' . escape(a:base, '*^$][.\') . '.'
let list_args = get(g:, 'tmuxcomplete#list_args', '-a')
let grep_args = tmuxcomplete#grepargs(a:base)
Expand All @@ -29,6 +29,16 @@ function! tmuxcomplete#completions(base, capture_args, splitmode)
let command .= ' -e' " exclude current pane
endif

return command
endfunction

function! tmuxcomplete#getcommand(base, splitmode)
return s:build_command(a:base, s:capture_args, a:splitmode)
endfunction

function! tmuxcomplete#completions(base, capture_args, splitmode)
let command = s:build_command(a:base, a:capture_args, a:splitmode)

let completions = system(command)
if v:shell_error != 0
return []
Expand Down
6 changes: 4 additions & 2 deletions rplugin/python3/deoplete/sources/tmuxcomplete.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .base import Base

import deoplete.util
from subprocess import check_output

class Source(Base):
def __init__(self, vim):
Expand All @@ -12,5 +13,6 @@ def __init__(self, vim):
self.rank = 4

def gather_candidates(self, context):
return [{ 'word': x } for x in
self.vim.call('tmuxcomplete#gather_candidates')]
command = self.vim.call('tmuxcomplete#getcommand', '', 'words')
words = check_output(['sh', '-c', command]).decode('utf-8').splitlines()
return [{ 'word': x } for x in words]

0 comments on commit c0e1f2b

Please sign in to comment.