<commit_before>function! s:on_stdout(job_id, data, event) dict
    let self.output[-1] .= a:data[0]
    call extend(self.output, a:data[1:])
endfunction

function! s:on_exit(job_id, data, event) dict
    " drop the last (empty) item
    let candidates = self.output[1 : -2]
    call self.callback(candidates)
endfunction

function! tmuxcomplete#async#gather_candidates(callback)
    let command = tmuxcomplete#getcommandlist('', 10, 'words')
    let context = {
                \ 'output':   [''],
                \ 'callback': a:callback,
                \ }
    let job_id = jobstart(command, {
                \ 'on_stdout': function('s:on_stdout', context),
                \ 'on_exit':   function('s:on_exit', context),
                \ })
endfunction<commit_msg>Add async coc.nvim support for Vim<commit_after>function! s:on_stdout_nvim(job_id, data, event) dict
    let self.output[-1] .= a:data[0]
    call extend(self.output, a:data[1:])
endfunction

function! s:on_exit_nvim(job_id, data, event) dict
    " drop the last (empty) item
    let candidates = self.output[: -2]
    call self.callback(candidates)
endfunction

function! s:on_output_vim(channel, message) dict
    call add(self.output, a:message)
endfunction

function! s:on_exit_vim(job, status) dict
    " drop the first (empty) item
    let candidates = self.output[1 :]
    call self.callback(candidates)
endfunction

function! tmuxcomplete#async#gather_candidates(callback)
    let command = tmuxcomplete#getcommandlist('', 10, 'words')
    let context = {
                \ 'output':   [''],
                \ 'callback': a:callback,
                \ }

    if has('nvim')
        call jobstart(command, {
                    \ 'on_stdout': function('s:on_stdout_nvim', context),
                    \ 'on_exit':   function('s:on_exit_nvim', context),
                    \ })
    else
        call job_start(command, {
                    \ 'out_cb':  function('s:on_output_vim', context),
                    \ 'exit_cb': function('s:on_exit_vim', context),
                    \ })
    endif
endfunction
{'fraction_non_alphanumeric': 0.13051823416506717, 'fraction_numerical': 0.0067178502879078695, 'mean_word_length': 2.4808013355592653, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5501802', 'n_tokens_mistral': 678, 'n_tokens_neox': 645, 'n_words': 140}