Update latex, html, ruby, c, cpp

This commit is contained in:
Adam Stankiewicz 2013-10-07 11:07:27 +02:00
parent b3257271db
commit e108a087b4
6 changed files with 63 additions and 36 deletions

View File

@ -51,7 +51,7 @@ autocmd BufNewFile,BufRead *.haml,*.hamlbars setf haml
autocmd BufNewFile,BufRead *.sass setf sass autocmd BufNewFile,BufRead *.sass setf sass
autocmd BufNewFile,BufRead *.scss setf scss autocmd BufNewFile,BufRead *.scss setf scss
if has("autocmd") 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 endif
autocmd BufNewFile,BufReadPost *.jade set filetype=jade autocmd BufNewFile,BufReadPost *.jade set filetype=jade
au BufNewFile,BufRead *.js setf javascript au BufNewFile,BufRead *.js setf javascript

View File

@ -215,7 +215,7 @@ function! LatexBox_View()
if has('win32') if has('win32')
let cmd = '!start /b' . cmd . ' >nul' let cmd = '!start /b' . cmd . ' >nul'
else else
let cmd = '!' . cmd . ' >/dev/null &' let cmd = '!' . cmd . ' &>/dev/null &'
endif endif
silent execute cmd silent execute cmd
if !has("gui_running") if !has("gui_running")

View File

@ -167,6 +167,16 @@ call add(s:tags, 'tr')
call add(s:tags, 'th') call add(s:tags, 'th')
call add(s:tags, 'td') 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') if exists('g:html_exclude_tags')
for tag in g:html_exclude_tags for tag in g:html_exclude_tags
call remove(s:tags, index(s:tags, tag)) call remove(s:tags, index(s:tags, tag))
@ -331,29 +341,35 @@ fun! HtmlIndentGet(lnum)
let ind = ind - 1 let ind = ind - 1
endif endif
if getline(a:lnum) =~ '<p\>' let lind = indent(lnum)
let block_start = search('^'.repeat(' ', ind * &sw).'\S' , 'bnW')
let prev_tag = search('<p\>', 'bW', block_start)
let prev_closetag = search('</p\>', 'W', a:lnum)
if prev_tag && !prev_closetag
let ind = ind - 1
endif
endif
if getline(a:lnum) =~ '</\w\+>' for tags in s:omittable
let block_start = search('^'.repeat(' ', ind * &sw).'\S' , 'bnW') let tags_exp = '<\(' . join(tags, '\|') . '\)>'
let prev_tag = search('<p\>', 'bW', block_start) let close_tags_exp = '</\(' . join(tags, '\|') . '\)>'
let prev_closetag = search('</p\>', 'W', a:lnum) if getline(a:lnum) =~ tags_exp
if prev_tag && !prev_closetag let block_start = search('^'.repeat(' ', lind + (&sw * ind - 1)).'\S' , 'bnW')
let ind = ind - 1 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
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 if restore_ic == 0
setlocal noic setlocal noic
endif endif
return indent(lnum) + (&sw * ind) return lind + (&sw * ind)
endfun endfun
let &cpo = s:cpo_save let &cpo = s:cpo_save

View File

