Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 3e15232454
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 68 lines (64 sloc) 2.889 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
setlocal formatoptions=crq
setlocal textwidth=80
setlocal foldmethod=marker
setlocal foldmarker=//{,//}
setlocal foldlevel=0
setlocal sw=2

if !exists("*s:CodeOrTestFile")
  function! s:CodeOrTestFile(precmd)
   let current = expand('%:p')
   let other = current
   if current =~ "/src/main/"
   let other = substitute(current, "/main/", "/test/", "")
   let other = substitute(other, ".scala$", "Spec.scala", "")
   elseif current =~ "/src/test/"
   let other = substitute(current, "/test/", "/main/", "")
   let other = substitute(other, "Spec.scala$", ".scala", "")
    elseif current =~ "/app/model/"
   let other = substitute(current, "/app/model/", "/test/", "")
   let other = substitute(other, ".scala$", "Spec.scala", "")
   elseif current =~ "/test/"
   let other = substitute(current, "/test/", "/app/model/", "")
   let other = substitute(other, "Spec.scala$", ".scala", "")
   endif
    if &switchbuf =~ "^use"
      let i = 1
      let bufnum = winbufnr(i)
      while bufnum != -1
        let filename = fnamemodify(bufname(bufnum), ':p')
        if filename == other
          execute ":sbuffer " . filename
          return
        endif
        let i += 1
        let bufnum = winbufnr(i)
      endwhile
    endif
    if other != ''
      if strlen(a:precmd) != 0
        execute a:precmd
      endif
      execute 'edit ' . fnameescape(other)
    else
      echoerr "Alternate has evaluated to nothing."
    endif
  endfunction
endif

com! -buffer ScalaSwitchHere :call s:CodeOrTestFile('')
com! -buffer ScalaSwitchRight :call s:CodeOrTestFile('wincmd l')
com! -buffer ScalaSwitchSplitRight :call s:CodeOrTestFile('let b:curspr=&spr | set nospr | vsplit | wincmd l | if b:curspr | set spr | endif | unlet b:curspr')
com! -buffer ScalaSwitchLeft :call s:CodeOrTestFile('wincmd h')
com! -buffer ScalaSwitchSplitLeft :call s:CodeOrTestFile('let b:curspr=&spr | set nospr | vsplit | wincmd h | if b:curspr | set spr | endif | unlet b:curspr')
com! -buffer ScalaSwitchAbove :call s:CodeOrTestFile('wincmd k')
com! -buffer ScalaSwitchSplitAbove :call s:CodeOrTestFile('let b:cursb=&sb | set nosb | split | wincmd k | if b:cursb | set sb | endif | unlet b:cursb')
com! -buffer ScalaSwitchBelow :call s:CodeOrTestFile('wincmd j')
com! -buffer ScalaSwitchSplitBelow :call s:CodeOrTestFile('let b:cursb=&sb | set nosb | split | wincmd j | if b:cursb | set sb | endif | unlet b:cursb')

nmap <buffer> <silent> ,of :ScalaSwitchHere<cr>
nmap <buffer> <silent> ,ol :ScalaSwitchRight<cr>
nmap <buffer> <silent> ,oL :ScalaSwitchSplitRight<cr>
nmap <buffer> <silent> ,oh :ScalaSwitchLeft<cr>
nmap <buffer> <silent> ,oH :ScalaSwitchSplitLeft<cr>
nmap <buffer> <silent> ,ok :ScalaSwitchAbove<cr>
nmap <buffer> <silent> ,oK :ScalaSwitchSplitAbove<cr>
nmap <buffer> <silent> ,oj :ScalaSwitchBelow<cr>
nmap <buffer> <silent> ,oJ :ScalaSwitchSplitBelow<cr>
Something went wrong with that request. Please try again.