Skip to content

Commit

Permalink
Included projects loaded in statusline (#4)
Browse files Browse the repository at this point in the history
* Included projects loaded in statusline

* Include project load counts in statusline
  • Loading branch information
nickspoons authored Jul 7, 2020
2 parents bc05f5e + c6eb74a commit f75b711
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions autoload/sharpenup/statusline.vim
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,33 @@ function! sharpenup#statusline#GetStatus() abort
return status
endif

let host = getbufvar(bufnr('%'), 'OmniSharp_host')
let job = empty(host) ? '' : OmniSharp#proc#GetJob(host.sln_or_dir)
if type(job) != v:t_dict
let host = OmniSharp#GetHost(bufnr('%'))
if type(host.job) != v:t_dict || get(host.job, 'stopped')
let status.State = s:t_dead
let status.Text = substitute(s:statusOpts.TextDead, '%s', '-', 'g')
return status
endif

let loaded = get(job, 'loaded', 0)
let loaded = get(host.job, 'loaded', 0)
let status.State = loaded ? s:t_ready : s:t_loading
let status.Text = loaded ? s:statusOpts.TextReady : s:statusOpts.TextLoading
if stridx(status.Text, '%s') >= 0
let sod = fnamemodify(host.sln_or_dir, ':t')
let status.Text = substitute(status.Text, '%s', sod, 'g')
endif
if match(status.Text, '%p\c') >= 0
try
let projectsloaded = OmniSharp#project#CountLoaded()
let projectstotal = OmniSharp#project#CountTotal()
catch
" The CountLoaded and CountTotal functions are very new - catch the error
" when they don't exist
let projectsloaded = 0
let projectstotal = 0
endtry
let status.Text = substitute(status.Text, '%p\C', projectsloaded, 'g')
let status.Text = substitute(status.Text, '%P\C', projectstotal, 'g')
endif
return status
endfunction

Expand Down

0 comments on commit f75b711

Please sign in to comment.