@ -34,7 +34,7 @@ set cpo&vim
" Regex of syntax group names that are or delimit strings/symbols or are comments. " Regex of syntax group names that are or delimit strings/symbols or are comments.
let s:syng_strcom = '\<ruby\%(Regexp\|RegexpDelimiter\|RegexpEscape' . let s:syng_strcom = '\<ruby\%(Regexp\|RegexpDelimiter\|RegexpEscape' .
\ '\|Symbol\|String\|StringDelimiter\|StringEscape\|ASCIICode' . \ '\|Symbol\|String\|StringDelimiter\|StringEscape\|ASCIICode' .
\ '\|Interpolation\|NoInterpolation\|Comment\|Documentation\)\>' \ '\|Interpolation\|InterpolationDelimiter\|NoInterpolation\|Comment\|Documentation\)\>'
" Regex of syntax group names that are strings. " Regex of syntax group names that are strings.
let s:syng_string = let s:syng_string =
@ -175,7 +175,7 @@ function s:GetMSL(lnum)
" something " something
" "
return msl 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) \ s:Match(msl, s:non_bracket_continuation_regex)
" If the current line is a non-bracket continuation and so is the " If the current line is a non-bracket continuation and so is the
" previous one, keep its indent and continue looking for an MSL. " previous one, keep its indent and continue looking for an MSL.
@ -299,18 +299,20 @@ function s:ExtraBrackets(lnum)
endfunction endfunction
function s:Match(lnum, regex) function s:Match(lnum, regex)
let col = match(getline(a:lnum), '\C'.a:regex) + 1 let line = getline(a:lnum)
return col > 0 && !s:IsInStringOrComment(a:lnum, col) ? col : 0 let offset = match(line, '\C'.a:regex)
endfunction let col = offset + 1
function s:MatchLast(lnum, regex) while offset > -1 && s:IsInStringOrComment(a:lnum, col)
let line = getline(a:lnum) let offset = match(line, '\C'.a:regex, offset + 1)
let col = match(line, '.*\zs' . a:regex) let col = offset + 1
while col != -1 && s:IsInStringOrComment(a:lnum, col)
let line = strpart(line, 0, col)
let col = match(line, '.*' . a:regex)
endwhile endwhile
return col + 1
if offset > -1
return col
else
return 0
endif
endfunction endfunction
" 3. GetRubyIndent Function {{{1 " 3. GetRubyIndent Function {{{1

View File

@ -1,7 +1,7 @@
" Vim syntax file " Vim syntax file
" Language: C " Language: C
" Maintainer: Bram Moolenaar <Bram@vim.org> " Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2013 Jun 06 " Last Change: 2013 Jul 05
" Quit when a (custom) syntax file was already loaded " Quit when a (custom) syntax file was already loaded
if exists("b:current_syntax") if exists("b:current_syntax")
@ -11,6 +11,8 @@ endif
let s:cpo_save = &cpo let s:cpo_save = &cpo
set cpo&vim set cpo&vim
let s:ft = matchstr(&ft, '^\([^.]\)\+')
" A bunch of useful C keywords " A bunch of useful C keywords
syn keyword cStatement goto break return continue asm syn keyword cStatement goto break return continue asm
syn keyword cLabel case default syn keyword cLabel case default
@ -110,7 +112,7 @@ endif
" But avoid matching <::. " But avoid matching <::.
syn cluster cParenGroup contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserLabel,cBitField,cOctalZero,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom syn cluster cParenGroup contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserLabel,cBitField,cOctalZero,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom
if exists("c_no_curly_error") if exists("c_no_curly_error")
if &filetype ==# 'cpp' && !exists("cpp_no_cpp11") if s:ft ==# 'cpp' && !exists("cpp_no_cpp11")
syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cCppString,@Spell syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cCppString,@Spell
" cCppParen: same as cParen but ends at end-of-line; used in cDefine " cCppParen: same as cParen but ends at end-of-line; used in cDefine
syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell
@ -124,7 +126,7 @@ if exists("c_no_curly_error")
syn match cErrInParen display contained "^[{}]\|^<%\|^%>" syn match cErrInParen display contained "^[{}]\|^<%\|^%>"
endif endif
elseif exists("c_no_bracket_error") elseif exists("c_no_bracket_error")
if &filetype ==# 'cpp' && !exists("cpp_no_cpp11") if s:ft ==# 'cpp' && !exists("cpp_no_cpp11")
syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cCppString,@Spell syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cCppString,@Spell
" cCppParen: same as cParen but ends at end-of-line; used in cDefine " cCppParen: same as cParen but ends at end-of-line; used in cDefine
syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell
@ -138,7 +140,7 @@ elseif exists("c_no_bracket_error")
syn match cErrInParen display contained "[{}]\|<%\|%>" syn match cErrInParen display contained "[{}]\|<%\|%>"
endif endif
else else
if &filetype ==# 'cpp' && !exists("cpp_no_cpp11") if s:ft ==# 'cpp' && !exists("cpp_no_cpp11")
syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,cCppString,@Spell syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,cCppString,@Spell
" cCppParen: same as cParen but ends at end-of-line; used in cDefine " cCppParen: same as cParen but ends at end-of-line; used in cDefine
syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell
@ -158,7 +160,7 @@ else
syn match cErrInBracket display contained "[);{}]\|<%\|%>" syn match cErrInBracket display contained "[);{}]\|<%\|%>"
endif endif
if &filetype ==# 'c' || exists("cpp_no_cpp11") if s:ft ==# 'c' || exists("cpp_no_cpp11")
syn region cBadBlock keepend start="{" end="}" contained containedin=cParen,cBracket,cBadBlock transparent fold syn region cBadBlock keepend start="{" end="}" contained containedin=cParen,cBracket,cBadBlock transparent fold
endif endif
@ -370,7 +372,7 @@ syn region cPreProc start="^\s*\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>
" Highlight User Labels " Highlight User Labels
syn cluster cMultiGroup contains=cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cCppParen,cCppBracket,cCppString syn cluster cMultiGroup contains=cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cCppParen,cCppBracket,cCppString
if &filetype ==# 'c' || exists("cpp_no_cpp11") if s:ft ==# 'c' || exists("cpp_no_cpp11")
syn region cMulti transparent start='?' skip='::' end=':' contains=ALLBUT,@cMultiGroup,@Spell syn region cMulti transparent start='?' skip='::' end=':' contains=ALLBUT,@cMultiGroup,@Spell
endif endif
" Avoid matching foo::bar() in C++ by requiring that the next char is not ':' " Avoid matching foo::bar() in C++ by requiring that the next char is not ':'
@ -457,6 +459,8 @@ hi def link cCppOut Comment
let b:current_syntax = "c" let b:current_syntax = "c"
unlet s:ft
let &cpo = s:cpo_save let &cpo = s:cpo_save
unlet s:cpo_save unlet s:cpo_save
" vim: ts=8 " vim: ts=8

View File

@ -39,6 +39,9 @@ if !exists("cpp_no_cpp11")
syn keyword cppExceptions noexcept syn keyword cppExceptions noexcept
syn keyword cppStorageClass constexpr decltype syn keyword cppStorageClass constexpr decltype
syn keyword cppConstant nullptr syn keyword cppConstant nullptr
" A C++11 raw-string literal. It tries to follow 2.14.5 and 2.14.5.2 of the
" standard.
syn region cppRawString matchgroup=cppRawDelim start=+\%(u8\=\|[LU]\)\=R"\z(\%([ ()\\\d9-\d12]\@![\d0-\d127]\)\{,16}\)(+ end=+)\z1"+ contains=@Spell
endif endif
" The minimum and maximum operators in GNU C++ " The minimum and maximum operators in GNU C++
@ -62,6 +65,8 @@ if version >= 508 || !exists("did_cpp_syntax_inits")
HiLink cppStructure Structure HiLink cppStructure Structure
HiLink cppBoolean Boolean HiLink cppBoolean Boolean
HiLink cppConstant Constant HiLink cppConstant Constant
HiLink cppRawDelim cFormat
HiLink cppRawString String
delcommand HiLink delcommand HiLink
endif endif