" Config Variables { if !exists("g:force_dispatch_background") let g:force_dispatch_background = 0 end if !exists("g:force_disable_airline") let g:force_disable_airline = 0 end " Config Variables } " Main Functions { function! ForceDeploy() let filePath = expand("%") let command = "force push \"" . filePath . "\"" call ForceTryStart(command) endfunction function! ForceTest() let fileName = expand("%:t:r") let command = "force test \"" . fileName ."\"" call ForceTryStart(command) endfunction " function! ForceRetrieve() " let filePath = expand("%") " " let command = " call ForceTryStart(command) " " endfunction function! ForceActive(...) if a:0 > 0 if a:1 == "?" let command = "force logins" else let target = a:1 let command = "force active \"" . target . "\"" end else let command = "force active" end if exists("l:command") call ForceTryStart(command) end endfunction function! ForceLogin(...) let command = "force login " . join(a:000, " ") call ForceTryStart(command) endfunction " Try to run the command using vim-dispatch " (https://github.com/tpope/vim-dispatch) function! ForceTryStart(...) " Make sure we have a parameter if a:0 > 0 let command = a:1 if exists(":Dispatch") " Determine foreground or background if g:force_dispatch_background == 1 let fgbg = "! " else let fgbg = " " end let command = "Dispatch" . fgbg . command else let command = "!" . command end execute command end endfunction command! -nargs=0 ForceDeploy call ForceDeploy() " Deploy current file command! -nargs=0 ForceDeployTest call ForceDeployTest() " Deploy current file and run test "command! -nargs=0 ForceRetrieve call ForceRetrieve() " Retrieve current file command! -nargs=? ForceLogin call ForceLogin() " Retrieve current file command! -nargs=? ForceTarget call ForceTarget() " Change deploy target " Main Functions } " Set SF Compiler autocmd BufNewFile,BufRead *.cls,*.trigger,*.page,*.component compiler ForceCli " Execute Anonymous { " Run current buffer " function! ForceRunCurrentBuffer() " let a=join(getline(1, '$'), "\\\n") " let cmd=join(["force apex < /dev/null')[:-2] endfunction function! ForceCli#AirlineFunction(...) if &filetype == 'apex' || &filetype == 'visualforce' let force_target = ForceCli#TargetName() if force_target != '' call airline#extensions#append_to_section('b', ' ☁' . force_target) endif endif endfunction if g:force_disable_airline != 1 && g:loaded_airline == 1 call airline#add_statusline_func('ForceCli#AirlineFunction') endif " Plugin Functions }