From 2f3935516d1aea7dc3fbd9a45efec4ba9f0b6d50 Mon Sep 17 00:00:00 2001 From: DrSlump Date: Mon, 19 Sep 2011 22:55:46 +0200 Subject: [PATCH 0001/1062] Modified syntax groups regular expressions Instead of targetting the regular expressions to very specific syntax groups (ie: javaScriptDocComment), which make the indent script not compatible with other syntaxes (ie: jsComment), more generic versions are used which should still match the same groups by using case insensitive search and shorter patterns (string, regex and comment). --- indent/javascript.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index b34deee4..dfe2d076 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -33,13 +33,13 @@ set cpo&vim " ============ " Regex of syntax group names that are or delimit string or are comments. -let s:syng_strcom = 'javaScript\%(String\|RegexpString\|CommentTodo\|LineComment\|Comment\|DocComment\)' +let s:syng_strcom = 'string\|regex\|comment\c' " Regex of syntax group names that are strings. -let s:syng_string = 'javaScript\%(RegexpString\)' +let s:syng_string = 'regex\c' " Regex of syntax group names that are strings or documentation. -let s:syng_stringdoc = 'javaScriptDocComment\|javaScriptComment' +let s:syng_stringdoc = 'comment\c' " Expression used to check whether we should skip a match with searchpair(). let s:skip_expr = "synIDattr(synID(line('.'),col('.'),1),'name') =~ '".s:syng_strcom."'" From 2713e881ac4b700789542ec4c8b138c448e6d301 Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Thu, 8 Dec 2011 14:44:08 -0800 Subject: [PATCH 0002/1062] detect .jsm files as javascript --- ftdetect/javascript.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/ftdetect/javascript.vim b/ftdetect/javascript.vim index e0708641..c38c7857 100644 --- a/ftdetect/javascript.vim +++ b/ftdetect/javascript.vim @@ -1,2 +1,3 @@ au BufNewFile,BufRead *.js setf javascript +au BufNewFile,BufRead *.jsm setf javascript au BufNewFile,BufRead Jakefile setf javascript From c0753fe82f7916da3e6100502bc4ecea5974e6de Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Fri, 10 Feb 2012 22:32:41 -0500 Subject: [PATCH 0003/1062] Fix regex character class matching. In Javascript, /[]/ denotes an empty character class (matches nothing), and /[^]/ denotes the negation of an empty character class (matches everything). This differs from languages like Python, which do not allow empty character classes. --- syntax/javascript.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/javascript.vim b/syntax/javascript.vim index 91d25069..bc6feef0 100644 --- a/syntax/javascript.vim +++ b/syntax/javascript.vim @@ -74,7 +74,7 @@ syntax case match syntax match javaScriptSpecial "\\\d\d\d\|\\x\x\{2\}\|\\u\x\{4\}\|\\." syntax region javaScriptStringD start=+"+ skip=+\\\\\|\\$"+ end=+"+ contains=javaScriptSpecial,@htmlPreproc syntax region javaScriptStringS start=+'+ skip=+\\\\\|\\$'+ end=+'+ contains=javaScriptSpecial,@htmlPreproc -syntax region javaScriptRegexpCharClass start=+\[\]\|\[^\]\|\[+ end=+\]+ contained +syntax region javaScriptRegexpCharClass start=+\[+ end=+\]+ contained syntax region javaScriptRegexpString start=+\(\(\(return\|case\)\s\+\)\@<=\|\(\([)\]"']\|\d\|\w\)\s*\)\@\|\<0[xX]\x\+\>/ syntax match javaScriptFloat /\<-\=\%(\d\+\.\d\+\|\d\+\.\|\.\d\+\)\%([eE][+-]\=\d\+\)\=\>/ From e80eb0a995a59600d04c131d56b1361f197aa285 Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Sat, 11 Feb 2012 15:22:41 -0500 Subject: [PATCH 0004/1062] Fix comment typos. --- syntax/javascript.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/syntax/javascript.vim b/syntax/javascript.vim index bc6feef0..f909d1a8 100644 --- a/syntax/javascript.vim +++ b/syntax/javascript.vim @@ -18,13 +18,13 @@ if !exists("main_syntax") let main_syntax = 'javascript' endif -"" Drop fold if it set but VIM doesn't support it. +"" Drop fold if it is set but VIM doesn't support it. let b:javascript_fold='true' if version < 600 " Don't support the old version unlet! b:javascript_fold endif -"" dollar sigh is permittd anywhere in an identifier +"" dollar sign is permittd anywhere in an identifier setlocal iskeyword+=$ syntax sync fromstart @@ -83,7 +83,7 @@ syntax match javaScriptLabel /\(?\s*\)\@ Date: Sat, 11 Feb 2012 15:49:16 -0500 Subject: [PATCH 0005/1062] Improve highlighting of ternary if statements. '?' and ':' are now highlighted, and we no longer treat 'x' as a label in the statement '1 ? a.x : 0'. Some test cases: var a = 1 ? a.x : 0; var a = 1 ? { x: 1 ? a.x : 0, y: 2 } : 0; var a = 1 ? ( 1 ? 1 : 0 ) : 0; --- syntax/javascript.vim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/syntax/javascript.vim b/syntax/javascript.vim index f909d1a8..d347f737 100644 --- a/syntax/javascript.vim +++ b/syntax/javascript.vim @@ -78,7 +78,7 @@ syntax region javaScriptRegexpCharClass start=+\[+ end=+\]+ contained syntax region javaScriptRegexpString start=+\(\(\(return\|case\)\s\+\)\@<=\|\(\([)\]"']\|\d\|\w\)\s*\)\@\|\<0[xX]\x\+\>/ syntax match javaScriptFloat /\<-\=\%(\d\+\.\d\+\|\d\+\.\|\.\d\+\)\%([eE][+-]\=\d\+\)\=\>/ -syntax match javaScriptLabel /\(?\s*\)\@= 508 || !exists("did_javascript_syn_inits") HiLink javaScriptDocParam Label HiLink javaScriptStringS String HiLink javaScriptStringD String + HiLink javaScriptTernaryIfOperator Conditional HiLink javaScriptRegexpString String HiLink javaScriptRegexpCharClass Character HiLink javaScriptCharacter Character From 5267b4f9cb05a06ab5e22801f43e2d449af90eab Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Sat, 11 Feb 2012 21:21:34 -0500 Subject: [PATCH 0006/1062] Handle indent correctly in multi-line comments. Closes #29. --- indent/javascript.vim | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index b34deee4..b85d0147 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -39,7 +39,7 @@ let s:syng_strcom = 'javaScript\%(String\|RegexpString\|CommentTodo\|LineComment let s:syng_string = 'javaScript\%(RegexpString\)' " Regex of syntax group names that are strings or documentation. -let s:syng_stringdoc = 'javaScriptDocComment\|javaScriptComment' +let s:syng_multiline = 'javaScriptDocComment\|javaScriptComment' " Expression used to check whether we should skip a match with searchpair(). let s:skip_expr = "synIDattr(synID(line('.'),col('.'),1),'name') =~ '".s:syng_strcom."'" @@ -71,9 +71,9 @@ function s:IsInString(lnum, col) 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, 1), 'name') =~ s:syng_stringdoc +" Check if the character at lnum:col is inside a multi-line comment. +function s:IsInMultilineComment(lnum, col) + return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_multiline endfunction " Find line above 'lnum' that isn't empty, in a comment, or in a string. @@ -226,7 +226,6 @@ function GetJavascriptIndent() let line = getline(v:lnum) let ind = -1 - " If we got a closing bracket on an empty line, find its match and indent " according to it. For parentheses we indent to its column - 1, for the " others we indent to the containing line's MSL's level. Return -1 if fail. @@ -244,14 +243,9 @@ function GetJavascriptIndent() return ind endif - " If we have a /* or */ set indent to first column. - if match(line, '^\s*\%(/\*\|\*/\)$') != -1 - return 0 - endif - - " If we are in a multi-line string or line-comment, don't do anything to it. - if s:IsInStringOrDocumentation(v:lnum, matchend(line, '^\s*') + 1) - return indent('.') + " If we are in a multi-line comment, cindent does the right thing. + if s:IsInMultilineComment(v:lnum, 1) + return cindent(v:lnum) endif " 3.3. Work on the previous line. {{{2 From 9bc0eb17814028f0529663da68a0beb2898ffa04 Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Sun, 12 Feb 2012 01:59:31 -0500 Subject: [PATCH 0007/1062] Fix indentation after multi-line comments. Closes #28. --- indent/javascript.vim | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index b85d0147..173c51b3 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -251,11 +251,19 @@ function GetJavascriptIndent() " 3.3. Work on the previous line. {{{2 " ------------------------------- + " If the line is empty and the previous nonblank line was a multi-line + " comment, use that comment's indent. Deduct one char to account for the + " space in ' */'. + let nonblank_lnum = prevnonblank(v:lnum - 1) + if line =~ '^\s*$' && s:IsInMultilineComment(nonblank_lnum, 1) + return indent(nonblank_lnum) - 1 + endif + " 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) + if line =~ '^\s*$' && lnum != nonblank_lnum return indent(prevnonblank(v:lnum)) endif From cc074c30d55b5b66d87edb59098ca57fdfb86b31 Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Fri, 17 Feb 2012 22:33:49 -0500 Subject: [PATCH 0008/1062] Fix highlighting in HTML files. Vim's default HTML syntax file colors all Javascript code with the 'Special' group. --- syntax/javascript.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/syntax/javascript.vim b/syntax/javascript.vim index d347f737..f14ef545 100644 --- a/syntax/javascript.vim +++ b/syntax/javascript.vim @@ -253,6 +253,8 @@ endif "syntax clear javaScriptExpression syntax cluster htmlJavaScript contains=@javaScriptAll,javaScriptBracket,javaScriptParen,javaScriptBlock,javaScriptParenError syntax cluster javaScriptExpression contains=@javaScriptAll,javaScriptBracket,javaScriptParen,javaScriptBlock,javaScriptParenError,@htmlPreproc +" Vim's default html.vim highlights all javascript as 'Special' +hi! def link javaScript NONE let b:current_syntax = "javascript" if main_syntax == 'javascript' From a8ce721701fdd015695406f7df315f48bb447ebb Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Sun, 26 Feb 2012 19:56:36 -0500 Subject: [PATCH 0009/1062] Support FF's sticky regex flag. --- syntax/javascript.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/javascript.vim b/syntax/javascript.vim index f14ef545..c2443eb5 100644 --- a/syntax/javascript.vim +++ b/syntax/javascript.vim @@ -75,7 +75,7 @@ syntax match javaScriptSpecial "\\\d\d\d\|\\x\x\{2\}\|\\u\x\{4\}\|\\." syntax region javaScriptStringD start=+"+ skip=+\\\\\|\\$"+ end=+"+ contains=javaScriptSpecial,@htmlPreproc syntax region javaScriptStringS start=+'+ skip=+\\\\\|\\$'+ end=+'+ contains=javaScriptSpecial,@htmlPreproc syntax region javaScriptRegexpCharClass start=+\[+ end=+\]+ contained -syntax region javaScriptRegexpString start=+\(\(\(return\|case\)\s\+\)\@<=\|\(\([)\]"']\|\d\|\w\)\s*\)\@\|\<0[xX]\x\+\>/ syntax match javaScriptFloat /\<-\=\%(\d\+\.\d\+\|\d\+\.\|\.\d\+\)\%([eE][+-]\=\d\+\)\=\>/ syntax match javaScriptLabel /\<\w\+\(\s*:\)\@=/ From 4ff72b7e3e14af09be2a9364bd74d0d00b810658 Mon Sep 17 00:00:00 2001 From: Arnout Kazemier Date: Wed, 29 Feb 2012 13:14:57 +0100 Subject: [PATCH 0010/1062] Added syntax highlighting for `@api` and `@const` in JSDoc comments --- syntax/javascript.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/javascript.vim b/syntax/javascript.vim index c2443eb5..96d3078b 100644 --- a/syntax/javascript.vim +++ b/syntax/javascript.vim @@ -52,11 +52,11 @@ if !exists("javascript_ignore_javaScriptdoc") " tags containing type and param syntax match javaScriptDocTags contained "@\(argument\|param\|property\)\>" nextgroup=javaScriptDocType skipwhite " tags containing type but no param - syntax match javaScriptDocTags contained "@\(type\|return\|returns\)\>" nextgroup=javaScriptDocTypeNoParam skipwhite + syntax match javaScriptDocTags contained "@\(type\|return\|returns\|api\)\>" nextgroup=javaScriptDocTypeNoParam skipwhite " tags containing references syntax match javaScriptDocTags contained "@\(lends\|link\|see\)\>" nextgroup=javaScriptDocSeeTag skipwhite " other tags (no extra syntax) - syntax match javaScriptDocTags contained "@\(access\|addon\|alias\|author\|beta\|constant\|constructor\|copyright\|deprecated\|description\|event\|example\|exec\|field\|fileOverview\|fileoverview\|function\|global\|ignore\|inner\|license\|overview\|private\|protected\|project\|public\|readonly\|since\|static\)\>" + syntax match javaScriptDocTags contained "@\(access\|addon\|alias\|author\|beta\|constant\|const\|constructor\|copyright\|deprecated\|description\|event\|example\|exec\|field\|fileOverview\|fileoverview\|function\|global\|ignore\|inner\|license\|overview\|private\|protected\|project\|public\|readonly\|since\|static\)\>" syntax region javaScriptDocType start="{" end="}" oneline contained nextgroup=javaScriptDocParam skipwhite syntax match javaScriptDocType contained "\%(#\|\"\|\w\|\.\|:\|\/\)\+" nextgroup=javaScriptDocParam skipwhite From 2a84f6399737d1ff5fe0a122bebaed20fb01bc0b Mon Sep 17 00:00:00 2001 From: vxsx Date: Fri, 9 Mar 2012 15:50:43 +0100 Subject: [PATCH 0011/1062] Added syntax highlighting for @methodOf tag --- syntax/javascript.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/javascript.vim b/syntax/javascript.vim index c2443eb5..7a4495c5 100644 --- a/syntax/javascript.vim +++ b/syntax/javascript.vim @@ -48,7 +48,7 @@ if !exists("javascript_ignore_javaScriptdoc") syntax region javaScriptDocComment matchgroup=javaScriptComment start="/\*\*\s*" end="\*/" contains=javaScriptDocTags,javaScriptCommentTodo,javaScriptCvsTag,@javaScriptHtml,@Spell fold " tags containing a param - syntax match javaScriptDocTags contained "@\(augments\|base\|borrows\|class\|constructs\|default\|exception\|exports\|extends\|file\|member\|memberOf\|module\|name\|namespace\|optional\|requires\|title\|throws\|version\)\>" nextgroup=javaScriptDocParam skipwhite + syntax match javaScriptDocTags contained "@\(augments\|base\|borrows\|class\|constructs\|default\|exception\|exports\|extends\|file\|member\|memberOf\|methodOf\|module\|name\|namespace\|optional\|requires\|title\|throws\|version\)\>" nextgroup=javaScriptDocParam skipwhite " tags containing type and param syntax match javaScriptDocTags contained "@\(argument\|param\|property\)\>" nextgroup=javaScriptDocType skipwhite " tags containing type but no param From 97e663fda8d2c6a0204a8816ae00957cc49048ac Mon Sep 17 00:00:00 2001 From: lepture Date: Tue, 5 Jun 2012 12:16:37 +0800 Subject: [PATCH 0012/1062] add readme --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..985c5b76 --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# vim-javascript + +JavaScript bundle for vim, this bundle provides syntax and indent plugins. + +> Indentation of javascript in vim is terrible, and this is the very end of it. + + +## Installation + +- Install with [Vundle](https://github.com/gmarik/vundle) + +If you are not using vundle, you really should have a try. +Edit your vimrc: + + Bundle "pangloss/vim-javascript" + +And install it: + + :so ~/.vimrc + :BundleInstall + + +- Install with [pathogen](https://github.com/tpope/vim-pathogen) + +If you prefer tpope's pathogen, that's ok. Just clone it: + + cd ~/.vim/bundle + git clone https://github.com/pangloss/vim-javascript.git + +## Bug report + +Report a bug on [GitHub Issues](https://github.com/pangloss/vim-javascript/issues). From 3286328a8a21733872595013228d8d634e0eac7b Mon Sep 17 00:00:00 2001 From: lepture Date: Tue, 5 Jun 2012 12:17:08 +0800 Subject: [PATCH 0013/1062] add indent for html --- indent/html.vim | 242 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 242 insertions(+) create mode 100644 indent/html.vim diff --git a/indent/html.vim b/indent/html.vim new file mode 100644 index 00000000..d23f418d --- /dev/null +++ b/indent/html.vim @@ -0,0 +1,242 @@ +" Description: html indenter +" Author: Johannes Zellner +" Modified By: Hsiaoming Yang +" Last Change: Jun, 05 Jun 2012 +" Globals: g:html_indent_tags -- indenting tags +" g:html_indent_strict -- inhibit 'O O' elements +" g:html_indent_strict_table -- inhibit 'O -' elements + +" Only load this indent file when no other was loaded. +"if exists("b:did_indent") +" finish +"endif +"let b:did_indent = 1 + +ru! indent/javascript.vim + + +" [-- local settings (must come before aborting the script) --] +setlocal indentexpr=HtmlIndentGet(v:lnum) +setlocal indentkeys=o,O,*,<>>,{,} + + +if exists('g:html_indent_tags') + unlet g:html_indent_tags +endif + +" [-- helper function to assemble tag list --] +fun! 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 + + +" [-- --] +call HtmlIndentPush('a') +call HtmlIndentPush('abbr') +call HtmlIndentPush('acronym') +call HtmlIndentPush('address') +call HtmlIndentPush('b') +call HtmlIndentPush('bdo') +call HtmlIndentPush('big') +call HtmlIndentPush('blockquote') +call HtmlIndentPush('button') +call HtmlIndentPush('caption') +call HtmlIndentPush('center') +call HtmlIndentPush('cite') +call HtmlIndentPush('code') +call HtmlIndentPush('colgroup') +call HtmlIndentPush('del') +call HtmlIndentPush('dfn') +call HtmlIndentPush('dir') +call HtmlIndentPush('div') +call HtmlIndentPush('dl') +call HtmlIndentPush('em') +call HtmlIndentPush('fieldset') +call HtmlIndentPush('font') +call HtmlIndentPush('form') +call HtmlIndentPush('frameset') +call HtmlIndentPush('h1') +call HtmlIndentPush('h2') +call HtmlIndentPush('h3') +call HtmlIndentPush('h4') +call HtmlIndentPush('h5') +call HtmlIndentPush('h6') +call HtmlIndentPush('i') +call HtmlIndentPush('iframe') +call HtmlIndentPush('ins') +call HtmlIndentPush('kbd') +call HtmlIndentPush('label') +call HtmlIndentPush('legend') +call HtmlIndentPush('map') +call HtmlIndentPush('menu') +call HtmlIndentPush('noframes') +call HtmlIndentPush('noscript') +call HtmlIndentPush('object') +call HtmlIndentPush('ol') +call HtmlIndentPush('optgroup') +" call HtmlIndentPush('pre') +call HtmlIndentPush('q') +call HtmlIndentPush('s') +call HtmlIndentPush('samp') +call HtmlIndentPush('script') +call HtmlIndentPush('select') +call HtmlIndentPush('small') +call HtmlIndentPush('span') +call HtmlIndentPush('strong') +call HtmlIndentPush('style') +call HtmlIndentPush('sub') +call HtmlIndentPush('sup') +call HtmlIndentPush('table') +call HtmlIndentPush('textarea') +call HtmlIndentPush('title') +call HtmlIndentPush('tt') +call HtmlIndentPush('u') +call HtmlIndentPush('ul') +call HtmlIndentPush('var') + + +" [-- --] +if !exists('g:html_indent_strict') + call HtmlIndentPush('body') + call HtmlIndentPush('head') + call HtmlIndentPush('html') + call HtmlIndentPush('tbody') +endif + + +" [-- --] +if !exists('g:html_indent_strict_table') + call HtmlIndentPush('th') + call HtmlIndentPush('td') + call HtmlIndentPush('tr') + call HtmlIndentPush('tfoot') + call HtmlIndentPush('thead') +endif + +delfun HtmlIndentPush + +let s:cpo_save = &cpo +set cpo-=C + +" [-- count indent-increasing tags of line a:lnum --] +fun! HtmlIndentOpen(lnum, pattern) + let s = substitute('x'.getline(a:lnum), + \ '.\{-}\(\(<\)\('.a:pattern.'\)\>\)', "\1", 'g') + let s = substitute(s, "[^\1].*$", '', '') + return strlen(s) +endfun + +" [-- count indent-decreasing tags of line a:lnum --] +fun! HtmlIndentClose(lnum, pattern) + let s = substitute('x'.getline(a:lnum), + \ '.\{-}\(\(<\)/\('.a:pattern.'\)\>>\)', "\1", 'g') + let s = substitute(s, "[^\1].*$", '', '') + return strlen(s) +endfun + +" [-- count indent-increasing '{' of (java|css) line a:lnum --] +fun! HtmlIndentOpenAlt(lnum) + return strlen(substitute(getline(a:lnum), '[^{]\+', '', 'g')) +endfun + +" [-- count indent-decreasing '}' of (java|css) line a:lnum --] +fun! HtmlIndentCloseAlt(lnum) + return strlen(substitute(getline(a:lnum), '[^}]\+', '', 'g')) +endfun + +" [-- return the sum of indents respecting the syntax of a:lnum --] +fun! HtmlIndentSum(lnum, style) + if a:style == match(getline(a:lnum), '^\s*') + let open = HtmlIndentOpen(a:lnum, g:html_indent_tags) + let close = HtmlIndentClose(a:lnum, g:html_indent_tags) + 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), 'name') + \ =~ '\(css\|java\).*' + if a:style == match(getline(a:lnum), '^\s*}') + return HtmlIndentOpenAlt(a:lnum) - HtmlIndentCloseAlt(a:lnum) + endif + endif + return 0 +endfun + +fun! HtmlIndentGet(lnum) + " Find a non-empty line above the current line. + let lnum = prevnonblank(a:lnum - 1) + + " Hit the start of the file, use zero indent. + if lnum == 0 + return 0 + endif + + let restore_ic = &ic + setlocal ic " ignore case + + " [-- special handling for
: no indenting --]
+    if getline(a:lnum) =~ '\c
' + \ || 0 < searchpair('\c
', '', '\c
', 'nWb') + \ || 0 < searchpair('\c
', '', '\c
', 'nW') + " we're in a line with or inside
 ... 
+ if restore_ic == 0 + setlocal noic + endif + return -1 + endif + + " [-- special handling for : use GetJavascriptIndent --] + let js = ', 05 Jun 2006 + " modified by Hsiaoming Yang , 05 Jun 2012 + " GetJavascriptIndent instead of cindent + " + if 0 < searchpair(js, '', '', 'nWb') + \ && 0 < searchpair(js, '', '', 'nW') + " we're inside javascript + if getline(lnum) !~ js && getline(a:lnum) !~ '' + if restore_ic == 0 + setlocal noic + endif + "return cindent(a:lnum) + return GetJavascriptIndent() + endif + endif + + if getline(lnum) =~ '\c' + " line before the current line a:lnum contains + " a closing . --> search for line before + " starting
 to restore the indent.
+	let preline = prevnonblank(search('\c
', 'bW') - 1)
+	if preline > 0
+	    if restore_ic == 0
+	      setlocal noic
+	    endif
+	    return indent(preline)
+	endif
+    endif
+
+    let ind = HtmlIndentSum(lnum, -1)
+    let ind = ind + HtmlIndentSum(a:lnum, 0)
+
+    if restore_ic == 0
+	setlocal noic
+    endif
+
+    return indent(lnum) + (&sw * ind)
+endfun
+
+let &cpo = s:cpo_save
+unlet s:cpo_save
+
+" [-- EOF /indent/html.vim --]

From e4270b2f43c4d3d6c2232422be8cf4e3493b8390 Mon Sep 17 00:00:00 2001
From: lepture 
Date: Tue, 5 Jun 2012 12:21:03 +0800
Subject: [PATCH 0014/1062] add feature section in readme

---
 README.md | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/README.md b/README.md
index 985c5b76..75018665 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,10 @@ JavaScript bundle for vim, this bundle provides syntax and indent plugins.
 
 > Indentation of javascript in vim is terrible, and this is the very end of it.
 
+## Feature
+
+1. very correct indentation for javascript
+2. support javascript indentation in html (provided by [lepture](https://github.com/lepture))
 
 ## Installation
 

From 310c5aa3866a9b4f09dd5c24a5170ef2f41b3f17 Mon Sep 17 00:00:00 2001
From: lepture 
Date: Tue, 5 Jun 2012 14:08:02 +0800
Subject: [PATCH 0015/1062] replace html #48

---
 indent/html.vim | 733 ++++++++++++++++++++++++++++++++++--------------
 1 file changed, 515 insertions(+), 218 deletions(-)

diff --git a/indent/html.vim b/indent/html.vim
index d23f418d..4e9dcfa6 100644
--- a/indent/html.vim
+++ b/indent/html.vim
@@ -1,242 +1,539 @@
-" Description:	html indenter
-" Author:	Johannes Zellner 
-" Modified By: Hsiaoming Yang 
-" Last Change:	Jun, 05 Jun 2012
-" Globals:	g:html_indent_tags	   -- indenting tags
-"		g:html_indent_strict       -- inhibit 'O O' elements
-"		g:html_indent_strict_table -- inhibit 'O -' elements
-
-" Only load this indent file when no other was loaded.
-"if exists("b:did_indent")
-"    finish
-"endif
-"let b:did_indent = 1
+" Vim indent script for HTML
+" General: "{{{
+" File: html.vim (Vimscript #2075)
+" Author: Andy Wokula 
+" Last Change: 2012 Jun 05
+" Last Changed By: Hsiaoming Yang 
+" Version: 0.8
+" Vim Version: Vim7
+" Description:
+"   Improved version of the distributed html indent script, faster on a
+"   range of lines.
+"
+" Customization:
+"   This section is about variables you can set in your vimrc.
+"
+" - You can set the indent for the first line after ', 'nWb')
-    \ && 0 < searchpair(js, '', '', 'nW')
-	" we're inside javascript
-	if getline(lnum) !~ js && getline(a:lnum) !~ ''
-	    if restore_ic == 0
-	      setlocal noic
-	    endif
-	    "return cindent(a:lnum)
-      return GetJavascriptIndent()
-	endif
+    if s:nextrel == 0
+      let s:curind -= 1
+    else
+      let s:nextrel -= 1
     endif
-
-    if getline(lnum) =~ '\c
' - " line before the current line a:lnum contains - " a closing
. --> search for line before - " starting
 to restore the indent.
-	let preline = prevnonblank(search('\c
', 'bW') - 1)
-	if preline > 0
-	    if restore_ic == 0
-	      setlocal noic
-	    endif
-	    return indent(preline)
-	endif
+    " if s:curind >= 1
+    "     let s:curind -= 1
+    " else
+    "     let s:nextrel -= 1
+    " endif
+  elseif ind == 1
+    " opening tag
+    if s:block != 0
+      return "foo"
+    endif
+    let s:nextrel += 1
+  elseif ind != 0
+    " block-tag (opening or closing)
+    return s:Blocktag(a:itag, ind)
+  endif
+  " else ind==0 (other tag found): keep indent
+  return "foo"   " no matter
+endfunc "}}}
+func! s:Blocktag(blocktag, ind) "{{{
+  if a:ind > 0
+    " a block starts here
+    if s:block != 0
+      " already in a block (nesting) - ignore
+      " especially ignore comments after other blocktags
+      return "foo"
+    endif
+    let s:block = a:ind		" block type
+    if s:countonly
+      return "foo"
+    endif
+    let s:newstate.blocklnr = v:lnum
+    " save allover indent for the endtag
+    let s:newstate.blocktagind = b:indent.baseindent + (s:nextrel + s:curind) * &shiftwidth
+    if a:ind == 3
+      return "SCRIPT"    " all except this must be lowercase
+      " line is to be checked again for the type attribute
+    endif
+  else
+    let s:block = 0
+    " we get here if starting and closing block-tag on same line
+  endif
+  return "foo"
+endfunc "}}}
+func! s:GetScriptType(str) "{{{
+  if a:str == "" || a:str =~ "java"
+    return "javascript"
+  else
+    return ""
+  endif
+endfunc "}}}
+
+func! s:FreshState(lnum) "{{{
+  " Look back in the file (lines 1 to a:lnum-1) to calc a state for line
+  " a:lnum.  A state is to know ALL relevant details about the lines
+  " 1..a:lnum-1, initial calculating (here!) can be slow, but updating is
+  " fast (incremental).
+  " State:
+  "	lnum		last indented line == prevnonblank(a:lnum - 1)
+  "	block = 0	a:lnum located within special tag: 0:none, 2:
,
+  "			3: