<commit_before>let s:save_cpo = &cpoptions
set cpoptions&vim

let g:omnisharp_proc_debug = get(g:, 'omnisharp_proc_debug', 0)

function! s:debug(message) abort
  if g:omnisharp_proc_debug == 1
    echom 'DEBUG: ' . string(a:message)
  endif
endfunction

function! OmniSharp#proc#supportsNeovimJobs() abort
  return exists('*jobstart')
endfunction

function! OmniSharp#proc#neovimOutHandler(job_id, data, event) abort
  if g:omnisharp_proc_debug == 1
    let l:message = printf('%s: %s',a:event,string(a:data))
    echom l:message
  endif
endfunction

function! OmniSharp#proc#neovimErrHandler(job_id, data, event) abort
  let l:message = printf('%s: %s',a:event,string(a:data))
  echoerr l:message
endfunction

function! OmniSharp#proc#neovimJobStart(command) abort
  if OmniSharp#proc#supportsNeovimJobs()
    call s:debug('Using Neovim jobstart to start the following command:')
    call s:debug(a:command)
    return jobstart(
                \ a:command,
                \ {'on_stdout': 'OmniSharp#proc#neovimOutHandler',
                \  'on_stderr': 'OmniSharp#proc#neovimErrHandler'})
  else
    echoerr 'Not using neovim'
  endif
endfunction

function! OmniSharp#proc#supportsVimJobs() abort
  return exists('*job_start')
endfunction

function! OmniSharp#proc#vimOutHandler(channel, message) abort
  if g:omnisharp_proc_debug == 1
      echom printf('%s: %s', string(a:channel), string(a:message))
  endif
endfunction

function! OmniSharp#proc#vimErrHandler(channel, message) abort
  echoerr printf('%s: %s', string(a:channel), string(a:message))
endfunction

let s:job = v:null

function! OmniSharp#proc#vimJobStart(command) abort
  if OmniSharp#proc#supportsVimJobs()
    call s:debug('Using vim job_start to start the following command:')
    call s:debug(a:command)
    if type(s:job) !=# v:t_job || job_status(s:job) ==# 'dead'
      let s:job = job_start(
                  \ a:command,
                  \ {'out_cb': 'OmniSharp#proc#vimOutHandler',
                  \  'err_cb': 'OmniSharp#proc#vimErrHandler'})
    else
      call s:debug('Skip to start server since job still exists')
    endif
  else
    echoerr 'Not using Vim 8.0+'
  endif
endfunction

function! OmniSharp#proc#supportsVimDispatch() abort
  return exists(':Dispatch') == 2
endfunction

function! OmniSharp#proc#dispatchStart(command) abort
  if OmniSharp#proc#supportsVimDispatch()
    return dispatch#spawn(
          \ call('dispatch#shellescape', a:command),<commit_msg>Use exists() instead<commit_after>let s:save_cpo = &cpoptions
set cpoptions&vim

let g:omnisharp_proc_debug = get(g:, 'omnisharp_proc_debug', 0)

function! s:debug(message) abort
  if g:omnisharp_proc_debug == 1
    echom 'DEBUG: ' . string(a:message)
  endif
endfunction

function! OmniSharp#proc#supportsNeovimJobs() abort
  return exists('*jobstart')
endfunction

function! OmniSharp#proc#neovimOutHandler(job_id, data, event) abort
  if g:omnisharp_proc_debug == 1
    let l:message = printf('%s: %s',a:event,string(a:data))
    echom l:message
  endif
endfunction

function! OmniSharp#proc#neovimErrHandler(job_id, data, event) abort
  let l:message = printf('%s: %s',a:event,string(a:data))
  echoerr l:message
endfunction

function! OmniSharp#proc#neovimJobStart(command) abort
  if OmniSharp#proc#supportsNeovimJobs()
    call s:debug('Using Neovim jobstart to start the following command:')
    call s:debug(a:command)
    return jobstart(
                \ a:command,
                \ {'on_stdout': 'OmniSharp#proc#neovimOutHandler',
                \  'on_stderr': 'OmniSharp#proc#neovimErrHandler'})
  else
    echoerr 'Not using neovim'
  endif
endfunction

function! OmniSharp#proc#supportsVimJobs() abort
  return exists('*job_start')
endfunction

function! OmniSharp#proc#vimOutHandler(channel, message) abort
  if g:omnisharp_proc_debug == 1
      echom printf('%s: %s', string(a:channel), string(a:message))
  endif
endfunction

function! OmniSharp#proc#vimErrHandler(channel, message) abort
  echoerr printf('%s: %s', string(a:channel), string(a:message))
endfunction

function! OmniSharp#proc#vimJobStart(command) abort
  if OmniSharp#proc#supportsVimJobs()
    call s:debug('Using vim job_start to start the following command:')
    call s:debug(a:command)
    if !exists('s:job') || job_status(s:job) ==# 'dead'
      let s:job = job_start(
                  \ a:command,
                  \ {'out_cb': 'OmniSharp#proc#vimOutHandler',
                  \  'err_cb': 'OmniSharp#proc#vimErrHandler'})
    else
      call s:debug('Skip to start server since job still exists')
    endif
  else
    echoerr 'Not using Vim 8.0+'
  endif
endfunction

function! OmniSharp#proc#supportsVimDispatch() abort
  return exists(':Dispatch') == 2
endfunction

function! OmniSharp#proc#dispatchStart(command) abort
  if OmniSharp#proc#supportsVimDispatch()
    return dispatch#spawn(
          \ call('dispatch#shellescape', a:command),
{'fraction_non_alphanumeric': 0.11985324092947411, 'fraction_numerical': 0.0028536485935589076, 'mean_word_length': 4.464365256124721, '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': '4367901', 'n_tokens_mistral': 1768, 'n_tokens_neox': 1681, 'n_words': 361}