" Config Variables { if !exists("g:force_dispatch_background") let g:force_dispatch_background = 0 end if !exists('g:loaded_airline') let g:force_disable_airline = 1 endif if !exists("g:force_disable_airline") let g:force_disable_airline = 0 endif if !exists("g:force_status_line_func_added") let g:force_status_line_func_added = 0 endif " Config Variables } " Main Functions { function! ForceDeploy() let filePath = expand("%") let command = "force push -f \"" . 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(':Neomake') let command = "NeomakeSh " . command elseif 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 ForceTest call ForceTest() " 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 && g:force_status_line_func_added != 1 call airline#add_statusline_func('ForceCli#AirlineFunction') let g:force_status_line_func_added = 1 endif " Neomake support let g:neomake_apex_force_push_maker = { \ 'exe': 'force', \ 'args': ['push', '-f'], \ 'errorformat': &errorformat, \ } let g:neomake_apex_force_test_maker = { \ 'exe': 'echo', \ 'args': ['test', '%:t:r', '||'], \ 'errorformat': &errorformat, \ } let g:neomake_visualforce_force_push_maker = g:neomake_apex_force_push_maker let g:neomake_apex_enabled_makers = ['force_push'] let g:neomake_visualforce_enabled_makers = ['force_push'] " Plugin Functions }