updated for version 7.2b-000
This commit is contained in:
@ -3,17 +3,19 @@
|
||||
" Language: Ada (2005)
|
||||
" $Id$
|
||||
" Copyright: Copyright (C) 2006 Martin Krischik
|
||||
" Maintainer: Martin Krischik
|
||||
" Maintainer: Martin Krischik <krischik@users.sourceforge.net>
|
||||
" Neil Bird <neil@fnxweb.com>
|
||||
" Ned Okie <nokie@radford.edu>
|
||||
" $Author$
|
||||
" $Date$
|
||||
" Version: 4.2
|
||||
" Version: 4.6
|
||||
" $Revision$
|
||||
" $HeadURL: https://svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/indent/ada.vim $
|
||||
" $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/indent/ada.vim $
|
||||
" History: 24.05.2006 MK Unified Headers
|
||||
" 16.07.2006 MK Ada-Mode as vim-ball
|
||||
" 15.10.2006 MK Bram's suggestion for runtime integration
|
||||
" 05.11.2006 MK Bram suggested to save on spaces
|
||||
" 19.09.2007 NO g: missing before ada#Comment
|
||||
" Help Page: ft-vim-indent
|
||||
"------------------------------------------------------------------------------
|
||||
" ToDo:
|
||||
@ -27,7 +29,7 @@ if exists("b:did_indent") || version < 700
|
||||
finish
|
||||
endif
|
||||
|
||||
let b:did_indent = 1
|
||||
let b:did_indent = 45
|
||||
|
||||
setlocal indentexpr=GetAdaIndent()
|
||||
setlocal indentkeys-=0{,0}
|
||||
@ -58,7 +60,7 @@ endif
|
||||
" Seems to work OK as it 'starts' with the indent of the /previous/ line.
|
||||
function s:MainBlockIndent (prev_indent, prev_lnum, blockstart, stop_at)
|
||||
let lnum = a:prev_lnum
|
||||
let line = substitute( getline(lnum), ada#Comment, '', '' )
|
||||
let line = substitute( getline(lnum), g:ada#Comment, '', '' )
|
||||
while lnum > 1
|
||||
if a:stop_at != '' && line =~ '^\s*' . a:stop_at && indent(lnum) < a:prev_indent
|
||||
return a:prev_indent
|
||||
@ -72,7 +74,7 @@ function s:MainBlockIndent (prev_indent, prev_lnum, blockstart, stop_at)
|
||||
let lnum = prevnonblank(lnum - 1)
|
||||
" Get previous non-blank/non-comment-only line
|
||||
while 1
|
||||
let line = substitute( getline(lnum), ada#Comment, '', '' )
|
||||
let line = substitute( getline(lnum), g:ada#Comment, '', '' )
|
||||
if line !~ '^\s*$' && line !~ '^\s*#'
|
||||
break
|
||||
endif
|
||||
@ -116,7 +118,7 @@ function s:EndBlockIndent( prev_indent, prev_lnum, blockstart, blockend )
|
||||
" Get previous non-blank/non-comment-only line
|
||||
while 1
|
||||
let line = getline(lnum)
|
||||
let line = substitute( line, ada#Comment, '', '' )
|
||||
let line = substitute( line, g:ada#Comment, '', '' )
|
||||
if line !~ '^\s*$'
|
||||
break
|
||||
endif
|
||||
@ -143,7 +145,8 @@ function s:StatementIndent( current_indent, prev_lnum )
|
||||
let lnum = prevnonblank(lnum - 1)
|
||||
" Get previous non-blank/non-comment-only line
|
||||
while 1
|
||||
let line = substitute( getline(lnum), ada#Comment, '', '' )
|
||||
let line = substitute( getline(lnum), g:ada#Comment, '', '' )
|
||||
|
||||
if line !~ '^\s*$' && line !~ '^\s*#'
|
||||
break
|
||||
endif
|
||||
@ -222,7 +225,7 @@ function GetAdaIndent()
|
||||
exe lnum
|
||||
exe 'normal! $F)%'
|
||||
if getline('.') =~ '^\s*('
|
||||
" Dire layout - use previous indent (could check for ada#Comment here)
|
||||
" Dire layout - use previous indent (could check for g:ada#Comment here)
|
||||
let ind = indent( prevnonblank( line('.')-1 ) )
|
||||
else
|
||||
let ind = indent('.')
|
||||
|
||||
@ -12,7 +12,7 @@ endif
|
||||
|
||||
runtime! indent/ruby.vim
|
||||
unlet! b:did_indent
|
||||
set indentexpr=
|
||||
setlocal indentexpr=
|
||||
|
||||
if exists("b:eruby_subtype")
|
||||
exe "runtime! indent/".b:eruby_subtype.".vim"
|
||||
@ -40,12 +40,17 @@ if exists("*GetErubyIndent")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! GetErubyIndent()
|
||||
function! GetErubyIndent(...)
|
||||
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 inruby = searchpair('<%','','%>','W')
|
||||
call cursor(v:lnum,vcol)
|
||||
if inruby && getline(v:lnum) !~ '^<%'
|
||||
if inruby && getline(v:lnum) !~ '^<%\|^\s*-\=%>'
|
||||
let ind = GetRubyIndent()
|
||||
else
|
||||
exe "let ind = ".b:eruby_subtype_indentexpr
|
||||
@ -53,15 +58,15 @@ function! GetErubyIndent()
|
||||
let lnum = prevnonblank(v:lnum-1)
|
||||
let line = getline(lnum)
|
||||
let cline = getline(v:lnum)
|
||||
if cline =~# '<%\s*\%(end\|else\|\%(ensure\|rescue\|elsif\|when\).\{-\}\)\s*\%(-\=%>\|$\)'
|
||||
if cline =~# '<%-\=\s*\%(}\|end\|else\|\%(ensure\|rescue\|elsif\|when\).\{-\}\)\s*\%(-\=%>\|$\)'
|
||||
let ind = ind - &sw
|
||||
endif
|
||||
if line =~# '\<do\%(\s*|[^|]*|\)\=\s*-\=%>'
|
||||
if line =~# '\%({\|\<do\)\%(\s*|[^|]*|\)\=\s*-\=%>'
|
||||
let ind = ind + &sw
|
||||
elseif line =~# '<%\s*\%(module\|class\|def\|if\|for\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure\|rescue\)\>.*%>'
|
||||
elseif line =~# '<%-\=\s*\%(module\|class\|def\|if\|for\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure\|rescue\)\>.*%>'
|
||||
let ind = ind + &sw
|
||||
endif
|
||||
if line =~# '^\s*<%[=#]\=\s*$' && cline !~# '^\s*end\>'
|
||||
if line =~# '^\s*<%[=#-]\=\s*$' && cline !~# '^\s*end\>'
|
||||
let ind = ind + &sw
|
||||
endif
|
||||
if cline =~# '^\s*-\=%>\s*$'
|
||||
|
||||
73
runtime/indent/haml.vim
Normal file
73
runtime/indent/haml.vim
Normal file
@ -0,0 +1,73 @@
|
||||
" Vim indent file
|
||||
" Language: HAML
|
||||
" Maintainer: Tim Pope <vimNOSPAM@tpope.info>
|
||||
" Last Change: 2007 Dec 16
|
||||
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
endif
|
||||
runtime! indent/ruby.vim
|
||||
unlet! b:did_indent
|
||||
let b:did_indent = 1
|
||||
|
||||
setlocal autoindent sw=2 et
|
||||
setlocal indentexpr=GetHamlIndent()
|
||||
setlocal indentkeys=o,O,*<Return>,},],0),!^F,=end,=else,=elsif,=rescue,=ensure,=when
|
||||
|
||||
" Only define the function once.
|
||||
if exists("*GetHamlIndent")
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:attributes = '\%({.\{-\}}\|\[.\{-\}\]\)'
|
||||
let s:tag = '\%([%.#][[:alnum:]_-]\+\|'.s:attributes.'\)*[<>]*'
|
||||
|
||||
if !exists('g:haml_self_closing_tags')
|
||||
let g:haml_self_closing_tags = 'meta|link|img|hr|br'
|
||||
endif
|
||||
|
||||
function! GetHamlIndent()
|
||||
let lnum = prevnonblank(v:lnum-1)
|
||||
if lnum == 0
|
||||
return 0
|
||||
endif
|
||||
let line = substitute(getline(lnum),'\s\+$','','')
|
||||
let cline = substitute(substitute(getline(v:lnum),'\s\+$','',''),'^\s\+','','')
|
||||
let lastcol = strlen(line)
|
||||
let line = substitute(line,'^\s\+','','')
|
||||
let indent = indent(lnum)
|
||||
let cindent = indent(v:lnum)
|
||||
if cline =~# '\v^-\s*%(elsif|else|when)>'
|
||||
let indent = cindent < indent ? cindent : indent - &sw
|
||||
endif
|
||||
let increase = indent + &sw
|
||||
if indent == indent(lnum)
|
||||
let indent = cindent <= indent ? -1 : increase
|
||||
endif
|
||||
"let indent = indent == indent(lnum) ? -1 : indent
|
||||
"let indent = indent > indent(lnum) + &sw ? indent(lnum) + &sw : indent
|
||||
|
||||
let group = synIDattr(synID(lnum,lastcol,1),'name')
|
||||
|
||||
if line =~ '^!!!'
|
||||
return indent
|
||||
elseif line =~ '^/\%(\[[^]]*\]\)\=$'
|
||||
return increase
|
||||
elseif line =~ '^:'
|
||||
return increase
|
||||
elseif line =~ '^'.s:tag.'[=~-]\s*\%(\%(if\|else\|elsif\|unless\|case\|when\|while\|until\|for\|begin\|module\|class\|def\)\>\%(.*\<end\>\)\@!\|.*do |[^|]*|\s*$\)'
|
||||
return increase
|
||||
elseif line == '-#'
|
||||
return increase
|
||||
elseif group =~? '\v^(hamlSelfCloser)$' || line =~? '^%\v%('.g:haml_self_closing_tags.')>'
|
||||
return indent
|
||||
elseif group =~? '\v^%(hamlTag|hamlAttributesDelimiter|hamlObjectDelimiter|hamlClass|hamlId|htmlTagName|htmlSpecialTagName)$'
|
||||
return increase
|
||||
elseif synIDattr(synID(v:lnum,1,1),'name') ==? 'hamlRubyFilter'
|
||||
return GetRubyIndent()
|
||||
else
|
||||
return indent
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" vim:set sw=2:
|
||||
61
runtime/indent/logtalk.vim
Normal file
61
runtime/indent/logtalk.vim
Normal file
@ -0,0 +1,61 @@
|
||||
" Maintainer: Paulo Moura <pmoura@logtalk.org>
|
||||
" Revised on: 2008.06.02
|
||||
" Language: Logtalk
|
||||
|
||||
" This Logtalk indent file is a modified version of the Prolog
|
||||
" indent file written by Gergely Kontra
|
||||
|
||||
" Only load this indent file when no other was loaded.
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
endif
|
||||
|
||||
let b:did_indent = 1
|
||||
|
||||
setlocal indentexpr=GetLogtalkIndent()
|
||||
setlocal indentkeys-=:,0#
|
||||
setlocal indentkeys+=0%,-,0;,>,0)
|
||||
|
||||
" Only define the function once.
|
||||
if exists("*GetLogtalkIndent")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! GetLogtalkIndent()
|
||||
" Find a non-blank line above the current line.
|
||||
let pnum = prevnonblank(v:lnum - 1)
|
||||
" Hit the start of the file, use zero indent.
|
||||
if pnum == 0
|
||||
return 0
|
||||
endif
|
||||
let line = getline(v:lnum)
|
||||
let pline = getline(pnum)
|
||||
|
||||
let ind = indent(pnum)
|
||||
" Previous line was comment -> use previous line's indent
|
||||
if pline =~ '^\s*%'
|
||||
retu ind
|
||||
endif
|
||||
" Check for entity opening directive on previous line
|
||||
if pline =~ '^\s*:-\s\(object\|protocol\|category\)\ze(.*,$'
|
||||
let ind = ind + &sw
|
||||
" Check for clause head on previous line
|
||||
elseif pline =~ ':-\s*\(%.*\)\?$'
|
||||
let ind = ind + &sw
|
||||
" Check for entity closing directive on previous line
|
||||
elseif pline =~ '^\s*:-\send_\(object\|protocol\|category\)\.\(%.*\)\?$'
|
||||
let ind = ind - &sw
|
||||
" Check for end of clause on previous line
|
||||
elseif pline =~ '\.\s*\(%.*\)\?$'
|
||||
let ind = ind - &sw
|
||||
endif
|
||||
" Check for opening conditional on previous line
|
||||
if pline =~ '^\s*\([(;]\|->\)' && pline !~ '\.\s*\(%.*\)\?$' && pline !~ '^.*\([)][,]\s*\(%.*\)\?$\)'
|
||||
let ind = ind + &sw
|
||||
endif
|
||||
" Check for closing an unclosed paren, or middle ; or ->
|
||||
if line =~ '^\s*\([);]\|->\)'
|
||||
let ind = ind - &sw
|
||||
endif
|
||||
return ind
|
||||
endfunction
|
||||
@ -2,11 +2,14 @@
|
||||
" Language: PHP
|
||||
" Author: John Wellesz <John.wellesz (AT) teaser (DOT) fr>
|
||||
" URL: http://www.2072productions.com/vim/indent/php.vim
|
||||
" Last Change: 2007 Jun 24
|
||||
" Last Change: 2008 June 7th
|
||||
" Newsletter: http://www.2072productions.com/?to=php-indent-for-vim-newsletter.php
|
||||
" Version: 1.24
|
||||
" Version: 1.28
|
||||
"
|
||||
" The change log and all the comments have been removed from this file.
|
||||
" If you find a bug, please e-mail me at John.wellesz (AT) teaser (DOT) fr
|
||||
" with an example of code that breaks the algorithm.
|
||||
"
|
||||
" ---> The change log and all the comments have been removed from this file.
|
||||
"
|
||||
" For a complete change log and fully commented code, download the script on
|
||||
" 2072productions.com at the URI provided above.
|
||||
@ -19,12 +22,15 @@
|
||||
"
|
||||
"
|
||||
" NOTE: This script must be used with PHP syntax ON and with the php syntax
|
||||
" script by Lutz Eymers ( http://www.isp.de/data/php.vim ) that's the script bundled with Vim.
|
||||
" script by Lutz Eymers (http://www.isp.de/data/php.vim ) or with the
|
||||
" script by Peter Hodge (http://www.vim.org/scripts/script.php?script_id=1571 )
|
||||
" the later is bunbdled by default with vim 7.
|
||||
"
|
||||
"
|
||||
" In the case you have syntax errors in your script such as end of HereDoc
|
||||
" tags not at col 1 you'll have to indent your file 2 times (This script
|
||||
" will automatically put HereDoc end tags at col 1).
|
||||
" In the case you have syntax errors in your script such as HereDoc end
|
||||
" identifiers not at col 1 you'll have to indent your file 2 times (This
|
||||
" script will automatically put HereDoc end identifiers at col 1 if
|
||||
" they are followed by a ';').
|
||||
"
|
||||
"
|
||||
" NOTE: If you are editing file in Unix file format and that (by accident)
|
||||
@ -37,8 +43,8 @@
|
||||
"
|
||||
" or simply 'let' the option PHP_removeCRwhenUnix to 1 and the script will
|
||||
" silently remove them when VIM load this script (at each bufread).
|
||||
|
||||
|
||||
"
|
||||
"
|
||||
" Options: PHP_autoformatcomment = 0 to not enable autoformating of comment by
|
||||
" default, if set to 0, this script will let the 'formatoptions' setting intact.
|
||||
"
|
||||
@ -48,7 +54,7 @@
|
||||
" Options: PHP_removeCRwhenUnix = 1 to make the script automatically remove CR
|
||||
" at end of lines (by default this option is unset), NOTE that you
|
||||
" MUST remove CR when the fileformat is UNIX else the indentation
|
||||
" won't be correct...
|
||||
" won't be correct!
|
||||
"
|
||||
" Options: PHP_BracesAtCodeLevel = 1 to indent the '{' and '}' at the same
|
||||
" level than the code they contain.
|
||||
@ -67,6 +73,10 @@
|
||||
"
|
||||
" NOTE: The script will be a bit slower if you use this option because
|
||||
" some optimizations won't be available.
|
||||
"
|
||||
" Options: PHP_vintage_case_default_indent = 1 (defaults to 0) to add a meaningless indent
|
||||
" befaore 'case:' and 'default":' statement in switch block
|
||||
"
|
||||
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
@ -89,12 +99,21 @@ else
|
||||
let b:PHP_BracesAtCodeLevel = 0
|
||||
endif
|
||||
|
||||
|
||||
if exists("PHP_autoformatcomment")
|
||||
let b:PHP_autoformatcomment = PHP_autoformatcomment
|
||||
else
|
||||
let b:PHP_autoformatcomment = 1
|
||||
endif
|
||||
|
||||
if exists("PHP_vintage_case_default_indent")
|
||||
let b:PHP_vintage_case_default_indent = PHP_vintage_case_default_indent
|
||||
else
|
||||
let b:PHP_vintage_case_default_indent = 0
|
||||
endif
|
||||
|
||||
|
||||
|
||||
let b:PHP_lastindented = 0
|
||||
let b:PHP_indentbeforelast = 0
|
||||
let b:PHP_indentinghuge = 0
|
||||
@ -182,8 +201,8 @@ function! GetLastRealCodeLNum(startline) " {{{
|
||||
endif
|
||||
|
||||
|
||||
elseif lastline =~? '^\a\w*;$' && lastline !~? s:notPhpHereDoc
|
||||
let tofind=substitute( lastline, '\([^;]\+\);', '<<<\1$', '')
|
||||
elseif lastline =~? '^\a\w*;\=$' && lastline !~? s:notPhpHereDoc " XXX 0607
|
||||
let tofind=substitute( lastline, '\(\a\w*\);\=', '<<<''\\=\1''\\=$', '') " XXX 0607
|
||||
while getline(lnum) !~? tofind && lnum > 1
|
||||
let lnum = lnum - 1
|
||||
endwhile
|
||||
@ -209,7 +228,7 @@ function! Skippmatch2()
|
||||
|
||||
let line = getline(".")
|
||||
|
||||
if line =~ '\%(".*\)\@<=/\*\%(.*"\)\@=' || line =~ '\%(//.*\)\@<=/\*'
|
||||
if line =~ '\%(".*\)\@<=/\*\%(.*"\)\@=' || line =~ '\%(\%(//\|#\).*\)\@<=/\*'
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
@ -218,7 +237,7 @@ endfun
|
||||
|
||||
function! Skippmatch() " {{{
|
||||
let synname = synIDattr(synID(line("."), col("."), 0), "name")
|
||||
if synname == "Delimiter" || synname == "phpRegionDelimiter" || synname =~# "^phpParent" || synname == "phpArrayParens" || synname =~# '^php\%(Block\|Brace\)' || synname == "javaScriptBraces" || synname == "phpComment" && b:UserIsTypingComment
|
||||
if synname == "Delimiter" || synname == "phpRegionDelimiter" || synname =~# "^phpParent" || synname == "phpArrayParens" || synname =~# '^php\%(Block\|Brace\)' || synname == "javaScriptBraces" || synname =~# "^phpComment" && b:UserIsTypingComment
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
@ -295,8 +314,8 @@ function! IslinePHP (lnum, tofind) " {{{
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
let s:notPhpHereDoc = '\%(break\|return\|continue\|exit\);'
|
||||
let s:blockstart = '\%(\%(\%(}\s*\)\=else\%(\s\+\)\=\)\=if\>\|else\>\|while\>\|switch\>\|for\%(each\)\=\>\|declare\>\|class\>\|interface\>\|abstract\>\|try\>\|catch\>\|[|&]\)'
|
||||
let s:notPhpHereDoc = '\%(break\|return\|continue\|exit\|else\)'
|
||||
let s:blockstart = '\%(\%(\%(}\s*\)\=else\%(\s\+\)\=\)\=if\>\|else\>\|while\>\|switch\>\|for\%(each\)\=\>\|declare\>\|class\>\|interface\>\|abstract\>\|try\>\|catch\>\)'
|
||||
|
||||
let s:autorestoptions = 0
|
||||
if ! s:autorestoptions
|
||||
@ -310,11 +329,11 @@ function! ResetOptions()
|
||||
|
||||
setlocal comments=s1:/*,mb:*,ex:*/,://,:#
|
||||
|
||||
" setlocal formatoptions-=t
|
||||
setlocal formatoptions-=t
|
||||
setlocal formatoptions+=q
|
||||
setlocal formatoptions+=r
|
||||
setlocal formatoptions+=o
|
||||
" setlocal formatoptions+=w
|
||||
setlocal formatoptions+=w
|
||||
setlocal formatoptions+=c
|
||||
setlocal formatoptions+=b
|
||||
endif
|
||||
@ -341,7 +360,7 @@ function! GetPhpIndent()
|
||||
if !b:PHP_indentinghuge && b:PHP_lastindented > b:PHP_indentbeforelast
|
||||
if b:PHP_indentbeforelast
|
||||
let b:PHP_indentinghuge = 1
|
||||
echom 'Large indenting detected, speed optimizations engaged'
|
||||
echom 'Large indenting detected, speed optimizations engaged (v1.28)'
|
||||
endif
|
||||
let b:PHP_indentbeforelast = b:PHP_lastindented
|
||||
endif
|
||||
@ -381,7 +400,7 @@ function! GetPhpIndent()
|
||||
let b:InPHPcode = 1
|
||||
let b:InPHPcode_tofind = ""
|
||||
|
||||
if synname == "phpComment"
|
||||
if synname =~# "^phpComment"
|
||||
let b:UserIsTypingComment = 1
|
||||
else
|
||||
let b:UserIsTypingComment = 0
|
||||
@ -396,11 +415,11 @@ function! GetPhpIndent()
|
||||
let b:UserIsTypingComment = 0
|
||||
|
||||
let lnum = v:lnum - 1
|
||||
while getline(lnum) !~? '<<<\a\w*$' && lnum > 1
|
||||
while getline(lnum) !~? '<<<''\=\a\w*''\=$' && lnum > 1
|
||||
let lnum = lnum - 1
|
||||
endwhile
|
||||
|
||||
let b:InPHPcode_tofind = substitute( getline(lnum), '^.*<<<\(\a\w*\)\c', '^\\s*\1;$', '')
|
||||
let b:InPHPcode_tofind = substitute( getline(lnum), '^.*<<<''\=\(\a\w*\)''\=$', '^\\s*\1;\\=$', '') " XXX 0607
|
||||
endif
|
||||
else
|
||||
let b:InPHPcode = 0
|
||||
@ -453,9 +472,9 @@ function! GetPhpIndent()
|
||||
let b:InPHPcode_and_script = 1
|
||||
endif
|
||||
|
||||
elseif last_line =~? '<<<\a\w*$'
|
||||
elseif last_line =~? '<<<''\=\a\w*''\=$' " XXX 0607
|
||||
let b:InPHPcode = 0
|
||||
let b:InPHPcode_tofind = substitute( last_line, '^.*<<<\(\a\w*\)\c', '^\\s*\1;$', '')
|
||||
let b:InPHPcode_tofind = substitute( last_line, '^.*<<<''\=\(\a\w*\)''\=$', '^\\s*\1;\\=$', '') " XXX 0607
|
||||
|
||||
elseif !UserIsEditing && cline =~ '^\s*/\*\%(.*\*/\)\@!' && getline(v:lnum + 1) !~ '^\s*\*'
|
||||
let b:InPHPcode = 0
|
||||
@ -513,7 +532,7 @@ function! GetPhpIndent()
|
||||
return 0
|
||||
endif
|
||||
|
||||
if cline =~? '^\s*\a\w*;$' && cline !~? s:notPhpHereDoc
|
||||
if cline =~? '^\s*\a\w*;$\|^\a\w*$' && cline !~? s:notPhpHereDoc " XXX 0607
|
||||
return 0
|
||||
endif " }}}
|
||||
|
||||
@ -558,7 +577,7 @@ function! GetPhpIndent()
|
||||
|
||||
let defaultORcase = '^\s*\%(default\|case\).*:'
|
||||
|
||||
if last_line =~ '[;}]'.endline && last_line !~# defaultORcase
|
||||
if last_line =~ '[;}]'.endline && last_line !~ '^)' && last_line !~# defaultORcase " Added && last_line !~ '^)' on 2007-12-30
|
||||
if ind==b:PHP_default_indenting
|
||||
return b:PHP_default_indenting
|
||||
elseif b:PHP_indentinghuge && ind==b:PHP_CurrentIndentLevel && cline !~# '^\s*\%(else\|\%(case\|default\).*:\|[})];\=\)' && last_line !~# '^\s*\%(\%(}\s*\)\=else\)' && getline(GetLastRealCodeLNum(lnum - 1))=~';'.endline
|
||||
@ -568,20 +587,20 @@ function! GetPhpIndent()
|
||||
|
||||
let LastLineClosed = 0
|
||||
|
||||
let terminated = '\%(;\%(\s*?>\)\=\|<<<\a\w*\|}\)'.endline
|
||||
let terminated = '\%(;\%(\s*?>\)\=\|<<<''\=\a\w*''\=$\|^\s*}\)'.endline " XXX 0607
|
||||
|
||||
let unstated = '\%(^\s*'.s:blockstart.'.*)\|\%(//.*\)\@<!\<e'.'lse\>\)'.endline
|
||||
|
||||
if ind != b:PHP_default_indenting && cline =~# '^\s*else\%(if\)\=\>'
|
||||
let b:PHP_CurrentIndentLevel = b:PHP_default_indenting
|
||||
return indent(FindTheIfOfAnElse(v:lnum, 1))
|
||||
elseif cline =~ '^\s*{'
|
||||
elseif cline =~ '^\s*)\=\s*{'
|
||||
let previous_line = last_line
|
||||
let last_line_num = lnum
|
||||
|
||||
while last_line_num > 1
|
||||
|
||||
if previous_line =~ '^\s*\%(' . s:blockstart . '\|\%([a-zA-Z]\s*\)*function\)' && previous_line !~ '^\s*[|&]'
|
||||
if previous_line =~ '^\s*\%(' . s:blockstart . '\|\%([a-zA-Z]\s*\)*function\)'
|
||||
|
||||
let ind = indent(last_line_num)
|
||||
|
||||
@ -596,11 +615,11 @@ function! GetPhpIndent()
|
||||
let previous_line = getline(last_line_num)
|
||||
endwhile
|
||||
|
||||
elseif last_line =~# unstated && cline !~ '^\s*{\|^\s*);\='.endline
|
||||
let ind = ind + &sw
|
||||
elseif last_line =~# unstated && cline !~ '^\s*);\='.endline
|
||||
let ind = ind + &sw " we indent one level further when the preceding line is not stated
|
||||
return ind
|
||||
|
||||
elseif ind != b:PHP_default_indenting && last_line =~ terminated
|
||||
elseif (ind != b:PHP_default_indenting || last_line =~ '^)' ) && last_line =~ terminated " Added || last_line =~ '^)' on 2007-12-30 (array indenting [rpblem broke other things)
|
||||
let previous_line = last_line
|
||||
let last_line_num = lnum
|
||||
let LastLineClosed = 1
|
||||
@ -642,7 +661,7 @@ function! GetPhpIndent()
|
||||
endif
|
||||
|
||||
if one_ahead_indent == two_ahead_indent || last_line_num < 1
|
||||
if previous_line =~# '[;}]'.endline || last_line_num < 1
|
||||
if previous_line =~# '\%(;\|^\s*}\)'.endline || last_line_num < 1
|
||||
break
|
||||
endif
|
||||
endif
|
||||
@ -680,8 +699,9 @@ function! GetPhpIndent()
|
||||
let ind = ind + &sw
|
||||
endif
|
||||
|
||||
if b:PHP_BracesAtCodeLevel || cline !~# defaultORcase
|
||||
if b:PHP_BracesAtCodeLevel || b:PHP_vintage_case_default_indent == 1 || cline !~# defaultORcase
|
||||
let b:PHP_CurrentIndentLevel = ind
|
||||
|
||||
return ind
|
||||
endif
|
||||
|
||||
@ -692,21 +712,23 @@ function! GetPhpIndent()
|
||||
if openedparent != lnum
|
||||
let ind = indent(openedparent)
|
||||
endif
|
||||
|
||||
|
||||
elseif cline !~ '^\s*{' && pline =~ '\%(;\%(\s*?>\)\=\|<<<\a\w*\|{\|^\s*'.s:blockstart.'\s*(.*)\)'.endline.'\|^\s*}\|'.defaultORcase
|
||||
|
||||
elseif last_line =~ '^\s*'.s:blockstart
|
||||
let ind = ind + &sw
|
||||
|
||||
elseif last_line =~# defaultORcase
|
||||
let ind = ind + &sw
|
||||
|
||||
|
||||
elseif pline =~ '\%(;\%(\s*?>\)\=\|<<<''\=\a\w*''\=$\|^\s*}\|{\)'.endline . '\|' . defaultORcase
|
||||
|
||||
let ind = ind + &sw
|
||||
endif
|
||||
|
||||
elseif last_line =~# defaultORcase
|
||||
let ind = ind + &sw
|
||||
endif
|
||||
|
||||
if cline =~ '^\s*);\='
|
||||
let ind = ind - &sw
|
||||
elseif cline =~# defaultORcase
|
||||
elseif cline =~# defaultORcase && last_line !~# defaultORcase
|
||||
let ind = ind - &sw
|
||||
|
||||
endif
|
||||
|
||||
@ -34,26 +34,26 @@ set cpo&vim
|
||||
" ============
|
||||
|
||||
" Regex of syntax group names that are or delimit string or are comments.
|
||||
let s:syng_strcom = '\<ruby\%(String\|StringDelimiter\|ASCIICode' .
|
||||
\ '\|Interpolation\|NoInterpolation\|Escape\|Comment\|Documentation\)\>'
|
||||
let s:syng_strcom = '\<ruby\%(String\|StringEscape\|ASCIICode' .
|
||||
\ '\|Interpolation\|NoInterpolation\|Comment\|Documentation\)\>'
|
||||
|
||||
" Regex of syntax group names that are strings.
|
||||
let s:syng_string =
|
||||
\ '\<ruby\%(String\|StringDelimiter\|Interpolation\|NoInterpolation\|Escape\)\>'
|
||||
\ '\<ruby\%(String\|Interpolation\|NoInterpolation\|StringEscape\)\>'
|
||||
|
||||
" Regex of syntax group names that are strings or documentation.
|
||||
let s:syng_stringdoc =
|
||||
\'\<ruby\%(String\|StringDelimiter\|Interpolation\|NoInterpolation\|Escape\|Documentation\)\>'
|
||||
\'\<ruby\%(String\|Interpolation\|NoInterpolation\|StringEscape\|Documentation\)\>'
|
||||
|
||||
" Expression used to check whether we should skip a match with searchpair().
|
||||
let s:skip_expr =
|
||||
\ "synIDattr(synID(line('.'),col('.'),0),'name') =~ '".s:syng_strcom."'"
|
||||
\ "synIDattr(synID(line('.'),col('.'),1),'name') =~ '".s:syng_strcom."'"
|
||||
|
||||
" Regex used for words that, at the start of a line, add a level of indent.
|
||||
let s:ruby_indent_keywords = '^\s*\zs\<\%(module\|class\|def\|if\|for' .
|
||||
\ '\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure' .
|
||||
\ '\|rescue\)\>' .
|
||||
\ '\|\%([*+/,=:-]\|<<\|>>\)\s*\zs' .
|
||||
\ '\|\%([*+/,=-]\|<<\|>>\|:\s\)\s*\zs' .
|
||||
\ '\<\%(if\|for\|while\|until\|case\|unless\|begin\)\>'
|
||||
|
||||
" Regex used for words that, at the start of a line, remove a level of indent.
|
||||
@ -65,7 +65,7 @@ let s:ruby_deindent_keywords =
|
||||
" TODO: the do here should be restricted somewhat (only at end of line)?
|
||||
let s:end_start_regex = '^\s*\zs\<\%(module\|class\|def\|if\|for' .
|
||||
\ '\|while\|until\|case\|unless\|begin\)\>' .
|
||||
\ '\|\%([*+/,=:-]\|<<\|>>\)\s*\zs' .
|
||||
\ '\|\%([*+/,=-]\|<<\|>>\|:\s\)\s*\zs' .
|
||||
\ '\<\%(if\|for\|while\|until\|case\|unless\|begin\)\>' .
|
||||
\ '\|\<do\>'
|
||||
|
||||
@ -78,15 +78,15 @@ let s:end_end_regex = '\%(^\|[^.:@$]\)\@<=\<end\>'
|
||||
" Expression used for searchpair() call for finding match for 'end' keyword.
|
||||
let s:end_skip_expr = s:skip_expr .
|
||||
\ ' || (expand("<cword>") == "do"' .
|
||||
\ ' && getline(".") =~ "^\\s*\\<while\\|until\\|for\\>")'
|
||||
\ ' && getline(".") =~ "^\\s*\\<\\(while\\|until\\|for\\)\\>")'
|
||||
|
||||
" Regex that defines continuation lines, not including (, {, or [.
|
||||
let s:continuation_regex = '\%([\\*+/.,=:-]\|\W[|&?]\|||\|&&\)\s*\%(#.*\)\=$'
|
||||
let s:continuation_regex = '\%([\\*+/.,:]\|\%(<%\)\@<![=-]\|\W[|&?]\|||\|&&\)\s*\%(#.*\)\=$'
|
||||
|
||||
" Regex that defines continuation lines.
|
||||
" TODO: this needs to deal with if ...: and so on
|
||||
let s:continuation_regex2 =
|
||||
\ '\%([\\*+/.,=:({[-]\|\W[|&?]\|||\|&&\)\s*\%(#.*\)\=$'
|
||||
\ '\%([\\*+/.,:({[]\|\%(<%\)\@<![=-]\|\W[|&?]\|||\|&&\)\s*\%(#.*\)\=$'
|
||||
|
||||
" Regex that defines blocks.
|
||||
let s:block_regex =
|
||||
@ -97,17 +97,17 @@ let s:block_regex =
|
||||
|
||||
" Check if the character at lnum:col is inside a string, comment, or is ascii.
|
||||
function s:IsInStringOrComment(lnum, col)
|
||||
return synIDattr(synID(a:lnum, a:col, 0), 'name') =~ s:syng_strcom
|
||||
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_strcom
|
||||
endfunction
|
||||
|
||||
" Check if the character at lnum:col is inside a string.
|
||||
function s:IsInString(lnum, col)
|
||||
return synIDattr(synID(a:lnum, a:col, 0), 'name') =~ s:syng_string
|
||||
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_string
|
||||
endfunction
|
||||
|
||||
" Check if the character at lnum:col is inside a string or documentation.
|
||||
function s:IsInStringOrDocumentation(lnum, col)
|
||||
return synIDattr(synID(a:lnum, a:col, 0), 'name') =~ s:syng_stringdoc
|
||||
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_stringdoc
|
||||
endfunction
|
||||
|
||||
" Find line above 'lnum' that isn't empty, in a comment, or in a string.
|
||||
@ -259,6 +259,11 @@ function GetRubyIndent()
|
||||
" Find a non-blank, non-multi-line string line above the current line.
|
||||
let lnum = s:PrevNonBlankNonString(v:lnum - 1)
|
||||
|
||||
" If the line is empty and inside a string, use the previous line.
|
||||
if line =~ '^\s*$' && lnum != prevnonblank(v:lnum - 1)
|
||||
return indent(prevnonblank(v:lnum))
|
||||
endif
|
||||
|
||||
" At the start of the file use zero indent.
|
||||
if lnum == 0
|
||||
return 0
|
||||
|
||||
39
runtime/indent/sass.vim
Normal file
39
runtime/indent/sass.vim
Normal file
@ -0,0 +1,39 @@
|
||||
" Vim indent file
|
||||
" Language: SASS
|
||||
" Maintainer: Tim Pope <vimNOSPAM@tpope.info>
|
||||
" Last Change: 2007 Dec 16
|
||||
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
endif
|
||||
let b:did_indent = 1
|
||||
|
||||
setlocal autoindent sw=2 et
|
||||
setlocal indentexpr=GetSassIndent()
|
||||
setlocal indentkeys=o,O,*<Return>,<:>,!^F
|
||||
|
||||
" Only define the function once.
|
||||
if exists("*GetSassIndent")
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:property = '^\s*:\|^\s*[[:alnum:]-]\+:'
|
||||
|
||||
function! GetSassIndent()
|
||||
let lnum = prevnonblank(v:lnum-1)
|
||||
let line = substitute(getline(lnum),'\s\+$','','')
|
||||
let cline = substitute(substitute(getline(v:lnum),'\s\+$','',''),'^\s\+','','')
|
||||
let lastcol = strlen(line)
|
||||
let line = substitute(line,'^\s\+','','')
|
||||
let indent = indent(lnum)
|
||||
let cindent = indent(v:lnum)
|
||||
if line !~ s:property && cline =~ s:property
|
||||
return indent + &sw
|
||||
"elseif line =~ s:property && cline !~ s:property
|
||||
"return indent - &sw
|
||||
else
|
||||
return -1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" vim:set sw=2:
|
||||
Reference in New Issue
Block a user