Skip to content

Commit

Permalink
Remove g:OmniSharp_server_stdio_quickload
Browse files Browse the repository at this point in the history
  • Loading branch information
nickspoons committed Jul 4, 2020
1 parent 787213f commit a2b4f95
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 57 deletions.
90 changes: 38 additions & 52 deletions autoload/OmniSharp/project.vim
Original file line number Diff line number Diff line change
Expand Up @@ -26,63 +26,49 @@ endfunction

" Listen for stdio server-loaded events
function! OmniSharp#project#ParseEvent(job, event, eventBody) abort
if g:OmniSharp_server_stdio_quickload
" Full load: Wait for all projects to load before marking server as ready
let projects_loaded = get(a:job, 'projects_loaded', 0)
let projects_total = get(a:job, 'projects_total', 0)
if a:job.loaded && projects_loaded == projects_total | return | endif

" Quick load: Mark server as ready as soon as configuration is finished.
" WARNING: This will _not_ result in fully functional server interaction.
if a:job.loaded | return | endif
let message = get(a:eventBody, 'Message', '')
if message ==# 'Configuration finished.'
call OmniSharp#project#RegisterLoaded(a:job)
endif

else

" Full load: Wait for all projects to load before marking server as ready
let projects_loaded = get(a:job, 'projects_loaded', 0)
let projects_total = get(a:job, 'projects_total', 0)
if a:job.loaded && projects_loaded == projects_total | return | endif

if !has_key(a:job, 'loading_timeout')
" Create a timeout to mark a job as loaded after 30 seconds despite not
" receiving the expected server events.
let a:job.loading_timeout = timer_start(
\ g:OmniSharp_server_loading_timeout * 1000,
\ function('s:ServerLoadTimeout', [a:job]))
endif
if !has_key(a:job, 'loading')
let a:job.loading = []
if !has_key(a:job, 'loading_timeout')
" Create a timeout to mark a job as loaded after 30 seconds despite not
" receiving the expected server events.
let a:job.loading_timeout = timer_start(
\ g:OmniSharp_server_loading_timeout * 1000,
\ function('s:ServerLoadTimeout', [a:job]))
endif
if !has_key(a:job, 'loading')
let a:job.loading = []
endif
let name = get(a:eventBody, 'Name', '')
let message = get(a:eventBody, 'Message', '')
if a:event ==# 'started'
call OmniSharp#actions#workspace#Get(a:job)
elseif name ==# 'OmniSharp.MSBuild.ProjectManager'
let project = matchstr(message, '''\zs.*\ze''')
if message =~# '^Queue project'
call add(a:job.loading, project)
if len(a:job.loading) > projects_total
let a:job.projects_total = len(a:job.loading)
silent doautocmd <nomodeline> User OmniSharpProjectUpdated
endif
endif
let name = get(a:eventBody, 'Name', '')
let message = get(a:eventBody, 'Message', '')
if a:event ==# 'started'
call OmniSharp#actions#workspace#Get(a:job)
elseif name ==# 'OmniSharp.MSBuild.ProjectManager'
let project = matchstr(message, '''\zs.*\ze''')
if message =~# '^Queue project'
call add(a:job.loading, project)
if len(a:job.loading) > projects_total
let a:job.projects_total = len(a:job.loading)
silent doautocmd <nomodeline> User OmniSharpProjectUpdated
endif
if message =~# '^Successfully loaded project'
\ || message =~# '^Failed to load project'
if message[0] ==# 'F'
echom 'Failed to load project: ' . project
endif
if message =~# '^Successfully loaded project'
\ || message =~# '^Failed to load project'
if message[0] ==# 'F'
echom 'Failed to load project: ' . project
endif
call filter(a:job.loading, {idx,val -> val !=# project})
let a:job.projects_loaded = projects_loaded + 1
silent doautocmd <nomodeline> User OmniSharpProjectUpdated
if len(a:job.loading) == 0
call OmniSharp#project#RegisterLoaded(a:job)
unlet a:job.loading
call timer_stop(a:job.loading_timeout)
unlet a:job.loading_timeout
endif
call filter(a:job.loading, {idx,val -> val !=# project})
let a:job.projects_loaded = projects_loaded + 1
silent doautocmd <nomodeline> User OmniSharpProjectUpdated
if len(a:job.loading) == 0
call OmniSharp#project#RegisterLoaded(a:job)
unlet a:job.loading
call timer_stop(a:job.loading_timeout)
unlet a:job.loading_timeout
endif
endif

endif
endfunction

Expand Down
6 changes: 1 addition & 5 deletions plugin/OmniSharp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ let g:OmniSharp_lookup_metadata = get(g:, 'OmniSharp_lookup_metadata', 1)

let g:OmniSharp_server_stdio = get(g:, 'OmniSharp_server_stdio', 1)

" When g:OmniSharp_server_stdio_quickload = 1, consider server 'loaded' once
" 'Configuration finished' is received. When this is 0, wait for notification
" that all projects have been loaded.
let g:OmniSharp_server_stdio_quickload = get(g:, 'OmniSharp_server_stdio_quickload', 0)
let g:OmniSharp_server_display_loading = get(g:, 'OmniSharp_server_display_loading', 1)
let g:OmniSharp_server_loading_timeout = get(g:, 'OmniSharp_server_loading_timeout', 20)
let g:OmniSharp_server_loading_timeout = get(g:, 'OmniSharp_server_loading_timeout', 30)

" Use mono to start the roslyn server on *nix
let g:OmniSharp_server_use_mono = get(g:, 'OmniSharp_server_use_mono', 0)
Expand Down

0 comments on commit a2b4f95

Please sign in to comment.