diff options
| author | Adam Stankiewicz <sheerun@sher.pl> | 2013-09-12 17:02:41 +0200 | 
|---|---|---|
| committer | Adam Stankiewicz <sheerun@sher.pl> | 2013-09-12 17:02:41 +0200 | 
| commit | 0a4fcd12b6227ae9975d64353025e55e2e0caddf (patch) | |
| tree | e7fd30c6aab1ecb25f0867acb43e3a403c5f4878 /ftplugin | |
| parent | 49b050f04240628288ee09b453280c522507477f (diff) | |
| download | vim-polyglot-0a4fcd12b6227ae9975d64353025e55e2e0caddf.tar.gz vim-polyglot-0a4fcd12b6227ae9975d64353025e55e2e0caddf.zip | |
Add scala and sbt support
Diffstat (limited to '')
| -rw-r--r-- | ftplugin/scala.vim | 166 | ||||
| -rw-r--r-- | ftplugin/scala.xpt.vim | 29 | 
2 files changed, 195 insertions, 0 deletions
| diff --git a/ftplugin/scala.vim b/ftplugin/scala.vim new file mode 100644 index 00000000..cdd1a74d --- /dev/null +++ b/ftplugin/scala.vim @@ -0,0 +1,166 @@ +setlocal textwidth=140 +setlocal shiftwidth=2 +setlocal softtabstop=2 +setlocal expandtab +setlocal formatoptions=tcqr +setlocal commentstring=//%s + +set makeprg=sbt\ -Dsbt.log.noformat=true\ compile +set efm=%E\ %#[error]\ %f:%l:\ %m,%C\ %#[error]\ %p^,%-C%.%#,%Z, +       \%W\ %#[warn]\ %f:%l:\ %m,%C\ %#[warn]\ %p^,%-C%.%#,%Z, +       \%-G%.%# + +if globpath(&rtp, 'plugin/fuf.vim') != '' +    " +    " FuzzyFinder stuff +    " +    " +    " SanitizeDirForFuzzyFinder() +    " +    " This is really just a convenience function to clean up any stray '/' +    " characters in the path, should they be there. +    " +    function! scala#SanitizeDirForFuzzyFinder(dir) +        let dir = expand(a:dir) +        let dir = substitute(dir, '/\+$', '', '') +        let dir = substitute(dir, '/\+', '/', '') + +        return dir +    endfunction + +    " +    " GetDirForFuzzyFinder() +    " +    " Given a directory to start 'from', walk up the hierarchy, looking for a path +    " that matches the 'addon' you want to see. +    " +    " If nothing can be found, then we just return the 'from' so we don't really get +    " the advantage of a hint, but just let the user start from wherever he was +    " starting from anyway. +    " +    function! scala#GetDirForFuzzyFinder(from, addon) +        let from = scala#SanitizeDirForFuzzyFinder(a:from) +        let addon = expand(a:addon) +        let addon = substitute(addon, '^/\+', '', '') +        let found = '' +        " If the addon is right here, then we win +        if isdirectory(from . '/' . addon) +            let found = from . '/' . addon +        else +            let dirs = split(from, '/') +        if !has('win32') && !has('win64') +          let dirs[0] = '/' . dirs[0] +        endif +            " Walk up the tree and see if it's anywhere there +            for n in range(len(dirs) - 1, 0, -1) +                let path = join(dirs[0:n], '/') +                if isdirectory(path . '/' . addon) +                    let found = path . '/' . addon +                    break +                endif +            endfor +        endif +        " If we found it, then let's see if we can go deeper +        " +        " For example, we may have found component_name/include +        " but what if that directory only has a single directory +        " in it, and that subdirectory only has a single directory +        " in it, etc... ?  This can happen when you're segmenting +        " by namespace like this: +        " +        "    component_name/include/org/vim/CoolClass.h +        " +        " You may find yourself always typing '' from the +        " 'include' directory just to go into 'org/vim' so let's +        " just eliminate the need to hit the ''. +        if found != '' +            let tempfrom = found +            let globbed = globpath(tempfrom, '*') +            while len(split(globbed, "\n")) == 1 +                let tempfrom = globbed +                let globbed = globpath(tempfrom, '*') +            endwhile +            let found = scala#SanitizeDirForFuzzyFinder(tempfrom) . '/' +        else +            let found = from +        endif + +        return found +    endfunction + +    " +    " GetTestDirForFuzzyFinder() +    " +    " Now overload GetDirForFuzzyFinder() specifically for the test directory (I'm +    " really only interested in going down into test/src 90% of the time, so let's +    " hit that 90% and leave the other 10% to couple of extra keystrokes) +    " +    function! scala#GetTestDirForFuzzyFinder(from) +        return scala#GetDirForFuzzyFinder(a:from, 'src/test/scala/') +    endfunction + +    " +    " GetMainDirForFuzzyFinder() +    " +    " Now overload GetDirForFuzzyFinder() specifically for the main directory. +    " +    function! scala#GetMainDirForFuzzyFinder(from) +        return scala#GetDirForFuzzyFinder(a:from, 'src/main/scala/') +    endfunction + +    " +    " GetRootDirForFuzzyFinder() +    " +    " Now overload GetDirForFuzzyFinder() specifically for the root directory. +    " +    function! scala#GetRootDirForFuzzyFinder(from) +        return scala#GetDirForFuzzyFinder(a:from, 'src/../') +    endfunction + +    nnoremap <buffer> <silent> ,ft :FufFile <c-r>=scala#GetTestDirForFuzzyFinder('%:p:h')<cr><cr> +    nnoremap <buffer> <silent> ,fs :FufFile <c-r>=scala#GetMainDirForFuzzyFinder('%:p:h')<cr><cr> +    nnoremap <buffer> <silent> ,fr :FufFile <c-r>=scala#GetRootDirForFuzzyFinder('%:p:h')<cr><cr> +endif + +" If you want to disable the default key mappings, write the following line in +" your ~/.vimrc +"     let g:scala_use_default_keymappings = 0 +if get(g:, 'scala_use_default_keymappings', 1) +    nnoremap <buffer> ,jt :call JustifyCurrentLine()<cr> +endif + +" +" TagBar +" +let g:tagbar_type_scala = { +    \ 'ctagstype' : 'scala', +    \ 'kinds'     : [ +      \ 'p:packages:1', +      \ 'V:values', +      \ 'v:variables', +      \ 'T:types', +      \ 't:traits', +      \ 'o:objects', +      \ 'a:aclasses', +      \ 'c:classes', +      \ 'r:cclasses', +      \ 'm:methods' +    \ ], +    \ 'sro'        : '.', +    \ 'kind2scope' : { +        \ 'T' : 'type', +        \ 't' : 'trait', +        \ 'o' : 'object', +        \ 'a' : 'abstract class', +        \ 'c' : 'class', +        \ 'r' : 'case class' +    \ }, +    \ 'scope2kind' : { +      \ 'type' : 'T', +      \ 'trait' : 't', +      \ 'object' : 'o', +      \ 'abstract class' : 'a', +      \ 'class' : 'c', +      \ 'case class' : 'r' +    \ } +\ } diff --git a/ftplugin/scala.xpt.vim b/ftplugin/scala.xpt.vim new file mode 100644 index 00000000..09d2b594 --- /dev/null +++ b/ftplugin/scala.xpt.vim @@ -0,0 +1,29 @@ + +XPTemplate priority=lang + +XPTvar $BRif ' ' +XPTvar $BRel \n +XPTvar $BRloop ' ' +XPTvar $BRfun ' ' + +XPTinclude +    \ _common/personal +    \ java/java + +XPT cake hint=Cake\ Pattern +XSET trait|def=Some +XSET derived|def=Real +trait `trait^Component { +	trait `trait^ { +		`body^ +	} + +	val `trait^SV('(.)', '\l\1', '')^^: `trait^ +} + +trait `derived^`trait^Component extends `trait^Component { + +	override lazy val `trait^SV('(.)', '\l\1', '')^^ = new `trait^ { +		`body2^ +	} +} | 
