From 91050b81e5976649df11f0e31937485e9761920c Mon Sep 17 00:00:00 2001 From: Nick Jensen Date: Tue, 23 Jun 2020 11:12:01 +1200 Subject: [PATCH] Encapsulate "global" (non-buffer) stdio requests --- autoload/OmniSharp/actions/diagnostics.vim | 15 ++++++--------- autoload/OmniSharp/stdio.vim | 8 ++++++-- ftplugin/omnisharplog/OmniSharp.vim | 1 + 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/autoload/OmniSharp/actions/diagnostics.vim b/autoload/OmniSharp/actions/diagnostics.vim index 001abbb03..d70fbbca6 100644 --- a/autoload/OmniSharp/actions/diagnostics.vim +++ b/autoload/OmniSharp/actions/diagnostics.vim @@ -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 @@ -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)) diff --git a/autoload/OmniSharp/stdio.vim b/autoload/OmniSharp/stdio.vim index da1399345..0e6c0fd4e 100644 --- a/autoload/OmniSharp/stdio.vim +++ b/autoload/OmniSharp/stdio.vim @@ -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) diff --git a/ftplugin/omnisharplog/OmniSharp.vim b/ftplugin/omnisharplog/OmniSharp.vim index f2b6acc5b..285f0702d 100644 --- a/ftplugin/omnisharplog/OmniSharp.vim +++ b/ftplugin/omnisharplog/OmniSharp.vim @@ -1 +1,2 @@ set foldlevel=0 +set foldmethod=syntax