summaryrefslogtreecommitdiffstats
path: root/indent
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2014-08-27 18:16:33 +0200
committerAdam Stankiewicz <sheerun@sher.pl>2014-08-27 18:16:33 +0200
commitbd35da8e9ca0bddd95539bef0c8f4857dc4cc746 (patch)
tree2eda075ecdbeb5a05a536c3a91272559ee936989 /indent
parent91da1ec2a5e8fb926535160ef4644ff879d3ee08 (diff)
downloadvim-polyglot-1.10.1.tar.gz
vim-polyglot-1.10.1.zip
Updatev1.10.1
Diffstat (limited to 'indent')
-rw-r--r--indent/eelixir.vim72
-rw-r--r--indent/scala.vim14
2 files changed, 81 insertions, 5 deletions
diff --git a/indent/eelixir.vim b/indent/eelixir.vim
new file mode 100644
index 00000000..7b17c104
--- /dev/null
+++ b/indent/eelixir.vim
@@ -0,0 +1,72 @@
+" Vim indent file
+" Language: Embedded Elixir
+" URL: https://github.com/elixir-lang/vim-elixir
+
+
+if exists("b:did_indent")
+ finish
+endif
+
+runtime! indent/elixir.vim
+unlet! b:did_indent
+setlocal indentexpr=
+
+if exists("b:eelixir_subtype")
+ exe "runtime! indent/".b:eelixir_subtype.".vim"
+else
+ runtime! indent/html.vim
+endif
+unlet! b:did_indent
+
+if &l:indentexpr == ''
+ if &l:cindent
+ let &l:indentexpr = 'cindent(v:lnum)'
+ else
+ let &l:indentexpr = 'indent(prevnonblank(v:lnum-1))'
+ endif
+endif
+let b:eelixir_subtype_indentexpr = &l:indentexpr
+
+let b:did_indent = 1
+
+setlocal indentexpr=GetEelixirIndent()
+setlocal indentkeys=o,O,*<Return>,<>>,{,},0),0],o,O,!^F,=end,=else,=elsif,=catch,=after,=rescue
+
+" Only define the function once.
+if exists("*GetEelixirIndent")
+ finish
+endif
+
+function! GetEelixirIndent(...)
+ if a:0 && a:1 == '.'
+ let v:lnum = line('.')
+ elseif a:0 && a:1 =~ '^\d'
+ let v:lnum = a:1
+ endif
+ let vcol = col('.')
+ call cursor(v:lnum,1)
+ let inelixir = searchpair('<%','','%>','W')
+ call cursor(v:lnum,vcol)
+ if inelixir && getline(v:lnum) !~ '^<%\|^\s*%>'
+ let ind = GetElixirIndent()
+ else
+ exe "let ind = ".b:eelixir_subtype_indentexpr
+ endif
+ let lnum = prevnonblank(v:lnum-1)
+ let line = getline(lnum)
+ let cline = getline(v:lnum)
+ if cline =~# '^\s*<%\s*\%(end\|else\|elsif\|catch\|after\|rescue\)\>.*%>'
+ let ind = ind - &sw
+ elseif line =~# '\S\s*<%\s*end\s*%>'
+ let ind = ind - &sw
+ endif
+ if line =~# '<%[=%]\=\s*.*\<do\s*%>'
+ let ind = ind + &sw
+ elseif line =~# '<%\s*\%(else\|elsif\|catch\|after\|rescue\)\>.*%>'
+ let ind = ind + &sw
+ endif
+ if cline =~# '^\s*%>\s*$'
+ let ind = ind - &sw
+ endif
+ return ind
+endfunction
diff --git a/indent/scala.vim b/indent/scala.vim
index 4053a83c..f533a514 100644
--- a/indent/scala.vim
+++ b/indent/scala.vim
@@ -36,12 +36,12 @@ endfunction
function! scala#GetLine(lnum)
let line = substitute(getline(a:lnum), '//.*$', '', '')
- let line = substitute(line, '"[^"]*"', '""', 'g')
+ let line = substitute(line, '"\(.\|\\"\)\{-}"', '""', 'g')
return line
endfunction
function! scala#CountBrackets(line, openBracket, closedBracket)
- let line = substitute(a:line, '"\(.\|\\"\)*"', '', 'g')
+ let line = substitute(a:line, '"\(.\|\\"\)\{-}"', '', 'g')
let open = substitute(line, '[^' . a:openBracket . ']', '', 'g')
let close = substitute(line, '[^' . a:closedBracket . ']', '', 'g')
return strlen(open) - strlen(close)
@@ -102,7 +102,7 @@ function! scala#CurlyMatcher()
if scala#CountParens(scala#GetLine(matchline)) < 0
let savedpos = getpos('.')
call setpos('.', [savedpos[0], matchline, 9999, savedpos[3]])
- call searchpos('{', 'Wb')
+ call searchpos('{', 'Wbc')
call searchpos(')', 'Wb')
let [lnum, colnum] = searchpairpos('(', '', ')', 'Wbn')
call setpos('.', savedpos)
@@ -133,7 +133,7 @@ function! scala#GetLineAndColumnThatMatchesBracket(openBracket, closedBracket)
call searchpos(a:closedBracket . '\ze[^' . a:closedBracket . a:openBracket . ']*' . a:openBracket, 'W')
else
call setpos('.', [savedpos[0], savedpos[1], 9999, savedpos[3]])
- call searchpos(a:closedBracket, 'Wb')
+ call searchpos(a:closedBracket, 'Wbc')
endif
let [lnum, colnum] = searchpairpos(a:openBracket, '', a:closedBracket, 'Wbn')
call setpos('.', savedpos)
@@ -382,7 +382,11 @@ function! GetScalaIndent()
let curline = scala#GetLine(curlnum)
if prevline =~ '^\s*/\*\*'
- return ind + 1
+ if prevline =~ '\*/\s*$'
+ return ind
+ else
+ return ind + 1
+ endif
endif
if curline =~ '^\s*\*'