Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 71 lines (67 sloc) 3.072 kb
bb62ce2 @derekwyatt Many changes in the new job
authored
1 setlocal formatoptions=crq
2 setlocal textwidth=80
3 setlocal foldmethod=marker
4 setlocal foldmarker=//{,//}
5 setlocal foldlevel=0
6 setlocal sw=4
7
8 if !exists("*s:CodeOrTestFile")
9 function! s:CodeOrTestFile(precmd)
10 let current = expand('%:p')
11 let other = current
12 if current =~ "/src/main/.*/\%(blogs|news\)/"
13 let other = substitute(current, "/main/", "/test/", "")
14 let other = substitute(other, "/blogs/", "/tests/", "")
15 let other = substitute(other, "/news/", "/tests/", "")
16 let other = substitute(other, ".java$", "Test.java", "")
17 elseif current =~ "/src/test/.*/actions/tests/"
18 let other = substitute(current, "/test/", "/main/", "")
19 let other = substitute(other, "/tests/", "/blogs/", "")
20 let other = substitute(other, "Test.java$", ".java", "")
21 elseif current =~ "/src/main/"
22 let other = substitute(current, "/main/", "/test/", "")
23 let other = substitute(other, ".java$", "Test.java", "")
24 elseif current =~ "/src/test/"
25 let other = substitute(current, "/test/", "/main/", "")
26 let other = substitute(other, "Test.java$", ".java", "")
27 endif
28 if &switchbuf =~ "^use"
29 let i = 1
30 let bufnum = winbufnr(i)
31 while bufnum != -1
32 let filename = fnamemodify(bufname(bufnum), ':p')
33 if filename == other
34 execute ":sbuffer " . filename
35 return
36 endif
37 let i += 1
38 let bufnum = winbufnr(i)
39 endwhile
40 endif
41 if other != ''
42 if strlen(a:precmd) != 0
43 execute a:precmd
44 endif
45 execute 'edit ' . fnameescape(other)
46 else
47 echoerr "Alternate has evaluated to nothing."
48 endif
49 endfunction
50 endif
51
52 com! -buffer JavaSwitchHere :call s:CodeOrTestFile('')
53 com! -buffer JavaSwitchRight :call s:CodeOrTestFile('wincmd l')
54 com! -buffer JavaSwitchSplitRight :call s:CodeOrTestFile('let b:curspr=&spr | set nospr | vsplit | wincmd l | if b:curspr | set spr | endif | unlet b:curspr')
55 com! -buffer JavaSwitchLeft :call s:CodeOrTestFile('wincmd h')
56 com! -buffer JavaSwitchSplitLeft :call s:CodeOrTestFile('let b:curspr=&spr | set nospr | vsplit | wincmd h | if b:curspr | set spr | endif | unlet b:curspr')
57 com! -buffer JavaSwitchAbove :call s:CodeOrTestFile('wincmd k')
58 com! -buffer JavaSwitchSplitAbove :call s:CodeOrTestFile('let b:cursb=&sb | set nosb | split | wincmd k | if b:cursb | set sb | endif | unlet b:cursb')
59 com! -buffer JavaSwitchBelow :call s:CodeOrTestFile('wincmd j')
60 com! -buffer JavaSwitchSplitBelow :call s:CodeOrTestFile('let b:cursb=&sb | set nosb | split | wincmd j | if b:cursb | set sb | endif | unlet b:cursb')
61
62 nmap <buffer> <silent> ,of :JavaSwitchHere<cr>
63 nmap <buffer> <silent> ,ol :JavaSwitchRight<cr>
64 nmap <buffer> <silent> ,oL :JavaSwitchSplitRight<cr>
65 nmap <buffer> <silent> ,oh :JavaSwitchLeft<cr>
66 nmap <buffer> <silent> ,oH :JavaSwitchSplitLeft<cr>
67 nmap <buffer> <silent> ,ok :JavaSwitchAbove<cr>
68 nmap <buffer> <silent> ,oK :JavaSwitchSplitAbove<cr>
69 nmap <buffer> <silent> ,oj :JavaSwitchBelow<cr>
70 nmap <buffer> <silent> ,oJ :JavaSwitchSplitBelow<cr>
Something went wrong with that request. Please try again.