set nocompatible

let ctags_exec = substitute($HOME, '[\\/]$','','')."/ctags58_win32/ctags.exe"
let ctags_command=ctags_exec.' -R --extra=+f --fields=+SK-k --totals -B .'
let ctags_command=ctags_command.' & '.ctags_exec.' -R --extra=+f --fields=+SK-k --totals --c-kinds=p -a .'

command! Ctags
      \ silent exec '!start /b cmd /c '.ctags_command.' & vim --servername '.
      \ v:servername." --remote-expr \"CtagsProcessingComplete('".getcwd()."')\""

function! CtagsProcessingComplete(processedPath)
  " convert to Unix line endings so I can share between systems
  let lines=readfile(fnameescape(a:processedPath).'/tags')
  call map(lines, 'substitute(v:val, ''^!\@!\S\+\t\zs\%(\f\| \)\+\ze\t'', ''\=substitute(submatch(0), "\\", "/", "g")'', "")')
  sleep 1
  call writefile(lines, fnameescape(a:processedPath).'/tags')

  let tempPath=escape(fnameescape(a:processedPath), '\ ')
  exec "set tags-=".tempPath."/tags"
  exec "set tags+=".tempPath."/tags"
  echomsg "Processed CTags for" a:processedPath
endfun

" prompt for which tag if multiple matches found
set cscopetag
