Add login, execute anon, and vim-airline support

This commit is contained in:
ViViDboarder 2014-09-10 16:22:06 -07:00
parent 8cb24f8cb7
commit 63b5992249
2 changed files with 65 additions and 10 deletions

View File

@ -1,19 +1,34 @@
force-vim force-vim
=================== =========
Plugin for "compiling" Salesforce.com code with [force cli](http://github.com/heroku/force) Plugin for "compiling" Salesforce.com code with [force cli](http://github.com/heroku/force)
Integrates with [vim-dispatch](https://github.com/tpope/vim-dispatch) and [vim-airline](https://github.com/bling/vim-airline)
Installation Installation
------------ ------------
* Install the [force cli](http://github.com/heroku/force) * Install the [force cli](http://github.com/heroku/force)
* Use Vundle or something similar * Use Vundle or something similar to install this plugin
Configuration
-------------
* `let g:force_dispatch_background = 0`: Set to 1 to use vim-dispatch to background any commands
* `let g:force_disable_airline = 0`: Set to 1 to disable integration with vim-airline
Usage Usage
----- -----
* `ForceDeploy`: executes `force push` to deploy file to server * `ForceDeploy`: executes `force push` to deploy file to server
* `ForceDeployTest`: executes `force test` to run tests in current class * `ForceTest`: executes `force test` to run tests in current class
* `ForceTarget`: Displays currently active target * `ForceActive`: Displays currently active target
* `ForceTarget ?`: List all orgs * `ForceActive ?`: List all orgs
* `ForceTarget orgName`: Activate specified org * `ForceActive orgName`: Activate specified org
* `ForceLogin`: Re-login to current org
* `ForceLogin url`: Login to provided url
Experimental:
* `ForceNewExecAnon`: Start new scratch window for executing anonymous code
* `ForceExecScratchAnon`: Execute contents of buffer
Based on plugin [vim-abuse-the-force](http://github.com/ViViDboarder/vim-abuse-the-force) Based on plugin [vim-abuse-the-force](http://github.com/ViViDboarder/vim-abuse-the-force)

View File

@ -1,8 +1,15 @@
" Config Variables {
if !exists("g:force_dispatch_background") if !exists("g:force_dispatch_background")
let g:force_dispatch_background = 0 let g:force_dispatch_background = 0
end end
if !exists("g:force_disable_airline")
let g:force_disable_airline = 0
end
" Config Variables }
" Main Functions {
function! ForceDeploy() function! ForceDeploy()
let filePath = expand("%") let filePath = expand("%")
@ -11,7 +18,7 @@ function! ForceDeploy()
endfunction endfunction
function! ForceDeployTest() function! ForceTest()
let fileName = expand("%:t:r") let fileName = expand("%:t:r")
let command = "force test \"" . fileName ."\"" let command = "force test \"" . fileName ."\""
@ -27,9 +34,8 @@ endfunction
" "
" endfunction " endfunction
function! ForceTarget(...) function! ForceActive(...)
if a:0 > 0 if a:0 > 0
if a:1 == "?" if a:1 == "?"
let command = "force logins" let command = "force logins"
else else
@ -47,6 +53,11 @@ function! ForceTarget(...)
endfunction endfunction
function! ForceLogin(...)
let command = "force login " . join(a:000, " ")
call ForceTryStart(command)
endfunction
" Try to run the command using vim-dispatch " Try to run the command using vim-dispatch
" (https://github.com/tpope/vim-dispatch) " (https://github.com/tpope/vim-dispatch)
function! ForceTryStart(...) function! ForceTryStart(...)
@ -76,11 +87,16 @@ endfunction
command! -nargs=0 ForceDeploy call ForceDeploy() " Deploy current file command! -nargs=0 ForceDeploy call ForceDeploy() " Deploy current file
command! -nargs=0 ForceDeployTest call ForceDeployTest() " Deploy current file and run test command! -nargs=0 ForceDeployTest call ForceDeployTest() " Deploy current file and run test
"command! -nargs=0 ForceRetrieve call ForceRetrieve() " Retrieve current file "command! -nargs=0 ForceRetrieve call ForceRetrieve() " Retrieve current file
command! -nargs=? ForceLogin call ForceLogin(<f-args>) " Retrieve current file
command! -nargs=? ForceTarget call ForceTarget(<f-args>) " Change deploy target command! -nargs=? ForceTarget call ForceTarget(<f-args>) " Change deploy target
" Main Functions }
" Set SF Compiler " Set SF Compiler
autocmd BufNewFile,BufRead *.cls,*.trigger,*.page,*.component compiler ForceCli autocmd BufNewFile,BufRead *.cls,*.trigger,*.page,*.component compiler ForceCli
" Execute Anonymous {
" Run current buffer " Run current buffer
" function! ForceRunCurrentBuffer() " function! ForceRunCurrentBuffer()
" let a=join(getline(1, '$'), "\\\n") " let a=join(getline(1, '$'), "\\\n")
@ -121,3 +137,27 @@ endfunction
command! -nargs=0 ForceNewExecAnon call ForceNewExecAnon() command! -nargs=0 ForceNewExecAnon call ForceNewExecAnon()
command! -nargs=0 ForceExecScratchAnon call ForceExecScratchAnon() command! -nargs=0 ForceExecScratchAnon call ForceExecScratchAnon()
" Execute Anonymous }
" Plugin Functions {
function! ForceCli#TargetName()
" Returns the name of the current force.com target
return system('force-target 2> /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 }