Skip to content

Commit 0e422ea

Browse files
committed
added async build comamnd
1 parent 56371da commit 0e422ea

File tree

5 files changed

+23
-5
lines changed

5 files changed

+23
-5
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ completions as MonoDevelop/SharpDevelop. The [server](https://github.com/nosami/
3030
* Lookup type information of an type/variable/method
3131
* Can be printed to the status line or in the preview window
3232
* Simple syntax error highlighting
33-
* Integrated xbuild/msbuild
33+
* Integrated xbuild/msbuild (can run asynchronously if vim dispatch is installed)
3434
* Code formatter
3535
* Add file to project (currently will only add .cs files to a .csproj file)
3636
* Add reference. Supports project and file reference. GAC referencing todo.
@@ -127,6 +127,9 @@ set noshowmatch
127127
set completeopt=longest,menuone,preview
128128
129129
nnoremap <F5> :wa!<cr>:OmniSharpBuild<cr>
130+
" Builds can run asynchronously with vim-dispatch installed
131+
"nnoremap <F5> :wa!<cr>:OmniSharpBuildAsync<cr>
132+
130133
nnoremap <F12> :OmniSharpGotoDefinition<cr>
131134
nnoremap gd :OmniSharpGotoDefinition<cr>
132135
nnoremap fi :OmniSharpFindImplementations<cr>
@@ -144,7 +147,7 @@ command! -nargs=1 Rename :call OmniSharp#RenameTo("<args>")
144147
nnoremap <leader>rl :OmniSharpReloadSolution<cr>
145148
nnoremap <leader>cf :OmniSharpCodeFormat<cr>
146149
nnoremap <leader>tp :OmniSharpAddToProject<cr>
147-
" (Experimental - uses vim-dispatch plugin) - Start the omnisharp server for the current solution
150+
" (Experimental - uses vim-dispatch or vimproc plugin) - Start the omnisharp server for the current solution
148151
nnoremap <leader>ss :OmniSharpStartServer<cr>
149152
nnoremap <leader>sp :OmniSharpStopServer<cr>
150153
"Don't ask to save when changing buffers (i.e. when jumping to a type definition)

autoload/OmniSharp.vim

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ function! OmniSharp#Build()
140140
endif
141141
endfunction
142142

143+
function! OmniSharp#BuildAsync()
144+
python buildcommand()
145+
set errorformat=\ %#%f(%l\\\,%c):\ %m
146+
set errorformat=%f(%l\\,%c):\ error\ CS%n:\ %m
147+
let &makeprg=b:buildcommand
148+
Make
149+
endfunction
150+
143151
function! OmniSharp#ReloadSolution()
144152
python getResponse("/reloadsolution")
145153
endfunction
@@ -195,13 +203,16 @@ function! OmniSharp#StartServerSolution(solutionPath)
195203
if !has('win32')
196204
let command = 'mono ' . command
197205
endif
206+
call OmniSharp#RunAsyncCommand(command)
207+
endfunction
198208

209+
function! OmniSharp#RunAsyncCommand(command)
199210
let is_vimproc = 0
200211
silent! let is_vimproc = vimproc#version()
201212
if is_vimproc
202-
call vimproc#system_gui(substitute(command, '\\', '\/', 'g'))
213+
call vimproc#system_gui(substitute(a:command, '\\', '\/', 'g'))
203214
else
204-
call dispatch#start(command, {'background': g:OmniSharp_Dispatch_Background})
215+
call dispatch#start(a:command, {'background': g:OmniSharp_Dispatch_Background})
205216
endif
206217
endfunction
207218

ftplugin/cs_omnisharp.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ command! -buffer -bar OmniSharpFindSyntaxErrors call OmniSharp#FindSyntaxErro
3232
command! -buffer -bar OmniSharpGetCodeActions call OmniSharp#GetCodeActions()
3333
command! -buffer -bar OmniSharpTypeLookup call OmniSharp#TypeLookup()
3434
command! -buffer -bar OmniSharpBuild call OmniSharp#Build()
35+
command! -buffer -bar OmniSharpBuildAsync call OmniSharp#BuildAsync()
3536
command! -buffer -bar OmniSharpRename call OmniSharp#Rename()
3637
command! -buffer -bar OmniSharpReloadSolution call OmniSharp#ReloadSolution()
3738
command! -buffer -bar OmniSharpCodeFormat call OmniSharp#CodeFormat()

python/OmniSharp.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ def build(ret):
207207
quickfixes = response['QuickFixes']
208208
populateQuickFix(ret, quickfixes)
209209

210+
def buildcommand():
211+
vim.command("let b:buildcommand = '%s'" % getResponse('/buildcommand'))
212+
210213
def codeFormat():
211214
response = json.loads(getResponse('/codeformat'))
212215
setBuffer(response["Buffer"])

server

0 commit comments

Comments
 (0)