Permalink
Browse files

Enhanced the scala stuff so that it works better with a Play repository.

  • Loading branch information...
1 parent 0fde040 commit 578cbfd4401722b205c989d8610a01d792b43992 Derek Wyatt committed May 16, 2012
Showing with 25 additions and 19 deletions.
  1. +8 −2 ftplugin/scala.vim
  2. +2 −2 vimrc
  3. +15 −15 xpt-personal/ftplugin/scala/scala.xpt.vim
View
10 ftplugin/scala.vim
@@ -9,12 +9,18 @@ if !exists("*s:CodeOrTestFile")
function! s:CodeOrTestFile(precmd)
let current = expand('%:p')
let other = current
- if current =~ "/main/"
+ if current =~ "/src/main/"
let other = substitute(current, "/main/", "/test/", "")
let other = substitute(other, ".scala$", "Spec.scala", "")
- elseif current =~ "/test/"
+ 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
View
4 vimrc
@@ -353,8 +353,8 @@ if has("mac")
let g:main_font = "Anonymous\\ Pro:h16"
let g:small_font = "Anonymous\\ Pro:h2"
else
- let g:main_font = "Monospace\\ 9"
- let g:small_font = "Monospace\\ 2"
+ let g:main_font = "DejaVu\\ Sans\\ Mono\\ 10"
+ let g:small_font = "DejaVu\\ Sans\\ Mono\\ 2"
endif
"-----------------------------------------------------------------------------
View
30 xpt-personal/ftplugin/scala/scala.xpt.vim
@@ -20,23 +20,23 @@ endfunction
function! s:f.getPackageForFile(...)
let dir = expand('%:p:h')
- let needle = 'src/main/scala'
- let idx = stridx(dir, needle)
- if idx == -1
- let needle = 'src/test/scala'
- let idx = stridx(dir, needle)
- endif
- if idx == -1
- let needle = 'src/multi-jvm/scala'
- let idx = stridx(dir, needle)
- endif
- if idx != -1
- let subdir = strpart(dir, idx + strlen(needle) + 1)
+ let regexes = [
+ \ [ '/src/main/scala', '/src/main/scala' ],
+ \ [ '/src/test/scala', '/src/test/scala' ],
+ \ [ '/src/multi-jvm/scala', '/src/multi-jvm/scala' ],
+ \ [ '/app/model/scala', '/app/model/scala' ],
+ \ [ '/app/controllers', '/app' ],
+ \ [ '/test/scala', '/test/scala' ]
+ \ ]
+ for e in regexes
+ let idx = match(dir, e[0])
+ if idx != -1
+ let subdir = strpart(dir, idx + strlen(e[1]) + 1)
let package = substitute(subdir, '/', '.', 'g')
return package
- else
- return ''
- endif
+ endif
+ endfor
+ return ''
endfunction
function! s:f.classname(...)

0 comments on commit 578cbfd

Please sign in to comment.