commit 1cff871dca0a9c9afb492973ae9467dc5fa129a1 Author: ViViDboarder Date: Thu Apr 18 12:00:14 2013 -0700 Initial Commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..bba0daf --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +Vim Abuse the Force +=================== +Plugin for "compiling" Salesforce.com code with [Abuse the Force](http://github.com/ViViDboarder/abuse-the-force) + +Installation +------------ +Soon diff --git a/compiler/AbuseTheForce.vim b/compiler/AbuseTheForce.vim new file mode 100644 index 0000000..6cb9b61 --- /dev/null +++ b/compiler/AbuseTheForce.vim @@ -0,0 +1,21 @@ +" Vim compiler file +" Compiler:Salesforce Deploy +" Maintainer: Ian (ViViDboarder@gmail.com) +" Last Change: 2013 Apr 18 + +if exists("current_compiler") + finish +endif +let current_compiler = "AbuseTheForce" + +if exists(":CompilerSet") != 2 " older Vim always used :setlocal + command -nargs=* CompilerSet setlocal +endif + +"CompilerSet errorformat& +"CompilerSet errorformat+=%f(%l\\,%v):%m, +" \%trror%*[^:]:\ %m, +" \%tarning%*[^:]:\ %m + +"set efm=%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%# +CompilerSet makeprg="abusetheforce deploy file " . %:p diff --git a/plugin/AbuseTheForce.vim b/plugin/AbuseTheForce.vim new file mode 100644 index 0000000..c0c3894 --- /dev/null +++ b/plugin/AbuseTheForce.vim @@ -0,0 +1,40 @@ + +function! AbuseTheForceDeploy() + let filePath = expand("%") + + "let command = "!echo \"" . filePath . "\"" + let command = "!abusetheforce deploy file \"" . filePath . "\"" + execute command + +endfunction + +function! AbuseTheForceRetrieve() + let filePath = expand("%") + + "let command = "!echo \"" . filePath . "\"" + let command = "!abusetheforce deploy file \"" . filePath . "\"" + execute command + +endfunction + +function! AbuseTheForceTarget(...) + + if a:0 > 0 + let target = a:1 + + let command = "!abusetheforce target activate \"" . target . "\"" + execute command + else + let command = "!abusetheforce target" + execute command + end + +endfunction + +command -nargs=0 ForceDeploy call AbuseTheForceDeploy() " Deploy current file +command -nargs=0 ForceRetrieve call AbuseTheForceRetrieve() " Retrieve current file +command -nargs=? ForceTarget call AbuseTheForceTarget() " Change deploy target + +" Set SF Compiler +autocmd BufNewFile,BufRead *.cls,*.trigger,*.page,*.component compiler AbuseTheForce + diff --git a/plugin/FormatApex.vim b/plugin/FormatApex.vim new file mode 100644 index 0000000..c8427d2 --- /dev/null +++ b/plugin/FormatApex.vim @@ -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() \ No newline at end of file diff --git a/plugin/SfdcEol.vim b/plugin/SfdcEol.vim new file mode 100644 index 0000000..aa9c248 --- /dev/null +++ b/plugin/SfdcEol.vim @@ -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 TempSetBinaryForNoeol() + au BufWritePost * call 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\\" + 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 \ No newline at end of file