Skip to content

Instantly share code, notes, and snippets.

@DeaR
Last active January 15, 2020 01:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DeaR/5589583 to your computer and use it in GitHub Desktop.
Save DeaR/5589583 to your computer and use it in GitHub Desktop.
if has('win32') || has('win64')
let s:save_ssl = &shellslash
set noshellslash
if exists('$VS110COMNTOOLS')
let s:vcvarsall_bat = shellescape($VS110COMNTOOLS . '..\..\VC\vcvarsall.bat')
elseif exists('$VS100COMNTOOLS')
let s:vcvarsall_bat = shellescape($VS100COMNTOOLS . '..\..\VC\vcvarsall.bat')
elseif exists('$VS90COMNTOOLS')
let s:vcvarsall_bat = shellescape($VS90COMNTOOLS . '..\..\VC\vcvarsall.bat')
elseif exists('$VS80COMNTOOLS')
let s:vcvarsall_bat = shellescape($VS80COMNTOOLS . '..\..\VC\vcvarsall.bat')
endif
let &shellslash = s:save_ssl
unlet s:save_ssl
endif
if exists('s:vcvarsall_bat')
let s:hook = {
\ 'name' : 'vcvarsall',
\ 'kind' : 'hook',
\ 'config' : {
\ 'enable' : 0,
\ 'bat' : ''}}
function! s:hook.on_module_loaded(session, context)
if type(a:session.config.exec) == type([])
let a:session.config.exec[0] = join([self.config.bat, $PROCESSOR_ARCHITECTURE, '\&']) . a:session.config.exec[0]
else
let a:session.config.exec = join([self.config.bat, $PROCESSOR_ARCHITECTURE, '\&']) . a:session.config.exec
endif
endfunction
call quickrun#module#register(s:hook, 1)
unlet s:hook
call extend(g:quickrun_config, {
\ 'c' : {
\ 'type' : 'c/vc'},
\ 'c/vc' : {
\ 'command' : 'cl',
\ 'exec' : [
\ '%c %o %s /nologo /Fo%s:p:r.obj /Fe%s:p:r.exe',
\ '%s:p:r.exe %a'],
\ 'tempfile' : '%{tempname()}.c',
\ 'hook/output_encode/encoding' : 'cp932',
\ 'hook/sweep/files' : ['%s:p:r.exe', '%s:p:r.obj'],
\ 'hook/vcvarsall/enable' : 1,
\ 'hook/vcvarsall/bat' : s:vcvarsall_bat},
\
\ 'cpp' : {
\ 'type' : 'cpp/vc'},
\ 'cpp/vc' : {
\ 'command' : 'cl',
\ 'exec' : [
\ '%c %o %s /nologo /Fo%s:p:r.obj /Fe%s:p:r.exe',
\ '%s:p:r.exe %a'],
\ 'tempfile' : '%{tempname()}.cpp',
\ 'hook/output_encode/encoding' : 'cp932',
\ 'hook/sweep/files' : ['%s:p:r.exe', '%s:p:r.obj'],
\ 'hook/vcvarsall/enable' : 1,
\ 'hook/vcvarsall/bat' : s:vcvarsall_bat},
\
\ 'cs' : {
\ 'type' : 'cs/csc'},
\ 'cs/csc' : {
\ 'command' : 'csc',
\ 'exec' : [
\ '%c /nologo /out:%s:p:r.exe %s',
\ '%s:p:r.exe %a'],
\ 'tempfile' : '%{tempname()}.cs',
\ 'hook/output_encode/encoding' : 'cp932',
\ 'hook/sweep/files' : ['%s:p:r.exe'],
\ 'hook/vcvarsall/enable' : 1,
\ 'hook/vcvarsall/bat' : s:vcvarsall_bat},
\
\ 'vbnet' : {
\ 'type' : 'vbnet/vbc'},
\ 'vbnet/vbc' : {
\ 'command' : 'vbc',
\ 'exec' : [
\ '%c /nologo /out:%s:p:r.exe %s',
\ '%s:p:r.exe %a'],
\ 'tempfile' : '%{tempname()}.vb',
\ 'hook/output_encode/encoding' : 'cp932',
\ 'hook/sweep/files' : ['%s:p:r.exe'],
\ 'hook/vcvarsall/enable' : 1,
\ 'hook/vcvarsall/bat' : s:vcvarsall_bat}})
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment