2013-04-18 19:00:14 +00:00
|
|
|
|
2014-01-09 00:05:52 +00:00
|
|
|
if !exists("g:abusetheforce_dispatch_background")
|
|
|
|
let g:abusetheforce_dispatch_background = 0
|
|
|
|
end
|
|
|
|
|
2013-04-18 19:00:14 +00:00
|
|
|
function! AbuseTheForceDeploy()
|
|
|
|
let filePath = expand("%")
|
|
|
|
|
2014-01-09 00:05:52 +00:00
|
|
|
let command = "abusetheforce deploy file \"" . filePath . "\""
|
|
|
|
call AbuseTheForceTryStart(command)
|
2013-04-18 19:00:14 +00:00
|
|
|
|
|
|
|
endfunction
|
|
|
|
|
2013-06-03 18:55:24 +00:00
|
|
|
function! AbuseTheForceDeployTest()
|
|
|
|
let filePath = expand("%")
|
|
|
|
|
2014-01-09 00:05:52 +00:00
|
|
|
let command = "abusetheforce deploy test \"" . filePath . "\""
|
|
|
|
call AbuseTheForceTryStart(command)
|
2013-06-03 18:55:24 +00:00
|
|
|
|
|
|
|
endfunction
|
|
|
|
|
2013-04-18 19:00:14 +00:00
|
|
|
function! AbuseTheForceRetrieve()
|
|
|
|
let filePath = expand("%")
|
|
|
|
|
2014-01-09 00:05:52 +00:00
|
|
|
let command = "abusetheforce retrieve file \"" . filePath . "\""
|
|
|
|
call AbuseTheForceTryStart(command)
|
2013-04-18 19:00:14 +00:00
|
|
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! AbuseTheForceTarget(...)
|
|
|
|
|
|
|
|
if a:0 > 0
|
|
|
|
|
2013-06-03 18:55:24 +00:00
|
|
|
if a:1 == "?"
|
2014-01-09 00:05:52 +00:00
|
|
|
let command = "abusetheforce target list"
|
2013-06-03 18:55:24 +00:00
|
|
|
else
|
|
|
|
let target = a:1
|
|
|
|
|
2014-01-09 00:05:52 +00:00
|
|
|
let command = "abusetheforce target activate \"" . target . "\""
|
2013-06-03 18:55:24 +00:00
|
|
|
end
|
2013-04-18 19:00:14 +00:00
|
|
|
else
|
2014-01-09 00:05:52 +00:00
|
|
|
let command = "abusetheforce target"
|
|
|
|
end
|
|
|
|
|
|
|
|
if exists("l:command")
|
|
|
|
call AbuseTheForceTryStart(command)
|
|
|
|
end
|
|
|
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" Try to run the command using vim-dispatch
|
|
|
|
" (https://github.com/tpope/vim-dispatch)
|
|
|
|
function! AbuseTheForceTryStart(...)
|
|
|
|
|
|
|
|
" Make sure we have a parameter
|
|
|
|
if a:0 > 0
|
|
|
|
let command = a:1
|
|
|
|
|
|
|
|
if exists(":Dispatch")
|
|
|
|
" Determine foreground or background
|
|
|
|
if g:abusetheforce_dispatch_background == 1
|
|
|
|
let fgbg = "! "
|
|
|
|
else
|
|
|
|
let fgbg = " "
|
|
|
|
end
|
|
|
|
|
|
|
|
let command = "Dispatch" . fgbg . command
|
|
|
|
else
|
|
|
|
let command = "!" . command
|
|
|
|
end
|
|
|
|
|
2013-04-18 19:00:14 +00:00
|
|
|
execute command
|
|
|
|
end
|
|
|
|
|
|
|
|
endfunction
|
|
|
|
|
2013-07-17 22:46:22 +00:00
|
|
|
command! -nargs=0 ForceDeploy call AbuseTheForceDeploy() " Deploy current file
|
|
|
|
command! -nargs=0 ForceDeployTest call AbuseTheForceDeployTest() " Deploy current file and run test
|
|
|
|
command! -nargs=0 ForceRetrieve call AbuseTheForceRetrieve() " Retrieve current file
|
|
|
|
command! -nargs=? ForceTarget call AbuseTheForceTarget(<f-args>) " Change deploy target
|
2013-04-18 19:00:14 +00:00
|
|
|
|
|
|
|
" Set SF Compiler
|
|
|
|
autocmd BufNewFile,BufRead *.cls,*.trigger,*.page,*.component compiler AbuseTheForce
|
|
|
|
|