我下载了
Scala 2.8,安装了包含的vim脚本,并尝试输入一些Scala代码.当我输入val x = 1 2并按ENTER时,缩进到v以下.当我输入val x =(1 2)时,缩进在x!
如果VIM被Scala所有人使用,那么这个bug应该早已被看到了.还是我唯一看到这个的?
使用目前的2.8.0.final版本的缩进/ scala.vim,我有相同的结果…但是我知道,它在早期版本中起作用,因为我有一个文件在这里工作.这里是:
" Vim indent file " Language : Scala (http://scala-lang.org/) " Maintainer : Stefan Matthias Aust " Last Change: 2006 Apr 13 if exists("b:did_indent") finish endif let b:did_indent = 1 setlocal indentexpr=GetScalaIndent() setlocal indentkeys=0{,0},0),!^F,<>>,<CR> setlocal autoindent sw=2 et if exists("*GetScalaIndent") finish endif function! CountParens(line) let line = substitute(a:line,'"\(.\|\\"\)*"','','g') let open = substitute(line,'[^(]','g') let close = substitute(line,'[^)]','g') return strlen(open) - strlen(close) endfunction function! GetScalaIndent() " Find a non-blank line above the current line. let lnum = prevnonblank(v:lnum - 1) " Hit the start of the file,use zero indent. if lnum == 0 return 0 endif let ind = indent(lnum) let prevline = getline(lnum) "Indent html literals if prevline !~ '/>\s*$' && prevline =~ '^\s*<[a-zA-Z][^>]*>\s*$' return ind + &shiftwidth endif "### Taken from mail on scala mailing list "### ------------------------------------- " Add a 'shiftwidth' after lines that start a block " If if,for or while end with ),this is a one-line block " If val,var,def end with =,this is a one-line block "if prevline =~ '^\s*\<\(\(else\s\+\)\?if\|for\|while\|va[lr]\|def\)\>.*[)=]\s*$' "\ || prevline =~ '^\s*\<else\>\s*$' "\ || prevline =~ '{\s*$' "let ind = ind + &shiftwidth "endif " Add a 'shiftwidth' after lines that start a block " If if,this is a one-line block " If val,this is a one-line block if prevline =~ '^\s*\<\(\(else\s\+\)\?if\|for\|while\)\>.*[)]\s*$' \ || prevline =~ '^\s*\<\(\(va[lr]\|def\)\>.*[=]\s*$' \ || prevline =~ '^\s*\<else\>\s*$' \ || prevline =~ '{\s*$' let ind = ind + &shiftwidth endif " If parenthesis are unbalanced,indent or dedent let c = CountParens(prevline) echo c if c > 0 let ind = ind + &shiftwidth elseif c < 0 let ind = ind - &shiftwidth endif "### Taken from mail on scala mailing list "### ------------------------------------- " Dedent after if,for,while and val,def without block "let pprevline = getline(prevnonblank(lnum - 1)) "if pprevline =~ '^\s*\<\(\(else\s\+\)\?if\|for\|while\|va[lr]\|def\)\>.*[)=]\s*$' "\ || pprevline =~ '^\s*\<else\>\s*$' "let ind = ind - &shiftwidth "endif " Dedent after if,def without block "let pprevline = getline(prevnonblank(lnum - 1)) if pprevline =~ '^\s*\<\(\(else\s\+\)\?if\|for\|while\)\>.*[)]\s*$' \ || pprevline =~ '^\s*\<\(\va[lr]\|def\)\>.*[=]\s*$' \ || pprevline =~ '^\s*\<else\>\s*$' let ind = ind - &shiftwidth endif " Align 'for' clauses nicely if prevline =~ '^\s*\<for\> (.*;\s*$' let ind = ind - &shiftwidth + 5 endif " Subtract a 'shiftwidth' on '}' or html let thisline = getline(v:lnum) if thisline =~ '^\s*[})]' \ || thisline =~ '^\s*</[a-zA-Z][^>]*>' let ind = ind - &shiftwidth endif return ind endfunction
但是我没有任何线索,在这里引入了变化,试图在https://codereview.scala-lang.org/fisheye/browse/scala-svn/scala-tool-support/trunk/src/vim/indent/scala.vim的SVN历史中找到它