mirror of
https://github.com/ViViDboarder/force-vim.git
synced 2024-11-25 00:06:36 +00:00
Initial Commit
This commit is contained in:
commit
f43554597f
19
README.md
Normal file
19
README.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
force-vim
|
||||||
|
===================
|
||||||
|
Plugin for "compiling" Salesforce.com code with [force cli](http://github.com/heroku/force)
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
* Install the [force cli](http://github.com/heroku/force)
|
||||||
|
* Use Vundle or something similar
|
||||||
|
|
||||||
|
Usage
|
||||||
|
-----
|
||||||
|
|
||||||
|
* `ForceDeploy`: executes `force push` to deploy file to server
|
||||||
|
* `ForceDeployTest`: executes `force test` to run tests in current class
|
||||||
|
* `ForceTarget`: Displays currently active target
|
||||||
|
* `ForceTarget ?`: List all orgs
|
||||||
|
* `ForceTarget orgName`: Activate specified org
|
||||||
|
|
||||||
|
Based on plugin [vim-abuse-the-force](http://github.com/ViViDboarder/vim-abuse-the-force)
|
16
compiler/ForceCli.vim
Normal file
16
compiler/ForceCli.vim
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
" Vim compiler file
|
||||||
|
" Compiler: Salesforce Deploy
|
||||||
|
" Maintainer: Ian (ViViDboarder@gmail.com)
|
||||||
|
" Last Change: 2014 Jun 13
|
||||||
|
|
||||||
|
if exists("current_compiler")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let current_compiler = "ForceCli"
|
||||||
|
|
||||||
|
if exists(":CompilerSet") != 2 " older Vim always used :setlocal
|
||||||
|
command -nargs=* CompilerSet setlocal <args>
|
||||||
|
endif
|
||||||
|
|
||||||
|
set errorformat+=%*[\"]%f%*[\"]\\,\ line\ %l:\ %m
|
||||||
|
CompilerSet makeprg=force\ push\ %
|
83
plugin/ForceCli.vim
Normal file
83
plugin/ForceCli.vim
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
|
||||||
|
if !exists("g:force_dispatch_background")
|
||||||
|
let g:force_dispatch_background = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function! ForceDeploy()
|
||||||
|
let filePath = expand("%")
|
||||||
|
|
||||||
|
let command = "force push \"" . filePath . "\""
|
||||||
|
call ForceTryStart(command)
|
||||||
|
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ForceDeployTest()
|
||||||
|
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! ForceTarget(...)
|
||||||
|
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
|
||||||
|
|
||||||
|
" 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=? ForceTarget call ForceTarget(<f-args>) " Change deploy target
|
||||||
|
|
||||||
|
" Set SF Compiler
|
||||||
|
autocmd BufNewFile,BufRead *.cls,*.trigger,*.page,*.component compiler ForceCli
|
||||||
|
|
33
plugin/FormatApex.vim
Normal file
33
plugin/FormatApex.vim
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
function! FormatApex()
|
||||||
|
" Mark current location
|
||||||
|
normal mz
|
||||||
|
|
||||||
|
" Delete extra lines
|
||||||
|
:%s/\s\+$//e
|
||||||
|
:%s/\n\{3,}/\r\r/e
|
||||||
|
|
||||||
|
" Delete blank lines before } after ; or }
|
||||||
|
:%s/;\s*\n\s*\n\s*}/;\r}/ge
|
||||||
|
:%s/}\s*\n\s*\n\s*}/}\r}/ge
|
||||||
|
|
||||||
|
" Delete blank lines before catch and else
|
||||||
|
:%s/}\s*\n\s*\n\s*catch/}\rcatch/ge
|
||||||
|
:%s/}\s*\n\s*\n\s*else/}\relse/ge
|
||||||
|
|
||||||
|
" Put space after if/for/while/catch
|
||||||
|
:%s/if(/if (/ge
|
||||||
|
:%s/for(/for (/ge
|
||||||
|
:%s/while(/while (/ge
|
||||||
|
:%s/catch(/catch (/ge
|
||||||
|
|
||||||
|
" Put space between ){
|
||||||
|
:%s/){/) {/ge
|
||||||
|
|
||||||
|
" Fix indentations
|
||||||
|
normal gg=G
|
||||||
|
|
||||||
|
" return to starting point
|
||||||
|
normal `z
|
||||||
|
endfunction
|
||||||
|
command! FormatApex call FormatApex()
|
||||||
|
command! FixApex call FormatApex()
|
56
plugin/SfdcEol.vim
Normal file
56
plugin/SfdcEol.vim
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
" Copied from: http://vim.wikia.com/wiki/Preserve_missing_end-of-line_at_end_of_text_files
|
||||||
|
|
||||||
|
" Preserve noeol (missing trailing eol) when saving file. In order
|
||||||
|
" to do this we need to temporarily 'set binary' for the duration of
|
||||||
|
" file writing, and for DOS line endings, add the CRs manually.
|
||||||
|
" For Mac line endings, also must join everything to one line since it doesn't
|
||||||
|
" use a LF character anywhere and 'binary' writes everything as if it were Unix.
|
||||||
|
|
||||||
|
" This works because 'eol' is set properly no matter what file format is used,
|
||||||
|
" even if it is only used when 'binary' is set.
|
||||||
|
|
||||||
|
augroup automatic_noeol
|
||||||
|
au!
|
||||||
|
au BufWritePre * call <SID>TempSetBinaryForNoeol()
|
||||||
|
au BufWritePost * call <SID>TempRestoreBinaryForNoeol()
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
function! s:TempSetBinaryForNoeol()
|
||||||
|
let s:save_binary = &binary
|
||||||
|
if ! &eol && ! &binary
|
||||||
|
let s:save_view = winsaveview()
|
||||||
|
setlocal binary
|
||||||
|
if &ff == "dos" || &ff == "mac"
|
||||||
|
if line('$') > 1
|
||||||
|
undojoin | exec "silent 1,$-1normal! A\<C-V>\<C-M>"
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
if &ff == "mac"
|
||||||
|
undojoin | %join!
|
||||||
|
" mac format does not use a \n anywhere, so we don't add one when writing
|
||||||
|
" in binary (which uses unix format always). However, inside the outer
|
||||||
|
" if statement, we already know that 'noeol' is set, so no special logic
|
||||||
|
" is needed.
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:TempRestoreBinaryForNoeol()
|
||||||
|
if ! &eol && ! s:save_binary
|
||||||
|
if &ff == "dos"
|
||||||
|
if line('$') > 1
|
||||||
|
" Sometimes undojoin gives errors here, even when it shouldn't.
|
||||||
|
" Suppress them for now...if you can figure out and fix them instead,
|
||||||
|
" please update http://vim.wikia.com/wiki/VimTip1369
|
||||||
|
silent! undojoin | silent 1,$-1s/\r$//e
|
||||||
|
endif
|
||||||
|
elseif &ff == "mac"
|
||||||
|
" Sometimes undojoin gives errors here, even when it shouldn't.
|
||||||
|
" Suppress them for now...if you can figure out and fix them instead,
|
||||||
|
" please update http://vim.wikia.com/wiki/VimTip1369
|
||||||
|
silent! undojoin | silent %s/\r/\r/ge
|
||||||
|
endif
|
||||||
|
setlocal nobinary
|
||||||
|
call winrestview(s:save_view)
|
||||||
|
endif
|
||||||
|
endfunction
|
Loading…
Reference in New Issue
Block a user