updated for version 7.2a

This commit is contained in:
Bram Moolenaar
2008-06-24 21:16:56 +00:00
parent a7241f5f19
commit 3577c6fafb
123 changed files with 39104 additions and 1352 deletions

206
runtime/indent/erlang.vim Normal file
View File

@ -0,0 +1,206 @@
" Vim indent file
" Language: Erlang
" Maintainer: Csaba Hoch <csaba.hoch@gmail.com>
" Contributor: Edwin Fine <efine145_nospam01 at usa dot net>
" Last Change: 2008 Mar 12
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
setlocal indentexpr=ErlangIndent()
setlocal indentkeys+==after,=end,=catch,=),=],=}
" Only define the functions once.
if exists("*ErlangIndent")
finish
endif
" The function go through the whole line, analyses it and sets the indentation
" (ind variable).
" l: the number of the line to be examined.
function s:ErlangIndentAtferLine(l)
let i = 0 " the index of the current character in the line
let length = strlen(a:l) " the length of the line
let ind = 0 " how much should be the difference between the indentation of
" the current line and the indentation of the next line?
" e.g. +1: the indentation of the next line should be equal to
" the indentation of the current line plus one shiftwidth
let lastFun = 0 " the last token was a 'fun'
let lastReceive = 0 " the last token was a 'receive'; needed for 'after'
let lastHashMark = 0 " the last token was a 'hashmark'
while 0<= i && i < length
" m: the next value of the i
if a:l[i] == '%'
break
elseif a:l[i] == '"'
let m = matchend(a:l,'"\%([^"\\]\|\\.\)*"',i)
let lastReceive = 0
elseif a:l[i] == "'"
let m = matchend(a:l,"'[^']*'",i)
let lastReceive = 0
elseif a:l[i] =~# "[a-z]"
let m = matchend(a:l,".[[:alnum:]_]*",i)
if lastFun
let ind = ind - 1
let lastFun = 0
let lastReceive = 0
elseif a:l[(i):(m-1)] =~# '^\%(case\|if\|try\)$'
let ind = ind + 1
elseif a:l[(i):(m-1)] =~# '^receive$'
let ind = ind + 1
let lastReceive = 1
elseif a:l[(i):(m-1)] =~# '^begin$'
let ind = ind + 2
let lastReceive = 0
elseif a:l[(i):(m-1)] =~# '^end$'
let ind = ind - 2
let lastReceive = 0
elseif a:l[(i):(m-1)] =~# '^after$'
if lastReceive == 0
let ind = ind - 1
else
let ind = ind + 0
end
let lastReceive = 0
elseif a:l[(i):(m-1)] =~# '^fun$'
let ind = ind + 1
let lastFun = 1
let lastReceive = 0
endif
elseif a:l[i] =~# "[A-Z_]"
let m = matchend(a:l,".[[:alnum:]_]*",i)
let lastReceive = 0
elseif a:l[i] == '$'
let m = i+2
let lastReceive = 0
elseif a:l[i] == "." && (i+1>=length || a:l[i+1]!~ "[0-9]")
let m = i+1
if lastHashMark
let lastHashMark = 0
else
let ind = ind - 1
end
let lastReceive = 0
elseif a:l[i] == '-' && (i+1<length && a:l[i+1]=='>')
let m = i+2
let ind = ind + 1
let lastReceive = 0
elseif a:l[i] == ';'
let m = i+1
let ind = ind - 1
let lastReceive = 0
elseif a:l[i] == '#'
let m = i+1
let lastHashMark = 1
elseif a:l[i] =~# '[({[]'
let m = i+1
let ind = ind + 1
let lastFun = 0
let lastReceive = 0
let lastHashMark = 0
elseif a:l[i] =~# '[)}\]]'
let m = i+1
let ind = ind - 1
let lastReceive = 0
else
let m = i+1
endif
let i = m
endwhile
return ind
endfunction
function s:FindPrevNonBlankNonComment(lnum)
let lnum = prevnonblank(a:lnum)
let line = getline(lnum)
" continue to search above if the current line begins with a '%'
while line =~# '^\s*%.*$'
let lnum = prevnonblank(lnum - 1)
if 0 == lnum
return 0
endif
let line = getline(lnum)
endwhile
return lnum
endfunction
function ErlangIndent()
" 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 prevline = getline(lnum)
let currline = getline(v:lnum)
let ind = indent(lnum) + &sw * s:ErlangIndentAtferLine(prevline)
" special cases:
if prevline =~# '^\s*\%(after\|end\)\>'
let ind = ind + 2*&sw
endif
if currline =~# '^\s*end\>'
let ind = ind - 2*&sw
endif
if currline =~# '^\s*after\>'
let plnum = s:FindPrevNonBlankNonComment(v:lnum-1)
if getline(plnum) =~# '^[^%]*\<receive\>\s*\%(%.*\)\=$'
let ind = ind - 1*&sw
" If the 'receive' is not in the same line as the 'after'
else
let ind = ind - 2*&sw
endif
endif
if prevline =~# '^\s*[)}\]]'
let ind = ind + 1*&sw
endif
if currline =~# '^\s*[)}\]]'
let ind = ind - 1*&sw
endif
if prevline =~# '^\s*\%(catch\)\s*\%(%\|$\)'
let ind = ind + 1*&sw
endif
if currline =~# '^\s*\%(catch\)\s*\%(%\|$\)'
let ind = ind - 1*&sw
endif
if ind<0
let ind = 0
endif
return ind
endfunction
" TODO:
"
" f() ->
" x("foo
" bar")
" ,
" bad_indent.
"
" fun
" init/0,
" bad_indent
"
" #rec
" .field,
" bad_indent
"
" case X of
" 1 when A; B ->
" bad_indent

