Browse files

Changed the close tag plugin and fixed once and for all html indentat…

…ion in php I hope.
  • Loading branch information...
1 parent 42ba8a6 commit 044301fdbf97d3afed3453486066eca0fd364ece alessioalex committed May 13, 2011
View
72 vim/bundle/AutoCloseTag/ftplugin/html/autoclose.vim
@@ -1,72 +0,0 @@
-" File: HTML AutoCloseTag.vim
-" Author: Michael Sanders (msanders42 [at] gmail [dot] com)
-" Last Updated: April 7 2009
-" Version: 0.3
-" Description: Automatically closes HTML tag once you finish typing it with >
-
-if exists('b:mapped_auto_closetag') || &cp | finish | endif
-let b:mapped_auto_closetag = 1
-
-ino <buffer> <silent> < <><left>
-ino <buffer> <silent> > <c-r>=<SID>CloseTag()<cr>
-ino <buffer> <expr> <cr> <SID>Return()
-
-if exists('s:did_auto_closetag') | finish | endif
-let s:did_auto_closetag = 1
-
-" Gets the current HTML tag by the cursor.
-fun s:GetCurrentTag()
- return matchstr(matchstr(getline('.'),
- \ '<\zs\(\w\|=\| \|''\|"\)*>\%'.col('.').'c'), '^\a*')
-endf
-
-" Cleanly return after autocompleting an html/xml tag.
-fun s:Return()
- let tag = s:GetCurrentTag()
- return tag != '' && match(getline('.'), '</'.tag.'>') > -1 ?
- \ "\<cr>\<cr>\<up>" : "\<cr>"
-endf
-
-fun s:InComment()
- return stridx(synIDattr(synID(line('.'), col('.')-1, 0), 'name'), 'omment') != -1
-endf
-
-" Counts occurance of needle in page, when not in a comment.
-fun s:CountInPage(needle)
- let pos = [line('.'), col('.')]
- call cursor(1, 1)
- let counter = search(a:needle, 'Wc')
- while search(a:needle, 'W')
- if !s:InComment() | let counter += 1 | endif
- endw
- call cursor(pos)
- return counter
-endf
-
-" Returns whether a closing tag has already been inserted.
-fun s:ClosingTag(tag)
- return s:CountInPage('\c<'.a:tag.'.\{-}>') <= s:CountInPage('\c</'.a:tag.'>')
-endf
-
-" Automatically inserts closing tag after starting tag is typed
-fun s:CloseTag()
- let line = getline('.')
- let col = col('.')
- if line[col-1] != '>' | return '>' | endif
- let col += 1
- call cursor(0, col)
- " Don't autocomplete next to a word or another tag or if inside comment
- if line[col] !~ '\w\|<\|>' && !s:InComment()
- let tag = s:GetCurrentTag()
- " Insert closing tag if tag is not self-closing and has not already
- " been closed
- if tag != '' && tag !~ '\vimg|input|link|meta|br|hr|area|base|param|dd|dt'
- \ && !s:ClosingTag(tag)
- let line = substitute(line, '\%'.col.'c', '</'.escape(tag, '/').'>', '')
- call setline('.', line)
- call cursor(0, col)
- endif
- endif
- return ''
-endf
-" vim:noet:sw=4:ts=4:ft=vim
View
332 vim/bundle/CloseTag/plugin/closetag.vim
@@ -0,0 +1,332 @@
+" File: closetag.vim
+" Summary: Functions and mappings to close open HTML/XML tags
+" Uses: <C-_> -- close matching open tag
+" Author: Steven Mueller <diffusor@ugcs.caltech.edu>
+" Last Modified: Tue May 24 13:29:48 PDT 2005
+" Version: 0.9.1
+" XXX - breaks if close attempted while XIM is in preedit mode
+" TODO - allow usability as a global plugin -
+" Add g:unaryTagsStack - always contains html tags settings
+" and g:closetag_default_xml - user should define this to default to xml
+" When a close is attempted but b:unaryTagsStack undefined,
+" use b:closetag_html_style to determine if the file is to be treated
+" as html or xml. Failing that, check the filetype for xml or html.
+" Finally, default to g:closetag_html_style.
+" If the file is html, let b:unaryTagsStack=g:unaryTagsStack
+" otherwise, let b:unaryTagsStack=""
+" TODO - make matching work for all comments
+" -- kinda works now, but needs syn sync minlines to be very long
+" -- Only check whether in syntax in the beginning, then store comment tags
+" in the tagstacks to determine whether to move into or out of comment mode
+" TODO - The new normal mode mapping clears recent messages with its <ESC>, and
+" it doesn't fix the null-undo issue for vim 5.7 anyway.
+" TODO - make use of the following neat features:
+" -- the ternary ?: operator
+" -- :echomsg and :echoerr
+" -- curly brace expansion for variables and function name definitions?
+" -- check up on map <blah> \FuncName
+"
+" Description:
+" This script eases redundant typing when writing html or xml files (even if
+" you're very good with ctrl-p and ctrl-n :). Hitting ctrl-_ will initiate a
+" search for the most recent open tag above that is not closed in the
+" intervening space and then insert the matching close tag at the cursor. In
+" normal mode, the close tag is inserted one character after cursor rather than
+" at it, as if a<C-_> had been used. This allows putting close tags at the
+" ends of lines while in normal mode, but disallows inserting them in the
+" first column.
+"
+" For HTML, a configurable list of tags are ignored in the matching process.
+" By default, the following tags will not be matched and thus not closed
+" automatically: area, base, br, dd, dt, hr, img, input, link, meta, and
+" param.
+"
+" For XML, all tags must have a closing match or be terminated by />, as in
+" <empty-element/>. These empty element tags are ignored for matching.
+"
+" Comment checking is now handled by vim's internal syntax checking. If tag
+" closing is initiated outside a comment, only tags outside of comments will
+" be matched. When closing tags in comments, only tags within comments will
+" be matched, skipping any non-commented out code (wee!). However, the
+" process of determining the syntax ID of an arbitrary position can still be
+" erroneous if a comment is not detected because the syntax highlighting is
+" out of sync, or really slow if syn sync minlines is large.
+" Set the b:closetag_disable_synID variable to disable this feature if you
+" have really big chunks of comment in your code and closing tags is too slow.
+"
+" If syntax highlighting is not enabled, comments will not be handled very
+" well. Commenting out HTML in certain ways may cause a "tag mismatch"
+" message and no completion. For example, '<!--a href="blah">link!</a-->'
+" between the cursor and the most recent unclosed open tag above causes
+" trouble. Properly matched well formed tags in comments don't cause a
+" problem.
+"
+" Install:
+" To use, place this file in your standard vim scripts directory, and source
+" it while editing the file you wish to close tags in. If the filetype is not
+" set or the file is some sort of template with embedded HTML, you may force
+" HTML style tag matching by first defining the b:closetag_html_style buffer
+" variable. Otherwise, the default is XML style tag matching.
+"
+" Example:
+" :let b:closetag_html_style=1
+" :source ~/.vim/scripts/closetag.vim
+"
+" For greater convenience, load this script in an autocommand:
+" :au Filetype html,xml,xsl source ~/.vim/scripts/closetag.vim
+"
+" Also, set noignorecase for html files or edit b:unaryTagsStack to match your
+" capitalization style. You may set this variable before or after loading the
+" script, or simply change the file itself.
+"
+" Configuration Variables:
+"
+" b:unaryTagsStack Buffer local string containing a whitespace
+" seperated list of element names that should be
+" ignored while finding matching closetags. Checking
+" is done according to the current setting of the
+" ignorecase option.
+"
+" b:closetag_html_style Define this (as with let b:closetag_html_style=1)
+" and source the script again to set the
+" unaryTagsStack to its default value for html.
+"
+" b:closetag_disable_synID Define this to disable comment checking if tag
+" closing is too slow. This can be set or unset
+" without having to source again.
+"
+" Changelog:
+" May 24, 2005 Tuesday
+" * Changed function names to be script-local to avoid conflicts with other
+" scripts' stack implementations.
+"
+" June 07, 2001 Thursday
+" * Added comment handling. Currently relies on synID, so if syn sync
+" minlines is small, the chance for failure is high, but if minlines is
+" large, tagclosing becomes rather slow...
+"
+" * Changed normal mode closetag mapping to use <C-R> in insert mode
+" rather than p in normal mode. This has 2 implications:
+" - Tag closing no longer clobbers the unnamed register
+" - When tag closing fails or finds no match, no longer adds to the undo
+" buffer for recent vim 6.0 development versions.
+" - However, clears the last message when closing tags in normal mode
+"
+" * Changed the closetag_html_style variable to be buffer-local rather than
+" global.
+"
+" * Expanded documentation
+
+"------------------------------------------------------------------------------
+" User configurable settings
+"------------------------------------------------------------------------------
+
+" if html, don't close certain tags. Works best if ignorecase is set.
+" otherwise, capitalize these elements according to your html editing style
+if !exists("b:unaryTagsStack") || exists("b:closetag_html_style")
+ if &filetype == "html" || exists("b:closetag_html_style")
+ let b:unaryTagsStack="area base br dd dt hr img input link meta param"
+ else " for xsl and xsl
+ let b:unaryTagsStack=""
+ endif
+endif
+
+let b:unaryTagsStack="area base br dd dt hr img input link meta param"
+
+" Has this already been loaded?
+if exists("loaded_closetag")
+ finish
+endif
+let loaded_closetag=1
+
+" set up mappings for tag closing
+inoremap <C-_> <C-R>=GetCloseTag()<CR>
+map <C-_> a<C-_><ESC>
+
+"------------------------------------------------------------------------------
+" Tag closer - uses the stringstack implementation below
+"------------------------------------------------------------------------------
+
+" Returns the most recent unclosed tag-name
+" (ignores tags in the variable referenced by a:unaryTagsStack)
+function! GetLastOpenTag(unaryTagsStack)
+ " Search backwards through the file line by line using getline()
+ " Overall strategy (moving backwards through the file from the cursor):
+ " Push closing tags onto a stack.
+ " On an opening tag, if the tag matches the stack top, discard both.
+ " -- if the tag doesn't match, signal an error.
+ " -- if the stack is empty, use this tag
+ let linenum=line(".")
+ let lineend=col(".") - 1 " start: cursor position
+ let first=1 " flag for first line searched
+ let b:TagStack="" " main stack of tags
+ let startInComment=s:InComment()
+
+ let tagpat='</\=\(\k\|[-:]\)\+\|/>'
+ " Search for: closing tags </tag, opening tags <tag, and unary tag ends />
+ while (linenum>0)
+ " Every time we see an end-tag, we push it on the stack. When we see an
+ " open tag, if the stack isn't empty, we pop it and see if they match.
+ " If no, signal an error.
+ " If yes, continue searching backwards.
+ " If stack is empty, return this open tag as the one that needs closing.
+ let line=getline(linenum)
+ if first
+ let line=strpart(line,0,lineend)
+ else
+ let lineend=strlen(line)
+ endif
+ let b:lineTagStack=""
+ let mpos=0
+ let b:TagCol=0
+ " Search the current line in the forward direction, pushing any tags
+ " onto a special stack for the current line
+ while (mpos > -1)
+ let mpos=matchend(line,tagpat)
+ if mpos > -1
+ let b:TagCol=b:TagCol+mpos
+ let tag=matchstr(line,tagpat)
+
+ if exists("b:closetag_disable_synID") || startInComment==s:InCommentAt(linenum, b:TagCol)
+ let b:TagLine=linenum
+ call s:Push(matchstr(tag,'[^<>]\+'),"b:lineTagStack")
+ endif
+ "echo "Tag: ".tag." ending at position ".mpos." in '".line."'."
+ let lineend=lineend-mpos
+ let line=strpart(line,mpos,lineend)
+ endif
+ endwhile
+ " Process the current line stack
+ while (!s:EmptystackP("b:lineTagStack"))
+ let tag=s:Pop("b:lineTagStack")
+ if match(tag, "^/") == 0 "found end tag
+ call s:Push(tag,"b:TagStack")
+ "echo linenum." ".b:TagStack
+ elseif s:EmptystackP("b:TagStack") && !s:Instack(tag, a:unaryTagsStack) "found unclosed tag
+ return tag
+ else
+ let endtag=s:Peekstack("b:TagStack")
+ if endtag == "/".tag || endtag == "/"
+ call s:Pop("b:TagStack") "found a open/close tag pair
+ "echo linenum." ".b:TagStack
+ elseif !s:Instack(tag, a:unaryTagsStack) "we have a mismatch error
+ echohl Error
+ echon "\rError:"
+ echohl None
+ echo " tag mismatch: <".tag."> doesn't match <".endtag.">. (Line ".linenum." Tagstack: ".b:TagStack.")"
+ return ""
+ endif
+ endif
+ endwhile
+ let linenum=linenum-1 | let first=0
+ endwhile
+ " At this point, we have exhausted the file and not found any opening tag
+ echo "No opening tags."
+ return ""
+endfunction
+
+" Returns closing tag for most recent unclosed tag, respecting the
+" current setting of b:unaryTagsStack for tags that should not be closed
+
+let b:unaryTagsStack="area base br dd dt hr img input link meta param"
+
+function! GetCloseTag()
+ let tag=GetLastOpenTag("b:unaryTagsStack")
+ if tag == ""
+ return ""
+ else
+ return "</".tag.">"
+ endif
+endfunction
+
+" return 1 if the cursor is in a syntactically identified comment field
+" (fails for empty lines: always returns not-in-comment)
+function! s:InComment()
+ return synIDattr(synID(line("."), col("."), 0), "name") =~ 'Comment'
+endfunction
+
+" return 1 if the position specified is in a syntactically identified comment field
+function! s:InCommentAt(line, col)
+ return synIDattr(synID(a:line, a:col, 0), "name") =~ 'Comment'
+endfunction
+
+"------------------------------------------------------------------------------
+" String Stacks
+"------------------------------------------------------------------------------
+" These are strings of whitespace-separated elements, matched using the \< and
+" \> patterns after setting the iskeyword option.
+"
+" The sname argument should contain a symbolic reference to the stack variable
+" on which method should operate on (i.e., sname should be a string containing
+" a fully qualified (ie: g:, b:, etc) variable name.)
+
+" Helper functions
+function! s:SetKeywords()
+ let g:IsKeywordBak=&iskeyword
+ let &iskeyword="33-255"
+endfunction
+
+function! s:RestoreKeywords()
+ let &iskeyword=g:IsKeywordBak
+endfunction
+
+" Push el onto the stack referenced by sname
+function! s:Push(el, sname)
+ if !s:EmptystackP(a:sname)
+ exe "let ".a:sname."=a:el.' '.".a:sname
+ else
+ exe "let ".a:sname."=a:el"
+ endif
+endfunction
+
+" Check whether the stack is empty
+function! s:EmptystackP(sname)
+ exe "let stack=".a:sname
+ if match(stack,"^ *$") == 0
+ return 1
+ else
+ return 0
+ endif
+endfunction
+
+" Return 1 if el is in stack sname, else 0.
+function! s:Instack(el, sname)
+ exe "let stack=".a:sname
+ call s:SetKeywords()
+ let m=match(stack, "\\<".a:el."\\>")
+ call s:RestoreKeywords()
+ if m < 0
+ return 0
+ else
+ return 1
+ endif
+endfunction
+
+" Return the first element in the stack
+function! s:Peekstack(sname)
+ call s:SetKeywords()
+ exe "let stack=".a:sname
+ let top=matchstr(stack, "\\<.\\{-1,}\\>")
+ call s:RestoreKeywords()
+ return top
+endfunction
+
+" Remove and return the first element in the stack
+function! s:Pop(sname)
+ if s:EmptystackP(a:sname)
+ echo "Error! Stack ".a:sname." is empty and can't be popped."
+ return ""
+ endif
+ exe "let stack=".a:sname
+ " Find the first space, loc is 0-based. Marks the end of 1st elt in stack.
+ call s:SetKeywords()
+ let loc=matchend(stack,"\\<.\\{-1,}\\>")
+ exe "let ".a:sname."=strpart(stack, loc+1, strlen(stack))"
+ let top=strpart(stack, match(stack, "\\<"), loc)
+ call s:RestoreKeywords()
+ return top
+endfunction
+
+function! s:Clearstack(sname)
+ exe "let ".a:sname."=''"
+endfunction
View
40 vim/bundle/phpHtmlIndent/indent/php.vim
@@ -1,40 +0,0 @@
-" Better indent support for PHP by making it possible to indent HTML sections
-" as well.
-if exists("b:did_indent")
- finish
-endif
-
-" This script pulls in the default indent/php.vim with the :runtime command
-" which could re-run this script recursively unless we catch that:
-if exists('s:doing_indent_inits')
- finish
-endif
-let s:doing_indent_inits = 1
-runtime! indent/html.vim
-unlet b:did_indent
-runtime! indent/php.vim
-unlet s:doing_indent_inits
-
-function! GetPhpHtmlIndent(lnum)
- if exists('*HtmlIndent')
- let html_ind = HtmlIndent()
- else
- let html_ind = HtmlIndentGet(a:lnum)
- endif
- let php_ind = GetPhpIndent()
- " priority one for php indent script
- if php_ind > -1
- return php_ind
- endif
- if html_ind > -1
- if getline(a:num) =~ "^<?" && (0< searchpair('<?', '', '?>', 'nWb')
- \ || 0 < searchpair('<?', '', '?>', 'nW'))
- return -1
- endif
- return html_ind
- endif
- return -1
-endfunction
-
-setlocal indentexpr=GetPhpHtmlIndent(v:lnum)
-setlocal indentkeys+=<>>
View
272 vim/bundle/web-indent/indent/php.vim
@@ -0,0 +1,272 @@
+" Vim indent file
+" Language: Php
+" Authors: Miles Lott <milos@groupwhere.org>, Johannes Zellner <johannes@zellner.org>, Pim Snel <pim@lingewoud.nl>
+" URL: http://lingewoud.nl/downloads.php
+" Last Change: 23 feb 2004
+" Version: 0.3
+" Notes: This is a combination of the PHP indent file of Miles Lott with
+" the HTML indent file of Johannes Zellner. Usefull for editing
+" php-files with html parts in it.
+"
+" Changelog:
+" 0.3 - 25 mar 2004
+" - fixed wrong indention when a php-tag is opened and closed on
+" one single line.
+" 0.2 - 23 feb 2004
+" - applied patch from Holger Dzeik <dzeik@nentec.de>
+" - added changelog
+" - added default indention of 3 spaces after the <?php for better
+" reading
+" - replaced URL
+" - reformatted the options section
+" 0.1 - 27 mar 2003
+" - initial creation of html-enhanced php indent-file
+
+" Options:
+let php_noindent_switch=0 " set this to '1' to not try to indent switch/case statements
+set sw=3 " default shiftwidth of 3 spaces
+
+
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=GetPhpIndent()
+"setlocal indentkeys+=0=,0),=EO
+setlocal indentkeys+=0=,0),=EO,o,O,*<Return>,<>>,<bs>,{,}
+
+" Only define the function once.
+if exists("*GetPhpIndent")
+ finish
+endif
+
+" Handle option(s)
+if exists("php_noindent_switch")
+ let b:php_noindent_switch=1
+endif
+
+if exists('g:html_indent_tags')
+ unlet g:html_indent_tags
+endif
+
+function GetPhpIndent()
+ " Find a non-empty 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 line = getline(lnum) " last line
+ let cline = getline(v:lnum) " current line
+ let pline = getline(lnum - 1) " previous to last line
+ let ind = indent(lnum)
+
+ let restore_ic=&ic
+ let &ic=1 " ignore case
+
+ let ind = <SID>HtmlIndentSum(lnum, -1)
+ let ind = ind + <SID>HtmlIndentSum(v:lnum, 0)
+
+ let &ic=restore_ic
+
+ let ind = indent(lnum) + (&sw * ind)
+
+ " Indent after php open tags
+ if line =~ '<?php' && line !~ '?>'
+ let ind = ind + &sw
+ endif
+ if cline =~ '^\s*[?>]' " // Fix from Holger Dzeik <dzeik@nentec.de> Thanks!
+ let ind = ind - &sw
+ endif
+
+
+ if exists("b:php_noindent_switch") " version 1 behavior, diy switch/case,etc
+ " Indent blocks enclosed by {} or ()
+ if line =~ '[{(]\s*\(#[^)}]*\)\=$'
+ let ind = ind + &sw
+ endif
+ if cline =~ '^\s*[)}]'
+ let ind = ind - &sw
+ endif
+ return ind
+ else " Try to indent switch/case statements as well
+ " Indent blocks enclosed by {} or () or case statements, with some anal requirements
+ if line =~ 'case.*:\|[{(]\s*\(#[^)}]*\)\=$'
+ let ind = ind + &sw
+ " return if the current line is not another case statement of the previous line is a bracket open
+ if cline !~ '.*case.*:\|default:' || line =~ '[{(]\s*\(#[^)}]*\)\=$'
+ return ind
+ endif
+ endif
+ if cline =~ '^\s*case.*:\|^\s*default:\|^\s*[)}]'
+ let ind = ind - &sw
+ " if the last line is a break or return, or the current line is a close bracket,
+ " or if the previous line is a default statement, subtract another
+ if line =~ '^\s*break;\|^\s*return\|' && cline =~ '^\s*[)}]' && pline =~ 'default:'
+ let ind = ind - &sw
+ endif
+ endif
+
+ if line =~ 'default:'
+ let ind = ind + &sw
+ endif
+ return ind
+ endif
+endfunction
+
+
+" [-- local settings (must come before aborting the script) --]
+"setlocal indentexpr=HtmlIndentGet(v:lnum)
+"setlocal indentkeys=o,O,*<Return>,<>>,<bs>,{,}
+
+
+
+" [-- helper function to assemble tag list --]
+fun! <SID>HtmlIndentPush(tag)
+ if exists('g:html_indent_tags')
+ let g:html_indent_tags = g:html_indent_tags.'\|'.a:tag
+ else
+ let g:html_indent_tags = a:tag
+ endif
+endfun
+
+
+" [-- <ELEMENT ? - - ...> --]
+call <SID>HtmlIndentPush('a')
+call <SID>HtmlIndentPush('abbr')
+call <SID>HtmlIndentPush('acronym')
+call <SID>HtmlIndentPush('address')
+call <SID>HtmlIndentPush('b')
+call <SID>HtmlIndentPush('bdo')
+call <SID>HtmlIndentPush('big')
+call <SID>HtmlIndentPush('blockquote')
+call <SID>HtmlIndentPush('button')
+call <SID>HtmlIndentPush('caption')
+call <SID>HtmlIndentPush('center')
+call <SID>HtmlIndentPush('cite')
+call <SID>HtmlIndentPush('code')
+call <SID>HtmlIndentPush('colgroup')
+call <SID>HtmlIndentPush('del')
+call <SID>HtmlIndentPush('dfn')
+call <SID>HtmlIndentPush('dir')
+call <SID>HtmlIndentPush('div')
+call <SID>HtmlIndentPush('dl')
+call <SID>HtmlIndentPush('em')
+call <SID>HtmlIndentPush('fieldset')
+call <SID>HtmlIndentPush('font')
+call <SID>HtmlIndentPush('form')
+call <SID>HtmlIndentPush('frameset')
+call <SID>HtmlIndentPush('h1')
+call <SID>HtmlIndentPush('h2')
+call <SID>HtmlIndentPush('h3')
+call <SID>HtmlIndentPush('h4')
+call <SID>HtmlIndentPush('h5')
+call <SID>HtmlIndentPush('h6')
+call <SID>HtmlIndentPush('i')
+call <SID>HtmlIndentPush('iframe')
+call <SID>HtmlIndentPush('ins')
+call <SID>HtmlIndentPush('kbd')
+call <SID>HtmlIndentPush('label')
+call <SID>HtmlIndentPush('legend')
+call <SID>HtmlIndentPush('map')
+call <SID>HtmlIndentPush('menu')
+call <SID>HtmlIndentPush('noframes')
+call <SID>HtmlIndentPush('noscript')
+call <SID>HtmlIndentPush('object')
+call <SID>HtmlIndentPush('ol')
+call <SID>HtmlIndentPush('optgroup')
+call <SID>HtmlIndentPush('pre')
+call <SID>HtmlIndentPush('q')
+call <SID>HtmlIndentPush('s')
+call <SID>HtmlIndentPush('samp')
+call <SID>HtmlIndentPush('script')
+call <SID>HtmlIndentPush('select')
+call <SID>HtmlIndentPush('small')
+call <SID>HtmlIndentPush('span')
+call <SID>HtmlIndentPush('strong')
+call <SID>HtmlIndentPush('style')
+call <SID>HtmlIndentPush('sub')
+call <SID>HtmlIndentPush('sup')
+call <SID>HtmlIndentPush('table')
+call <SID>HtmlIndentPush('textarea')
+call <SID>HtmlIndentPush('title')
+call <SID>HtmlIndentPush('tt')
+call <SID>HtmlIndentPush('u')
+call <SID>HtmlIndentPush('ul')
+call <SID>HtmlIndentPush('var')
+
+
+" [-- <ELEMENT ? O O ...> --]
+if !exists('g:html_indent_strict')
+ call <SID>HtmlIndentPush('body')
+ call <SID>HtmlIndentPush('head')
+ call <SID>HtmlIndentPush('html')
+ call <SID>HtmlIndentPush('tbody')
+endif
+
+
+" [-- <ELEMENT ? O - ...> --]
+if !exists('g:html_indent_strict_table')
+ call <SID>HtmlIndentPush('th')
+ call <SID>HtmlIndentPush('td')
+ call <SID>HtmlIndentPush('tr')
+ call <SID>HtmlIndentPush('tfoot')
+ call <SID>HtmlIndentPush('thead')
+endif
+
+delfun <SID>HtmlIndentPush
+
+set cpo-=C
+
+" [-- count indent-increasing tags of line a:lnum --]
+fun! <SID>HtmlIndentOpen(lnum)
+ let s = substitute('x'.getline(a:lnum),
+ \ '.\{-}\(\(<\)\('.g:html_indent_tags.'\)\>\)', "\1", 'g')
+ let s = substitute(s, "[^\1].*$", '', '')
+ return strlen(s)
+endfun
+
+" [-- count indent-decreasing tags of line a:lnum --]
+fun! <SID>HtmlIndentClose(lnum)
+ let s = substitute('x'.getline(a:lnum),
+ \ '.\{-}\(\(<\)/\('.g:html_indent_tags.'\)\>>\)', "\1", 'g')
+ let s = substitute(s, "[^\1].*$", '', '')
+ return strlen(s)
+endfun
+
+" [-- count indent-increasing '{' of (java|css) line a:lnum --]
+fun! <SID>HtmlIndentOpenAlt(lnum)
+ return strlen(substitute(getline(a:lnum), '[^{]\+', '', 'g'))
+endfun
+
+" [-- count indent-decreasing '}' of (java|css) line a:lnum --]
+fun! <SID>HtmlIndentCloseAlt(lnum)
+ return strlen(substitute(getline(a:lnum), '[^}]\+', '', 'g'))
+endfun
+
+" [-- return the sum of indents respecting the syntax of a:lnum --]
+fun! <SID>HtmlIndentSum(lnum, style)
+ if a:style == match(getline(a:lnum), '^\s*</')
+ if a:style == match(getline(a:lnum), '^\s*</\<\('.g:html_indent_tags.'\)\>')
+ let open = <SID>HtmlIndentOpen(a:lnum)
+ let close = <SID>HtmlIndentClose(a:lnum)
+ if 0 != open || 0 != close
+ return open - close
+ endif
+ endif
+ endif
+ if '' != &syntax &&
+ \ synIDattr(synID(a:lnum, 1, 1), 'name') =~ '\(css\|java\).*' &&
+ \ synIDattr(synID(a:lnum, strlen(getline(a:lnum)) - 1, 1), 'name')
+ \ =~ '\(css\|java\).*'
+ if a:style == match(getline(a:lnum), '^\s*}')
+ return <SID>HtmlIndentOpenAlt(a:lnum) - <SID>HtmlIndentCloseAlt(a:lnum)
+ endif
+ endif
+ return 0
+endfun
+
+" vim: set ts=3 sw=3:
View
6 vim/includes/plugin_settings.vim
@@ -1,8 +1,8 @@
" All plugin customizations should be placed here {
"
- " AutoCloseTag {
- " Make it so AutoCloseTag works for xml and xhtml files as well
- au FileType xhtml,xml ru ftplugin/html/autoclosetag.vim
+ " CloseTag {
+ au FileType * let b:unaryTagsStack=""
+ let g:closetag_html_style=1
" }
" DelimitMate {
View
12 vimrc
@@ -13,12 +13,6 @@
endif
" }
- " Setup Bundle Support {
- " The next two lines ensure that the ~/.vim/bundle/ system works
- call pathogen#runtime_append_all_bundles()
- call pathogen#helptags()
- " }
-
" Includes {
" Custom functions library
@@ -31,6 +25,12 @@
source $HOME/.vim/includes/plugin_settings.vim
" }
+ " Setup Bundle Support {
+ " The next two lines ensure that the ~/.vim/bundle/ system works
+ call pathogen#runtime_append_all_bundles()
+ call pathogen#helptags()
+ " }
+
" }
" General {

0 comments on commit 044301f

Please sign in to comment.