Skip to content

Commit

Permalink
Merge pull request #13 from Milly/use-job-vimproc
Browse files Browse the repository at this point in the history
Use job vimproc
  • Loading branch information
soramugi committed Jun 3, 2018
2 parents 4e40328 + 6a0e882 commit 768ff21
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions autoload/auto_ctags.vim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
" Vim global plugin for Create ctags
" Last Change: 11 Jul 2016
" Last Change: 15 Mar 2018
" Maintainer: Yudai Tsuyuzaki <soramugi.chika@gmail.com>
" License: This file is placed in the public domain.

Expand Down Expand Up @@ -92,9 +92,18 @@ function! auto_ctags#ctags_cmd_opt()
endfunction

function! auto_ctags#ctags_cmd()
if !executable(g:auto_ctags_bin_path)
call s:warn('Ctags command not found.')
return ''
endif
let tags_path = auto_ctags#ctags_path()
let tags_lock_path = auto_ctags#ctags_lock_path()
if tags_path == '' || glob(tags_lock_path) != ''
if tags_path == ''
call s:warn('Tags path not exists.')
return ''
endif
if glob(tags_lock_path) != ''
call s:warn('Tags path currently locked.')
return ''
endif

Expand Down Expand Up @@ -131,13 +140,40 @@ function! auto_ctags#ctags(recreate)

if s:is_windows
let [ssl, &ssl] = [&ssl, 0]
silent! execute '!start /b cmd.exe /c' shellescape(cmd, 1)
let args = ['cmd.exe', '/c', cmd]
let cmd = 'start cmd.exe /c '.shellescape(cmd)
let &ssl = ssl
else
silent! execute '!sh -c' shellescape(cmd, 1) '&'
let args = ['sh', '-c', cmd]
let cmd = 'sh -c '.shellescape(cmd).' &'
endif

if has('job')
call job_start(args)
elseif s:has_vimproc()
call vimproc#system(args)
else
silent! execute '!' cmd
redraw!
endif
endfunction

function! s:has_vimproc()
if !exists('s:vimproc_exists')
try
let s:vimproc_exists = vimproc#dll_version() ? 1 : 0
catch
let s:vimproc_exists = 0
endtry
endif
return s:vimproc_exists
endfunction

function! s:warn(msg)
echohl WarningMsg
echo 'auto_ctags.vim:' a:msg
echohl None
endfunction

let &cpo = s:save_cpo
unlet s:save_cpo

0 comments on commit 768ff21

Please sign in to comment.