View File

@ -43,7 +43,7 @@ endif
function! GetErubyIndent()
let vcol = col('.')
call cursor(v:lnum,1)
let inruby = searchpair('<%','','%>')
let inruby = searchpair('<%','','%>','W')
call cursor(v:lnum,vcol)
if inruby && getline(v:lnum) !~ '^<%'
let ind = GetRubyIndent()
@ -70,4 +70,4 @@ function! GetErubyIndent()
return ind
endfunction
" vim:set sw=2 sts=2 ts=8 noet ff=unix:
" vim:set sw=2 sts=2 ts=8 noet:

View File

@ -0,0 +1,35 @@
" Vim indent file
" Language: git config file
" Maintainer: Tim Pope <vimNOSPAM@tpope.info>
" Last Change: 2008 Jun 04
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
setlocal autoindent
setlocal indentexpr=GetGitconfigIndent()
setlocal indentkeys=o,O,*<Return>,0[,],0;,0#,=,!^F
" Only define the function once.
if exists("*GetGitconfigIndent")
finish
endif
function! GetGitconfigIndent()
let line = getline(prevnonblank(v:lnum-1))
let cline = getline(v:lnum)
if line =~ '\\\@<!\%(\\\\\)*\\$'
" odd number of slashes, in a line continuation
return 2 * &sw
elseif cline =~ '^\s*\['
return 0
elseif cline =~ '^\s*\a'
return &sw
elseif cline == '' && line =~ '^\['
return &sw
else
return -1
endif
endfunction

View File

@ -2,7 +2,7 @@
" Language: Lua script
" Maintainer: Marcus Aurelius Farias <marcus.cf 'at' bol.com.br>
" First Author: Max Ischenko <mfi 'at' ukr.net>
" Last Change: 2005 Jun 23
" Last Change: 2007 Jul 23
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
@ -25,33 +25,37 @@ endif
function! GetLuaIndent()
" Find a non-blank line above the current line.
let lnum = prevnonblank(v:lnum - 1)
let prevlnum = prevnonblank(v:lnum - 1)
" Hit the start of the file, use zero indent.
if lnum == 0
if prevlnum == 0
return 0
endif
" Add a 'shiftwidth' after lines that start a block:
" 'function', 'if', 'for', 'while', 'repeat', 'else', 'elseif', '{'
let ind = indent(lnum)
let flag = 0
let prevline = getline(lnum)
if prevline =~ '^\s*\%(if\>\|for\>\|while\>\|repeat\>\|else\>\|elseif\>\|do\>\|then\>\)'
\ || prevline =~ '{\s*$' || prevline =~ '\<function\>\s*\%(\k\|[.:]\)\{-}\s*('
let ind = ind + &shiftwidth
let flag = 1
let ind = indent(prevlnum)
let prevline = getline(prevlnum)
let midx = match(prevline, '^\s*\%(if\>\|for\>\|while\>\|repeat\>\|else\>\|elseif\>\|do\>\|then\>\)')
if midx == -1
let midx = match(prevline, '{\s*$')
if midx == -1
let midx = match(prevline, '\<function\>\s*\%(\k\|[.:]\)\{-}\s*(')
endif
endif
" Subtract a 'shiftwidth' after lines ending with
" 'end' when they begin with 'while', 'if', 'for', etc. too.
if flag == 1 && prevline =~ '\<end\>\|\<until\>'
let ind = ind - &shiftwidth
if midx != -1
" Add 'shiftwidth' if what we found previously is not in a comment and
" an "end" or "until" is not present on the same line.
if synIDattr(synID(prevlnum, midx + 1, 1), "name") != "luaComment" && prevline !~ '\<end\>\|\<until\>'
let ind = ind + &shiftwidth
endif
endif
" Subtract a 'shiftwidth' on end, else (and elseif), until and '}'
" This is the part that requires 'indentkeys'.
if getline(v:lnum) =~ '^\s*\%(end\|else\|until\|}\)'
let midx = match(getline(v:lnum), '^\s*\%(end\|else\|until\|}\)')
if midx != -1 && synIDattr(synID(v:lnum, midx + 1, 1), "name") != "luaComment"
let ind = ind - &shiftwidth
endif