omnisharp.vim 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. " MIT License
  2. " Plugin: https://github.com/OmniSharp/omnisharp-vim
  3. " vim: et ts=2 sts=2 sw=2
  4. scriptencoding utf-8
  5. if !get(g:, 'OmniSharp_loaded', 0)
  6. finish
  7. endif
  8. function! airline#extensions#omnisharp#server_status(...) abort
  9. if !exists(':OmniSharpGotoDefinition') || !get(g:, 'OmniSharp_server_stdio', 0)
  10. return ''
  11. endif
  12. let host = OmniSharp#GetHost(bufnr('%'))
  13. if type(host.job) != v:t_dict || get(host.job, 'stopped')
  14. return ''
  15. endif
  16. let sln = fnamemodify(host.sln_or_dir, ':t')
  17. if get(host.job, 'loaded', 0)
  18. return sln
  19. endif
  20. try
  21. let projectsloaded = OmniSharp#project#CountLoaded()
  22. let projectstotal = OmniSharp#project#CountTotal()
  23. catch
  24. " The CountLoaded and CountTotal functions are very new - catch the error
  25. " when they don't exist
  26. let projectsloaded = 0
  27. let projectstotal = 0
  28. endtry
  29. return printf('%s(%d/%d)', sln, projectsloaded, projectstotal)
  30. endfunction
  31. function! airline#extensions#omnisharp#init(ext) abort
  32. call airline#parts#define_function('omnisharp', 'airline#extensions#omnisharp#server_status')
  33. augroup airline_omnisharp
  34. autocmd!
  35. autocmd User OmniSharpStarted,OmniSharpReady,OmniSharpStopped AirlineRefresh!
  36. augroup END
  37. endfunction