summaryrefslogtreecommitdiffstats
path: root/indent/scala.vim
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2022-03-07 14:43:44 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2022-03-07 14:43:44 +0100
commitcbcab8684e06379c9f5c51cfc9cac68d8684fe0c (patch)
treed03b04e9a7f8e3aae70e590953408f90deed077c /indent/scala.vim
parent721a7ea65d23e7b149ba73968a1d75727a55b390 (diff)
downloadvim-cbcab8684e06379c9f5c51cfc9cac68d8684fe0c.zip
vim-cbcab8684e06379c9f5c51cfc9cac68d8684fe0c.tar.gz
move to old
Diffstat (limited to 'indent/scala.vim')
-rw-r--r--indent/scala.vim85
1 files changed, 0 insertions, 85 deletions
diff --git a/indent/scala.vim b/indent/scala.vim
deleted file mode 100644
index c3e7c91..0000000
--- a/indent/scala.vim
+++ /dev/null
@@ -1,85 +0,0 @@
-" 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 shiftwidth=2 tabstop=2 softtabstop=2 expandtab
-
-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
-
- " 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\)\>.*[)]\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
-
- " Dedent after if, for, while and val, var, 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