mirror of
https://github.com/ViViDboarder/vim-abuse-the-force.git
synced 2024-11-21 22:26:37 +00:00
Initial Commit
This commit is contained in:
commit
1cff871dca
7
README.md
Normal file
7
README.md
Normal file
@ -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
|
21
compiler/AbuseTheForce.vim
Normal file
21
compiler/AbuseTheForce.vim
Normal file
@ -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 <args>
|
||||
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
|
40
plugin/AbuseTheForce.vim
Normal file
40
plugin/AbuseTheForce.vim
Normal file
@ -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(<f-args>) " Change deploy target
|
||||
|
||||
" Set SF Compiler
|
||||
autocmd BufNewFile,BufRead *.cls,*.trigger,*.page,*.component compiler AbuseTheForce
|
||||
|
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