diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index dc3b2e8f..03efb46e 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -51,7 +51,7 @@ autocmd BufNewFile,BufRead *.haml,*.hamlbars setf haml autocmd BufNewFile,BufRead *.sass setf sass autocmd BufNewFile,BufRead *.scss setf scss if has("autocmd") - au BufNewFile,BufRead *.{handlebars,hb,hbs,hbt}{,.erb} set ft=html syntax=handlebars | runtime! ftplugin/handlebars.vim ftplugin/handlebars*.vim ftplugin/handlebars/*.vim + au BufNewFile,BufRead *.{handlebars,hb,hbs,hbt}{,.erb} set ft=handlebars.html syntax=handlebars | runtime! ftplugin/handlebars.vim ftplugin/handlebars*.vim ftplugin/handlebars/*.vim endif autocmd BufNewFile,BufReadPost *.jade set filetype=jade au BufNewFile,BufRead *.js setf javascript diff --git a/ftplugin/latex-box/common.vim b/ftplugin/latex-box/common.vim index 7b62d21c..7df90020 100644 --- a/ftplugin/latex-box/common.vim +++ b/ftplugin/latex-box/common.vim @@ -215,7 +215,7 @@ function! LatexBox_View() if has('win32') let cmd = '!start /b' . cmd . ' >nul' else - let cmd = '!' . cmd . ' >/dev/null &' + let cmd = '!' . cmd . ' &>/dev/null &' endif silent execute cmd if !has("gui_running") diff --git a/indent/html.vim b/indent/html.vim index 6c30555d..d5b7c837 100644 --- a/indent/html.vim +++ b/indent/html.vim @@ -167,6 +167,16 @@ call add(s:tags, 'tr') call add(s:tags, 'th') call add(s:tags, 'td') + + +let s:omittable = [ + \ ['address', 'article', 'aside', 'blockquote', 'dir', 'div', 'dl', 'fieldset', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr', 'menu', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul'], + \ ['dt', 'dd'], + \ ['li'], + \ ['thead', 'tbody', 'tfoot'], + \ ['th', 'td'], + \] + if exists('g:html_exclude_tags') for tag in g:html_exclude_tags call remove(s:tags, index(s:tags, tag)) @@ -331,29 +341,35 @@ fun! HtmlIndentGet(lnum) let ind = ind - 1 endif - if getline(a:lnum) =~ '
' - let block_start = search('^'.repeat(' ', ind * &sw).'\S' , 'bnW') - let prev_tag = search('
', 'bW', block_start) - let prev_closetag = search('
', 'W', a:lnum) - if prev_tag && !prev_closetag - let ind = ind - 1 - endif - endif + let lind = indent(lnum) - if getline(a:lnum) =~ '\w\+>' - let block_start = search('^'.repeat(' ', ind * &sw).'\S' , 'bnW') - let prev_tag = search('', 'bW', block_start) - let prev_closetag = search('
', 'W', a:lnum) - if prev_tag && !prev_closetag - let ind = ind - 1 + for tags in s:omittable + let tags_exp = '<\(' . join(tags, '\|') . '\)>' + let close_tags_exp = '\(' . join(tags, '\|') . '\)>' + if getline(a:lnum) =~ tags_exp + let block_start = search('^'.repeat(' ', lind + (&sw * ind - 1)).'\S' , 'bnW') + let prev_tag = search(tags_exp, 'bW', block_start) + let prev_closetag = search(close_tags_exp, 'W', a:lnum) + if prev_tag && !prev_closetag + let ind = ind - 1 + endif endif - endif + + if getline(a:lnum) =~ '\w\+>' + let block_start = search('^'.repeat(' ', lind + (&sw * ind - 1)).'\S' , 'bnW') + let prev_tag = search(tags_exp, 'bW', block_start) + let prev_closetag = search(close_tags_exp, 'W', a:lnum) + if prev_tag && !prev_closetag + let ind = ind - 1 + endif + endif + endfor if restore_ic == 0 setlocal noic endif - return indent(lnum) + (&sw * ind) + return lind + (&sw * ind) endfun let &cpo = s:cpo_save diff --git a/indent/ruby.vim b/indent/ruby.vim index 095b3a43..c669a1d5 100644 --- a/indent/ruby.vim +++ b/indent/ruby.vim @@ -34,7 +34,7 @@ set cpo&vim " Regex of syntax group names that are or delimit strings/symbols or are comments. let s:syng_strcom = '\' + \ '\|Interpolation\|InterpolationDelimiter\|NoInterpolation\|Comment\|Documentation\)\>' " Regex of syntax group names that are strings. let s:syng_string = @@ -175,7 +175,7 @@ function s:GetMSL(lnum) " something " return msl - elseif s:Match(line, s:non_bracket_continuation_regex) && + elseif s:Match(lnum, s:non_bracket_continuation_regex) && \ s:Match(msl, s:non_bracket_continuation_regex) " If the current line is a non-bracket continuation and so is the " previous one, keep its indent and continue looking for an MSL. @@ -299,18 +299,20 @@ function s:ExtraBrackets(lnum) endfunction function s:Match(lnum, regex) - let col = match(getline(a:lnum), '\C'.a:regex) + 1 - return col > 0 && !s:IsInStringOrComment(a:lnum, col) ? col : 0 -endfunction + let line = getline(a:lnum) + let offset = match(line, '\C'.a:regex) + let col = offset + 1 -function s:MatchLast(lnum, regex) - let line = getline(a:lnum) - let col = match(line, '.*\zs' . a:regex) - while col != -1 && s:IsInStringOrComment(a:lnum, col) - let line = strpart(line, 0, col) - let col = match(line, '.*' . a:regex) + while offset > -1 && s:IsInStringOrComment(a:lnum, col) + let offset = match(line, '\C'.a:regex, offset + 1) + let col = offset + 1 endwhile - return col + 1 + + if offset > -1 + return col + else + return 0 + endif endfunction " 3. GetRubyIndent Function {{{1 diff --git a/syntax/c.vim b/syntax/c.vim index 6a62fe37..7a58ae71 100644 --- a/syntax/c.vim +++ b/syntax/c.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: C " Maintainer: Bram Moolenaar