Skip to content

Commit

Permalink
Encapsulate "global" (non-buffer) stdio requests
Browse files Browse the repository at this point in the history
  • Loading branch information
nickspoons committed Jun 24, 2020
1 parent 4c745ae commit 91050b8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
15 changes: 6 additions & 9 deletions autoload/OmniSharp/actions/diagnostics.vim
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ function! OmniSharp#actions#diagnostics#CheckGlobal(...) abort
if bufname('%') ==# '' || OmniSharp#FugitiveCheck() | return [] | endif
" Place the results in the quickfix window, if possible
if g:OmniSharp_server_stdio
call s:StdioCheckGlobal(function('s:CBGlobalCodeCheck'))
let Callback = function('s:CBGlobalCodeCheck')
let opts = {
\ 'ResponseHandler': function('s:StdioCheckRH', [Callback])
\}
let job = OmniSharp#GetHost().job
call OmniSharp#stdio#RequestGlobal(job, '/codecheck', opts)
else
let quickfixes = OmniSharp#py#Eval('globalCodeCheck()')
if OmniSharp#py#CheckForError() | return | endif
Expand All @@ -47,14 +52,6 @@ function! OmniSharp#actions#diagnostics#StdioCheck(opts, Callback) abort
call OmniSharp#stdio#Request('/codecheck', opts)
endfunction

function! s:StdioCheckGlobal(Callback) abort
let opts = {
\ 'ResponseHandler': function('s:StdioCheckRH', [a:Callback])
\}
let job = OmniSharp#GetHost().job
call OmniSharp#stdio#RequestSend(job, {}, '/codecheck', opts)
endfunction

function! s:StdioCheckRH(Callback, response) abort
if !a:response.Success | return | endif
call a:Callback(OmniSharp#locations#Parse(a:response.Body.QuickFixes))
Expand Down
8 changes: 6 additions & 2 deletions autoload/OmniSharp/stdio.vim
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,14 @@ function! OmniSharp#stdio#Request(command, opts) abort
if send_buffer
let body.Arguments.Buffer = buffer
endif
return OmniSharp#stdio#RequestSend(job, body, a:command, a:opts, sep)
return s:Request(job, body, a:command, a:opts, sep)
endfunction

function! OmniSharp#stdio#RequestSend(job, body, command, opts, ...) abort
function! OmniSharp#stdio#RequestGlobal(job, command, opts) abort
call s:Request(a:job, {}, a:command, a:opts)
endfunction

function! s:Request(job, body, command, opts, ...) abort
let sep = a:0 ? a:1 : ''
if type(a:job) != type({}) || !has_key(a:job, 'job_id') || !a:job.loaded
if has_key(a:opts, 'ReplayOnLoad') && !has_key(s:pendingRequests, a:command)
Expand Down
1 change: 1 addition & 0 deletions ftplugin/omnisharplog/OmniSharp.vim
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
set foldlevel=0
set foldmethod=syntax

0 comments on commit 91050b8

Please sign in to comment.