mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-09 12:03:53 -05:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
acd7ce5950 | ||
|
|
f24fecc338 |
2
build
2
build
@@ -93,7 +93,7 @@ PACKS="
|
|||||||
jade:digitaltoad/vim-jade
|
jade:digitaltoad/vim-jade
|
||||||
jasmine:glanotte/vim-jasmine
|
jasmine:glanotte/vim-jasmine
|
||||||
javascript:pangloss/vim-javascript
|
javascript:pangloss/vim-javascript
|
||||||
json:leshill/vim-json
|
json:sheerun/vim-json
|
||||||
jst:briancollins/vim-jst
|
jst:briancollins/vim-jst
|
||||||
latex:LaTeX-Box-Team/LaTeX-Box
|
latex:LaTeX-Box-Team/LaTeX-Box
|
||||||
less:groenewege/vim-less
|
less:groenewege/vim-less
|
||||||
|
|||||||
@@ -76,12 +76,7 @@ fun! s:SelectJavascript()
|
|||||||
endfun
|
endfun
|
||||||
au BufNewFile,BufRead * call s:SelectJavascript()
|
au BufNewFile,BufRead * call s:SelectJavascript()
|
||||||
autocmd BufNewFile,BufRead *.json set filetype=json
|
autocmd BufNewFile,BufRead *.json set filetype=json
|
||||||
augroup json_autocmd
|
autocmd BufNewFile,BufRead *.jsonp set filetype=json
|
||||||
autocmd!
|
|
||||||
autocmd FileType json setlocal autoindent
|
|
||||||
autocmd FileType json setlocal formatoptions=tcq2l
|
|
||||||
autocmd FileType json setlocal foldmethod=syntax
|
|
||||||
augroup END
|
|
||||||
au BufNewFile,BufRead *.ejs set filetype=jst
|
au BufNewFile,BufRead *.ejs set filetype=jst
|
||||||
au BufNewFile,BufRead *.jst set filetype=jst
|
au BufNewFile,BufRead *.jst set filetype=jst
|
||||||
au BufNewFile,BufRead *.hamljs set filetype=jst
|
au BufNewFile,BufRead *.hamljs set filetype=jst
|
||||||
@@ -202,6 +197,7 @@ au BufNewFile,BufRead *.timer set filetype=systemd
|
|||||||
au BufRead,BufNewFile *.textile set filetype=textile
|
au BufRead,BufNewFile *.textile set filetype=textile
|
||||||
au BufNewFile,BufRead *.thrift setlocal filetype=thrift
|
au BufNewFile,BufRead *.thrift setlocal filetype=thrift
|
||||||
autocmd BufNewFile,BufRead {.,}tmux.conf{.*,} setlocal filetype=tmux
|
autocmd BufNewFile,BufRead {.,}tmux.conf{.*,} setlocal filetype=tmux
|
||||||
|
autocmd BufNewFile,BufRead {.,}tmux.conf{.*,} setlocal commentstring=#\ %s
|
||||||
autocmd BufNewFile,BufRead *.toml set filetype=toml
|
autocmd BufNewFile,BufRead *.toml set filetype=toml
|
||||||
autocmd BufNewFile,BufRead Cargo.lock set filetype=toml
|
autocmd BufNewFile,BufRead Cargo.lock set filetype=toml
|
||||||
autocmd BufNewFile,BufRead *.twig set filetype=twig
|
autocmd BufNewFile,BufRead *.twig set filetype=twig
|
||||||
|
|||||||
@@ -10,35 +10,19 @@ endif
|
|||||||
|
|
||||||
let g:tagbar_type_scala = {
|
let g:tagbar_type_scala = {
|
||||||
\ 'ctagstype' : 'scala',
|
\ 'ctagstype' : 'scala',
|
||||||
|
\ 'sro' : '.',
|
||||||
\ 'kinds' : [
|
\ 'kinds' : [
|
||||||
\ 'p:packages:1',
|
\ 'p:packages',
|
||||||
\ 'V:values',
|
\ 'T:types:1',
|
||||||
\ 'v:variables',
|
|
||||||
\ 'T:types',
|
|
||||||
\ 't:traits',
|
\ 't:traits',
|
||||||
\ 'o:objects',
|
\ 'o:objects',
|
||||||
\ 'a:aclasses',
|
\ 'O:case objects',
|
||||||
\ 'c:classes',
|
\ 'c:classes',
|
||||||
\ 'r:cclasses',
|
\ 'C:case classes',
|
||||||
\ 'm:methods'
|
\ 'm:methods',
|
||||||
\ ],
|
\ 'V:values:1',
|
||||||
\ 'sro' : '.',
|
\ 'v:variables:1'
|
||||||
\ 'kind2scope' : {
|
\ ]
|
||||||
\ 'T' : 'type',
|
|
||||||
\ 't' : 'trait',
|
|
||||||
\ 'o' : 'object',
|
|
||||||
\ 'a' : 'abstract class',
|
|
||||||
\ 'c' : 'class',
|
|
||||||
\ 'r' : 'case class'
|
|
||||||
\ },
|
|
||||||
\ 'scope2kind' : {
|
|
||||||
\ 'type' : 'T',
|
|
||||||
\ 'trait' : 't',
|
|
||||||
\ 'object' : 'o',
|
|
||||||
\ 'abstract class' : 'a',
|
|
||||||
\ 'class' : 'c',
|
|
||||||
\ 'case class' : 'r'
|
|
||||||
\ }
|
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
" In case you've updated/customized your ~/.ctags and prefer to use it.
|
" In case you've updated/customized your ~/.ctags and prefer to use it.
|
||||||
|
|||||||
@@ -1,2 +1,19 @@
|
|||||||
|
if exists("b:did_ftplugin")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let b:did_ftplugin = 1
|
||||||
|
|
||||||
|
let s:cpo_save = &cpo
|
||||||
|
set cpo-=C
|
||||||
|
|
||||||
compiler typescript
|
compiler typescript
|
||||||
setlocal commentstring=//\ %s
|
setlocal commentstring=//\ %s
|
||||||
|
|
||||||
|
" Set 'formatoptions' to break comment lines but not other lines,
|
||||||
|
" " and insert the comment leader when hitting <CR> or using "o".
|
||||||
|
setlocal formatoptions-=t formatoptions+=croql
|
||||||
|
|
||||||
|
let b:undo_ftplugin = "setl fo< ofu< com< cms<"
|
||||||
|
|
||||||
|
let &cpo = s:cpo_save
|
||||||
|
unlet s:cpo_save
|
||||||
|
|||||||
169
indent/json.vim
Normal file
169
indent/json.vim
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
" Vim indent file
|
||||||
|
" Language: JSON
|
||||||
|
" Mantainer: Eli Parra <eli@elzr.com> https://github.com/elzr/vim-json
|
||||||
|
" Last Change: 2014-05-13: merged Fix for square bracket matching by Jakar
|
||||||
|
" https://github.com/jakar/vim-json/commit/20b650e22aa750c4ab6a66aa646bdd95d7cd548a#diff-e81fc111b2052e306d126bd9989f7b7c
|
||||||
|
" Original Author: Rogerz Zhang <rogerz.zhang at gmail.com> http://github.com/rogerz/vim-json
|
||||||
|
" Acknowledgement: Based off of vim-javascript maintained by Darrick Wiebe
|
||||||
|
" http://www.vim.org/scripts/script.php?script_id=2765
|
||||||
|
|
||||||
|
" 0. Initialization {{{1
|
||||||
|
" =================
|
||||||
|
|
||||||
|
" Only load this indent file when no other was loaded.
|
||||||
|
if exists("b:did_indent")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let b:did_indent = 1
|
||||||
|
|
||||||
|
setlocal nosmartindent
|
||||||
|
|
||||||
|
" Now, set up our indentation expression and keys that trigger it.
|
||||||
|
setlocal indentexpr=GetJSONIndent()
|
||||||
|
setlocal indentkeys=0{,0},0),0[,0],!^F,o,O,e
|
||||||
|
|
||||||
|
" Only define the function once.
|
||||||
|
if exists("*GetJSONIndent")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
let s:cpo_save = &cpo
|
||||||
|
set cpo&vim
|
||||||
|
|
||||||
|
" 1. Variables {{{1
|
||||||
|
" ============
|
||||||
|
|
||||||
|
let s:line_term = '\s*\%(\%(\/\/\).*\)\=$'
|
||||||
|
" Regex that defines blocks.
|
||||||
|
let s:block_regex = '\%({\)\s*\%(|\%([*@]\=\h\w*,\=\s*\)\%(,\s*[*@]\=\h\w*\)*|\)\=' . s:line_term
|
||||||
|
|
||||||
|
" 2. Auxiliary Functions {{{1
|
||||||
|
" ======================
|
||||||
|
|
||||||
|
" Check if the character at lnum:col is inside a string.
|
||||||
|
function s:IsInString(lnum, col)
|
||||||
|
return synIDattr(synID(a:lnum, a:col, 1), 'name') == jsonString
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Find line above 'lnum' that isn't empty, or in a string.
|
||||||
|
function s:PrevNonBlankNonString(lnum)
|
||||||
|
let lnum = prevnonblank(a:lnum)
|
||||||
|
while lnum > 0
|
||||||
|
" If the line isn't empty or in a string, end search.
|
||||||
|
let line = getline(lnum)
|
||||||
|
if !(s:IsInString(lnum, 1) && s:IsInString(lnum, strlen(line)))
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
let lnum = prevnonblank(lnum - 1)
|
||||||
|
endwhile
|
||||||
|
return lnum
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Check if line 'lnum' has more opening brackets than closing ones.
|
||||||
|
function s:LineHasOpeningBrackets(lnum)
|
||||||
|
let open_0 = 0
|
||||||
|
let open_2 = 0
|
||||||
|
let open_4 = 0
|
||||||
|
let line = getline(a:lnum)
|
||||||
|
let pos = match(line, '[][(){}]', 0)
|
||||||
|
while pos != -1
|
||||||
|
let idx = stridx('(){}[]', line[pos])
|
||||||
|
if idx % 2 == 0
|
||||||
|
let open_{idx} = open_{idx} + 1
|
||||||
|
else
|
||||||
|
let open_{idx - 1} = open_{idx - 1} - 1
|
||||||
|
endif
|
||||||
|
let pos = match(line, '[][(){}]', pos + 1)
|
||||||
|
endwhile
|
||||||
|
return (open_0 > 0) . (open_2 > 0) . (open_4 > 0)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function s:Match(lnum, regex)
|
||||||
|
let col = match(getline(a:lnum), a:regex) + 1
|
||||||
|
return col > 0 && !s:IsInString(a:lnum, col) ? col : 0
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" 3. GetJSONIndent Function {{{1
|
||||||
|
" =========================
|
||||||
|
|
||||||
|
function GetJSONIndent()
|
||||||
|
" 3.1. Setup {{{2
|
||||||
|
" ----------
|
||||||
|
|
||||||
|
" Set up variables for restoring position in file. Could use v:lnum here.
|
||||||
|
let vcol = col('.')
|
||||||
|
|
||||||
|
" 3.2. Work on the current line {{{2
|
||||||
|
" -----------------------------
|
||||||
|
|
||||||
|
" Get the current line.
|
||||||
|
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.
|
||||||
|
let col = matchend(line, '^\s*[]}]')
|
||||||
|
|
||||||
|
if col > 0 && !s:IsInString(v:lnum, col)
|
||||||
|
call cursor(v:lnum, col)
|
||||||
|
let bs = strpart('{}[]', stridx('}]', line[col - 1]) * 2, 2)
|
||||||
|
|
||||||
|
let pairstart = escape(bs[0], '[')
|
||||||
|
let pairend = escape(bs[1], ']')
|
||||||
|
let pairline = searchpair(pairstart, '', pairend, 'bW')
|
||||||
|
|
||||||
|
if pairline > 0
|
||||||
|
let ind = indent(pairline)
|
||||||
|
else
|
||||||
|
let ind = virtcol('.') - 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
return ind
|
||||||
|
endif
|
||||||
|
|
||||||
|
" If we are in a multi-line string, don't do anything to it.
|
||||||
|
if s:IsInString(v:lnum, matchend(line, '^\s*') + 1)
|
||||||
|
return indent('.')
|
||||||
|
endif
|
||||||
|
|
||||||
|
" 3.3. Work on the previous line. {{{2
|
||||||
|
" -------------------------------
|
||||||
|
|
||||||
|
let lnum = prevnonblank(v:lnum - 1)
|
||||||
|
|
||||||
|
if lnum == 0
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Set up variables for current line.
|
||||||
|
let line = getline(lnum)
|
||||||
|
let ind = indent(lnum)
|
||||||
|
|
||||||
|
" If the previous line ended with a block opening, add a level of indent.
|
||||||
|
" if s:Match(lnum, s:block_regex)
|
||||||
|
" return indent(lnum) + shiftwidth()
|
||||||
|
" endif
|
||||||
|
|
||||||
|
" If the previous line contained an opening bracket, and we are still in it,
|
||||||
|
" add indent depending on the bracket type.
|
||||||
|
if line =~ '[[({]'
|
||||||
|
let counts = s:LineHasOpeningBrackets(lnum)
|
||||||
|
if counts[0] == '1' || counts[1] == '1' || counts[2] == '1'
|
||||||
|
return ind + shiftwidth()
|
||||||
|
else
|
||||||
|
call cursor(v:lnum, vcol)
|
||||||
|
end
|
||||||
|
endif
|
||||||
|
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
return ind
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" }}}1
|
||||||
|
|
||||||
|
let &cpo = s:cpo_save
|
||||||
|
unlet s:cpo_save
|
||||||
|
|
||||||
|
" vim:set sw=2 sts=2 ts=8 noet:
|
||||||
|
|
||||||
79
indent/typescript.vim
Normal file
79
indent/typescript.vim
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
" Vim indent file, taken from indent/java.vim
|
||||||
|
" Language: Typescript
|
||||||
|
" Maintainer: None! Wanna improve this?
|
||||||
|
" Last Change: 2015 Mar 07
|
||||||
|
|
||||||
|
" Only load this indent file when no other was loaded.
|
||||||
|
if exists("b:did_indent")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let b:did_indent = 1
|
||||||
|
|
||||||
|
" Use javascript cindent options
|
||||||
|
setlocal cindent cinoptions& cinoptions+=j1,J1
|
||||||
|
setlocal indentkeys&
|
||||||
|
|
||||||
|
" Load typescript indent function
|
||||||
|
setlocal indentexpr=GetTypescriptIndent()
|
||||||
|
|
||||||
|
let b:undo_indent = "setl cin< cino< indentkeys< indentexpr<"
|
||||||
|
|
||||||
|
" Only define the function once
|
||||||
|
if exists("*GetTypescriptIndent")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Make sure we have vim capabilities
|
||||||
|
let s:keepcpo = &cpo
|
||||||
|
set cpo&vim
|
||||||
|
|
||||||
|
function! TypescriptPrevNonBlankOrComment(lnum)
|
||||||
|
let pnum = prevnonblank(a:lnum)
|
||||||
|
" skip any comments (either `//`, `/*` or `*`)
|
||||||
|
while getline(pnum) =~ '^\s*\(\/\/\|\/\*\|\*\)'
|
||||||
|
let pnum = prevnonblank(pnum-1)
|
||||||
|
endwhile
|
||||||
|
return pnum
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function GetTypescriptIndent()
|
||||||
|
|
||||||
|
" default value: trust cindent
|
||||||
|
let ind = cindent(v:lnum)
|
||||||
|
|
||||||
|
if getline(v:lnum) =~ '^\s*[{}\*]'
|
||||||
|
return ind
|
||||||
|
endif
|
||||||
|
|
||||||
|
" The last non-empty line
|
||||||
|
let prev = TypescriptPrevNonBlankOrComment(v:lnum-1)
|
||||||
|
|
||||||
|
" Check if the previous line consists of a single `<variable> : <type>;`
|
||||||
|
" declaration (e.g. in interface definitions)
|
||||||
|
if getline(prev) =~ '^\s*\w\+\s*:[^{]\+;\s*$'
|
||||||
|
return indent(prev)
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Try to find out whether the last `}` ended a `<variable> : {` block
|
||||||
|
if getline(prev) =~ '};\s*$'
|
||||||
|
" jump to matching `{` bracket
|
||||||
|
call cursor(prev, 1)
|
||||||
|
silent normal %
|
||||||
|
|
||||||
|
" See if current line is type annotation without closing ';' but open
|
||||||
|
" `{` bracket
|
||||||
|
let lnum = line('.')
|
||||||
|
if getline(lnum) =~ '^\s*\w\+\s*:[^;]\+{'
|
||||||
|
let ind = indent(lnum)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
return ind
|
||||||
|
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Restore compatibility mode
|
||||||
|
let &cpo = s:keepcpo
|
||||||
|
unlet s:keepcpo
|
||||||
|
|
||||||
|
" vim: et
|
||||||
128
syntax/json.vim
128
syntax/json.vim
@@ -1,13 +1,7 @@
|
|||||||
" Vim syntax file
|
" Vim syntax file
|
||||||
" Language: JSON
|
" Language: JSON
|
||||||
" Maintainer: Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
|
" Maintainer: Eli Parra <eli@elzr.com> https://github.com/elzr/vim-json
|
||||||
" Last Change: 2009-06-16
|
" Last Change: 2014-12-20 Load ftplugin/json.vim
|
||||||
" Version: 0.4
|
|
||||||
" {{{1
|
|
||||||
|
|
||||||
" Syntax setup {{{2
|
|
||||||
" For version 5.x: Clear all syntax items
|
|
||||||
" For version 6.x: Quit when a syntax file was already loaded
|
|
||||||
|
|
||||||
if !exists("main_syntax")
|
if !exists("main_syntax")
|
||||||
if version < 600
|
if version < 600
|
||||||
@@ -18,54 +12,95 @@ if !exists("main_syntax")
|
|||||||
let main_syntax = 'json'
|
let main_syntax = 'json'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Syntax: Strings {{{2
|
syntax match jsonNoise /\%(:\|,\)/
|
||||||
syn region jsonString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=jsonEscape
|
|
||||||
" Syntax: JSON does not allow strings with single quotes, unlike JavaScript.
|
|
||||||
syn region jsonStringSQ start=+'+ skip=+\\\\\|\\"+ end=+'+
|
|
||||||
|
|
||||||
" Syntax: Escape sequences {{{3
|
" Syntax: Strings
|
||||||
|
" Separated into a match and region because a region by itself is always greedy
|
||||||
|
syn match jsonStringMatch /"\([^"]\|\\\"\)\+"\ze[[:blank:]\r\n]*[,}\]]/ contains=jsonString
|
||||||
|
syn region jsonString oneline matchgroup=jsonQuote start=/"/ skip=/\\\\\|\\"/ end=/"/ concealends contains=jsonEscape contained
|
||||||
|
|
||||||
|
" Syntax: JSON does not allow strings with single quotes, unlike JavaScript.
|
||||||
|
syn region jsonStringSQError oneline start=+'+ skip=+\\\\\|\\"+ end=+'+
|
||||||
|
|
||||||
|
" Syntax: JSON Keywords
|
||||||
|
" Separated into a match and region because a region by itself is always greedy
|
||||||
|
syn match jsonKeywordMatch /"\([^"]\|\\\"\)\+"[[:blank:]\r\n]*\:/ contains=jsonKeyword
|
||||||
|
syn region jsonKeyword matchgroup=jsonQuote start=/"/ end=/"\ze[[:blank:]\r\n]*\:/ contains=jsonEscape contained
|
||||||
|
|
||||||
|
" Syntax: Escape sequences
|
||||||
syn match jsonEscape "\\["\\/bfnrt]" contained
|
syn match jsonEscape "\\["\\/bfnrt]" contained
|
||||||
syn match jsonEscape "\\u\x\{4}" contained
|
syn match jsonEscape "\\u\x\{4}" contained
|
||||||
|
|
||||||
" Syntax: Strings should always be enclosed with quotes.
|
" Syntax: Numbers
|
||||||
syn match jsonNoQuotes "\<\a\+\>"
|
syn match jsonNumber "-\=\<\%(0\|[1-9]\d*\)\%(\.\d\+\)\=\%([eE][-+]\=\d\+\)\=\>\ze[[:blank:]\r\n]*[,}\]]"
|
||||||
|
|
||||||
" Syntax: Numbers {{{2
|
" ERROR WARNINGS **********************************************
|
||||||
syn match jsonNumber "-\=\<\%(0\|[1-9]\d*\)\%(\.\d\+\)\=\%([eE][-+]\=\d\+\)\=\>"
|
" Syntax: Strings should always be enclosed with quotes.
|
||||||
|
syn match jsonNoQuotesError "\<[[:alpha:]][[:alnum:]]*\>"
|
||||||
|
syn match jsonTripleQuotesError /"""/
|
||||||
|
|
||||||
" Syntax: An integer part of 0 followed by other digits is not allowed.
|
" Syntax: An integer part of 0 followed by other digits is not allowed.
|
||||||
syn match jsonNumError "-\=\<0\d\.\d*\>"
|
syn match jsonNumError "-\=\<0\d\.\d*\>"
|
||||||
|
|
||||||
" Syntax: Boolean {{{2
|
" Syntax: Decimals smaller than one should begin with 0 (so .1 should be 0.1).
|
||||||
syn keyword jsonBoolean true false
|
syn match jsonNumError "\:\@<=[[:blank:]\r\n]*\zs\.\d\+"
|
||||||
|
|
||||||
" Syntax: Null {{{2
|
" Syntax: No comments in JSON, see http://stackoverflow.com/questions/244777/can-i-comment-a-json-file
|
||||||
syn keyword jsonNull null
|
syn match jsonCommentError "//.*"
|
||||||
|
syn match jsonCommentError "\(/\*\)\|\(\*/\)"
|
||||||
|
|
||||||
" Syntax: Braces {{{2
|
" Syntax: No semicolons in JSON
|
||||||
syn match jsonBraces "[{}\[\]]"
|
syn match jsonSemicolonError ";"
|
||||||
|
|
||||||
" Define the default highlighting. {{{1
|
" Syntax: No trailing comma after the last element of arrays or objects
|
||||||
" For version 5.7 and earlier: only when not done already
|
syn match jsonTrailingCommaError ",\_s*[}\]]"
|
||||||
" For version 5.8 and later: only when an item doesn't have highlighting yet
|
|
||||||
|
" Syntax: Watch out for missing commas between elements
|
||||||
|
syn match jsonMissingCommaError /\("\|\]\|\d\)\zs\_s\+\ze"/
|
||||||
|
syn match jsonMissingCommaError /\(\]\|\}\)\_s\+\ze"/ "arrays/objects as values
|
||||||
|
syn match jsonMissingCommaError /}\_s\+\ze{/ "objects as elements in an array
|
||||||
|
syn match jsonMissingCommaError /\(true\|false\)\_s\+\ze"/ "true/false as value
|
||||||
|
|
||||||
|
" ********************************************** END OF ERROR WARNINGS
|
||||||
|
" Allowances for JSONP: function call at the beginning of the file,
|
||||||
|
" parenthesis and semicolon at the end.
|
||||||
|
" Function name validation based on
|
||||||
|
" http://stackoverflow.com/questions/2008279/validate-a-javascript-function-name/2008444#2008444
|
||||||
|
syn match jsonPadding "\%^[[:blank:]\r\n]*[_$[:alpha:]][_$[:alnum:]]*[[:blank:]\r\n]*("
|
||||||
|
syn match jsonPadding ");[[:blank:]\r\n]*\%$"
|
||||||
|
|
||||||
|
" Syntax: Boolean
|
||||||
|
syn match jsonBoolean /\(true\|false\)\(\_s\+\ze"\)\@!/
|
||||||
|
|
||||||
|
" Syntax: Null
|
||||||
|
syn keyword jsonNull null
|
||||||
|
|
||||||
|
" Syntax: Braces
|
||||||
|
syn region jsonFold matchgroup=jsonBraces start="{" end=/}\(\_s\+\ze\("\|{\)\)\@!/ transparent fold
|
||||||
|
syn region jsonFold matchgroup=jsonBraces start="\[" end=/]\(\_s\+\ze"\)\@!/ transparent fold
|
||||||
|
|
||||||
|
" Define the default highlighting.
|
||||||
if version >= 508 || !exists("did_json_syn_inits")
|
if version >= 508 || !exists("did_json_syn_inits")
|
||||||
if version < 508
|
hi def link jsonPadding Operator
|
||||||
let did_json_syn_inits = 1
|
hi def link jsonString String
|
||||||
command -nargs=+ HiLink hi link <args>
|
hi def link jsonTest Label
|
||||||
else
|
hi def link jsonEscape Special
|
||||||
command -nargs=+ HiLink hi def link <args>
|
hi def link jsonNumber Number
|
||||||
endif
|
hi def link jsonBraces Delimiter
|
||||||
HiLink jsonString String
|
hi def link jsonNull Function
|
||||||
HiLink jsonEscape Special
|
hi def link jsonBoolean Boolean
|
||||||
HiLink jsonNumber Number
|
hi def link jsonKeyword Label
|
||||||
HiLink jsonBraces Operator
|
|
||||||
HiLink jsonNull Function
|
|
||||||
HiLink jsonBoolean Boolean
|
|
||||||
|
|
||||||
HiLink jsonNumError Error
|
hi def link jsonNumError Error
|
||||||
HiLink jsonStringSQ Error
|
hi def link jsonCommentError Error
|
||||||
HiLink jsonNoQuotes Error
|
hi def link jsonSemicolonError Error
|
||||||
delcommand HiLink
|
hi def link jsonTrailingCommaError Error
|
||||||
|
hi def link jsonMissingCommaError Error
|
||||||
|
hi def link jsonStringSQError Error
|
||||||
|
hi def link jsonNoQuotesError Error
|
||||||
|
hi def link jsonTripleQuotesError Error
|
||||||
|
hi def link jsonQuote Quote
|
||||||
|
hi def link jsonNoise Noise
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let b:current_syntax = "json"
|
let b:current_syntax = "json"
|
||||||
@@ -73,5 +108,12 @@ if main_syntax == 'json'
|
|||||||
unlet main_syntax
|
unlet main_syntax
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Vim settings {{{2
|
" Vim settings
|
||||||
" vim: ts=8 fdm=marker
|
" vim: ts=8 fdm=marker
|
||||||
|
|
||||||
|
" MIT License
|
||||||
|
" Copyright (c) 2013, Jeroen Ruigrok van der Werven, Eli Parra
|
||||||
|
"Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
"The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
"THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
"See https://twitter.com/elzr/status/294964017926119424
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ syntax case match
|
|||||||
|
|
||||||
"" Syntax in the typeScript code"{{{
|
"" Syntax in the typeScript code"{{{
|
||||||
syn match typeScriptSpecial "\\\d\d\d\|\\."
|
syn match typeScriptSpecial "\\\d\d\d\|\\."
|
||||||
syn region typeScriptStringD start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ contains=typeScriptSpecial,@htmlPreproc
|
syn region typeScriptStringD start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ contains=typeScriptSpecial,@htmlPreproc
|
||||||
syn region typeScriptStringS start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ contains=typeScriptSpecial,@htmlPreproc
|
syn region typeScriptStringS start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ contains=typeScriptSpecial,@htmlPreproc
|
||||||
|
|
||||||
syn match typeScriptSpecialCharacter "'\\.'"
|
syn match typeScriptSpecialCharacter "'\\.'"
|
||||||
syn match typeScriptNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>"
|
syn match typeScriptNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>"
|
||||||
@@ -72,28 +72,28 @@ syntax match typeScriptFloat /\<-\=\%(\d\+\.\d\+\|\d\+\.\|\.\d\+\)\%([eE][+-]\=\
|
|||||||
" syntax match typeScriptLabel /\(?\s*\)\@<!\<\w\+\(\s*:\)\@=/
|
" syntax match typeScriptLabel /\(?\s*\)\@<!\<\w\+\(\s*:\)\@=/
|
||||||
"}}}
|
"}}}
|
||||||
"" typeScript Prototype"{{{
|
"" typeScript Prototype"{{{
|
||||||
syntax keyword typeScriptPrototype prototype
|
syntax keyword typeScriptPrototype contained prototype
|
||||||
"}}}
|
"}}}
|
||||||
" DOM, Browser and Ajax Support {{{
|
" DOM, Browser and Ajax Support {{{
|
||||||
""""""""""""""""""""""""
|
""""""""""""""""""""""""
|
||||||
syntax keyword typeScriptBrowserObjects window navigator screen history location
|
syntax keyword typeScriptBrowserObjects window navigator screen history location
|
||||||
|
|
||||||
syntax keyword typeScriptDOMObjects document event HTMLElement Anchor Area Base Body Button Form Frame Frameset Image Link Meta Option Select Style Table TableCell TableRow Textarea
|
syntax keyword typeScriptDOMObjects document event HTMLElement Anchor Area Base Body Button Form Frame Frameset Image Link Meta Option Select Style Table TableCell TableRow Textarea
|
||||||
syntax keyword typeScriptDOMMethods createTextNode createElement insertBefore replaceChild removeChild appendChild hasChildNodes cloneNode normalize isSupported hasAttributes getAttribute setAttribute removeAttribute getAttributeNode setAttributeNode removeAttributeNode getElementsByTagName hasAttribute getElementById adoptNode close compareDocumentPosition createAttribute createCDATASection createComment createDocumentFragment createElementNS createEvent createExpression createNSResolver createProcessingInstruction createRange createTreeWalker elementFromPoint evaluate getBoxObjectFor getElementsByClassName getSelection getUserData hasFocus importNode
|
syntax keyword typeScriptDOMMethods contained createTextNode createElement insertBefore replaceChild removeChild appendChild hasChildNodes cloneNode normalize isSupported hasAttributes getAttribute setAttribute removeAttribute getAttributeNode setAttributeNode removeAttributeNode getElementsByTagName hasAttribute getElementById adoptNode close compareDocumentPosition createAttribute createCDATASection createComment createDocumentFragment createElementNS createEvent createExpression createNSResolver createProcessingInstruction createRange createTreeWalker elementFromPoint evaluate getBoxObjectFor getElementsByClassName getSelection getUserData hasFocus importNode
|
||||||
syntax keyword typeScriptDOMProperties nodeName nodeValue nodeType parentNode childNodes firstChild lastChild previousSibling nextSibling attributes ownerDocument namespaceURI prefix localName tagName
|
syntax keyword typeScriptDOMProperties contained nodeName nodeValue nodeType parentNode childNodes firstChild lastChild previousSibling nextSibling attributes ownerDocument namespaceURI prefix localName tagName
|
||||||
|
|
||||||
syntax keyword typeScriptAjaxObjects XMLHttpRequest
|
syntax keyword typeScriptAjaxObjects XMLHttpRequest
|
||||||
syntax keyword typeScriptAjaxProperties readyState responseText responseXML statusText
|
syntax keyword typeScriptAjaxProperties contained readyState responseText responseXML statusText
|
||||||
syntax keyword typeScriptAjaxMethods onreadystatechange abort getAllResponseHeaders getResponseHeader open send setRequestHeader
|
syntax keyword typeScriptAjaxMethods contained onreadystatechange abort getAllResponseHeaders getResponseHeader open send setRequestHeader
|
||||||
|
|
||||||
syntax keyword typeScriptPropietaryObjects ActiveXObject
|
syntax keyword typeScriptPropietaryObjects ActiveXObject
|
||||||
syntax keyword typeScriptPropietaryMethods attachEvent detachEvent cancelBubble returnValue
|
syntax keyword typeScriptPropietaryMethods contained attachEvent detachEvent cancelBubble returnValue
|
||||||
|
|
||||||
syntax keyword typeScriptHtmlElemProperties className clientHeight clientLeft clientTop clientWidth dir href id innerHTML lang length offsetHeight offsetLeft offsetParent offsetTop offsetWidth scrollHeight scrollLeft scrollTop scrollWidth style tabIndex target title
|
syntax keyword typeScriptHtmlElemProperties contained className clientHeight clientLeft clientTop clientWidth dir href id innerHTML lang length offsetHeight offsetLeft offsetParent offsetTop offsetWidth scrollHeight scrollLeft scrollTop scrollWidth style tabIndex target title
|
||||||
|
|
||||||
syntax keyword typeScriptEventListenerKeywords blur click focus mouseover mouseout load item
|
syntax keyword typeScriptEventListenerKeywords contained blur click focus mouseover mouseout load item
|
||||||
|
|
||||||
syntax keyword typeScriptEventListenerMethods scrollIntoView addEventListener dispatchEvent removeEventListener preventDefault stopPropagation
|
syntax keyword typeScriptEventListenerMethods contained scrollIntoView addEventListener dispatchEvent removeEventListener preventDefault stopPropagation
|
||||||
" }}}
|
" }}}
|
||||||
"" Programm Keywords"{{{
|
"" Programm Keywords"{{{
|
||||||
syntax keyword typeScriptSource import export
|
syntax keyword typeScriptSource import export
|
||||||
@@ -165,33 +165,34 @@ if exists("typeScript_enable_domhtmlcss")
|
|||||||
syntax keyword typeScriptCssStyles contained marks maxHeight maxWidth minHeight minWidth opacity MozOpacity overflow overflowX overflowY verticalAlign visibility zoom cssText
|
syntax keyword typeScriptCssStyles contained marks maxHeight maxWidth minHeight minWidth opacity MozOpacity overflow overflowX overflowY verticalAlign visibility zoom cssText
|
||||||
syntax keyword typeScriptCssStyles contained scrollbar3dLightColor scrollbarArrowColor scrollbarBaseColor scrollbarDarkShadowColor scrollbarFaceColor scrollbarHighlightColor scrollbarShadowColor scrollbarTrackColor
|
syntax keyword typeScriptCssStyles contained scrollbar3dLightColor scrollbarArrowColor scrollbarBaseColor scrollbarDarkShadowColor scrollbarFaceColor scrollbarHighlightColor scrollbarShadowColor scrollbarTrackColor
|
||||||
"}}}
|
"}}}
|
||||||
" Highlight ways"{{{
|
|
||||||
syntax match typeScriptDotNotation "\." nextgroup=typeScriptPrototype,typeScriptDomElemAttrs,typeScriptDomElemFuncs,typeScriptHtmlElemAttrs,typeScriptHtmlElemFuncs
|
|
||||||
syntax match typeScriptDotNotation "\.style\." nextgroup=typeScriptCssStyles
|
|
||||||
"}}}
|
|
||||||
endif "DOM/HTML/CSS
|
endif "DOM/HTML/CSS
|
||||||
|
|
||||||
|
" Highlight ways"{{{
|
||||||
|
syntax match typeScriptDotNotation "\." nextgroup=typeScriptPrototype,typeScriptDomElemAttrs,typeScriptDomElemFuncs,typeScriptDOMMethods,typeScriptDOMProperties,typeScriptHtmlElemAttrs,typeScriptHtmlElemFuncs,typeScriptHtmlElemProperties,typeScriptAjaxProperties,typeScriptAjaxMethods,typeScriptPropietaryMethods,typeScriptEventListenerMethods skipwhite skipnl
|
||||||
|
syntax match typeScriptDotNotation "\.style\." nextgroup=typeScriptCssStyles
|
||||||
|
"}}}
|
||||||
|
|
||||||
"" end DOM/HTML/CSS specified things""}}}
|
"" end DOM/HTML/CSS specified things""}}}
|
||||||
|
|
||||||
|
|
||||||
"" Code blocks
|
"" Code blocks
|
||||||
syntax cluster typeScriptAll contains=typeScriptComment,typeScriptLineComment,typeScriptDocComment,typeScriptStringD,typeScriptStringS,typeScriptRegexpString,typeScriptNumber,typeScriptFloat,typeScriptLabel,typeScriptSource,typeScriptType,typeScriptOperator,typeScriptBoolean,typeScriptNull,typeScriptFuncKeyword,typeScriptConditional,typeScriptGlobal,typeScriptRepeat,typeScriptBranch,typeScriptStatement,typeScriptGlobalObjects,typeScriptMessage,typeScriptIdentifier,typeScriptExceptions,typeScriptReserved,typeScriptDeprecated,typeScriptDomErrNo,typeScriptDomNodeConsts,typeScriptHtmlEvents,typeScriptDotNotation,typeScriptBrowserObjects,typeScriptDOMObjects,typeScriptAjaxObjects,typeScriptPropietaryObjects,typeScriptDOMMethods,typeScriptHtmlElemProperties,typeScriptDOMProperties,typeScriptEventListenerKeywords,typeScriptEventListenerMethods,typeScriptAjaxProperties,typeScriptAjaxMethods,typeScriptFuncArg
|
syntax cluster typeScriptAll contains=typeScriptComment,typeScriptLineComment,typeScriptDocComment,typeScriptStringD,typeScriptStringS,typeScriptRegexpString,typeScriptNumber,typeScriptFloat,typeScriptLabel,typeScriptSource,typeScriptType,typeScriptOperator,typeScriptBoolean,typeScriptNull,typeScriptFuncKeyword,typeScriptConditional,typeScriptGlobal,typeScriptRepeat,typeScriptBranch,typeScriptStatement,typeScriptGlobalObjects,typeScriptMessage,typeScriptIdentifier,typeScriptExceptions,typeScriptReserved,typeScriptDeprecated,typeScriptDomErrNo,typeScriptDomNodeConsts,typeScriptHtmlEvents,typeScriptDotNotation,typeScriptBrowserObjects,typeScriptDOMObjects,typeScriptAjaxObjects,typeScriptPropietaryObjects,typeScriptDOMMethods,typeScriptHtmlElemProperties,typeScriptDOMProperties,typeScriptEventListenerKeywords,typeScriptEventListenerMethods,typeScriptAjaxProperties,typeScriptAjaxMethods,typeScriptFuncArg
|
||||||
|
|
||||||
if main_syntax == "typeScript"
|
if main_syntax == "typescript"
|
||||||
syntax sync clear
|
syntax sync clear
|
||||||
syntax sync ccomment typeScriptComment minlines=200
|
syntax sync ccomment typeScriptComment minlines=200
|
||||||
" syntax sync match typeScriptHighlight grouphere typeScriptBlock /{/
|
" syntax sync match typeScriptHighlight grouphere typeScriptBlock /{/
|
||||||
endif
|
endif
|
||||||
|
|
||||||
syntax keyword typeScriptFuncKeyword function contained
|
syntax keyword typeScriptFuncKeyword function
|
||||||
syntax region typeScriptFuncDef start="function" end="\([^)]*\)" contains=typeScriptFuncKeyword,typeScriptFuncArg keepend
|
"syntax region typeScriptFuncDef start="function" end="\(.*\)" contains=typeScriptFuncKeyword,typeScriptFuncArg keepend
|
||||||
syntax match typeScriptFuncArg "\(([^()]*)\)" contains=typeScriptParens,typeScriptFuncComma contained
|
"syntax match typeScriptFuncArg "\(([^()]*)\)" contains=typeScriptParens,typeScriptFuncComma contained
|
||||||
syntax match typeScriptFuncComma /,/ contained
|
"syntax match typeScriptFuncComma /,/ contained
|
||||||
" syntax region typeScriptFuncBlock contained matchgroup=typeScriptFuncBlock start="{" end="}" contains=@typeScriptAll,typeScriptParensErrA,typeScriptParensErrB,typeScriptParen,typeScriptBracket,typeScriptBlock fold
|
" syntax region typeScriptFuncBlock contained matchgroup=typeScriptFuncBlock start="{" end="}" contains=@typeScriptAll,typeScriptParensErrA,typeScriptParensErrB,typeScriptParen,typeScriptBracket,typeScriptBlock fold
|
||||||
|
|
||||||
syn match typeScriptBraces "[{}\[\]]"
|
syn match typeScriptBraces "[{}\[\]]"
|
||||||
syn match typeScriptParens "[()]"
|
syn match typeScriptParens "[()]"
|
||||||
syn match typeScriptOpSymbols "=\{1,3}\|!==\|!=\|<\|>\|>=\|<=\|++\|+=\|--\|-="
|
syn match typeScriptOpSymbols "=\{1,3}\|!==\|!=\|<\|>\|>=\|<=\|++\|+=\|--\|-="
|
||||||
syn match typeScriptEndColons "[;,]"
|
syn match typeScriptEndColons "[;,]"
|
||||||
syn match typeScriptLogicSymbols "\(&&\)\|\(||\)"
|
syn match typeScriptLogicSymbols "\(&&\)\|\(||\)"
|
||||||
|
|
||||||
@@ -204,7 +205,7 @@ syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend
|
|||||||
setl foldtext=FoldText()
|
setl foldtext=FoldText()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
au FileType typeScript call TypeScriptFold()
|
au FileType typescript call TypeScriptFold()
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
@@ -250,7 +251,7 @@ if version >= 508 || !exists("did_typeScript_syn_inits")
|
|||||||
HiLink typeScriptIdentifier Identifier
|
HiLink typeScriptIdentifier Identifier
|
||||||
HiLink typeScriptRepeat Repeat
|
HiLink typeScriptRepeat Repeat
|
||||||
HiLink typeScriptStatement Statement
|
HiLink typeScriptStatement Statement
|
||||||
HiLink typeScriptFuncKeyword Type
|
HiLink typeScriptFuncKeyword Function
|
||||||
HiLink typeScriptMessage Keyword
|
HiLink typeScriptMessage Keyword
|
||||||
HiLink typeScriptDeprecated Exception
|
HiLink typeScriptDeprecated Exception
|
||||||
HiLink typeScriptError Error
|
HiLink typeScriptError Error
|
||||||
@@ -280,28 +281,29 @@ if version >= 508 || !exists("did_typeScript_syn_inits")
|
|||||||
HiLink typeScriptHtmlElemFuncs PreProc
|
HiLink typeScriptHtmlElemFuncs PreProc
|
||||||
|
|
||||||
HiLink typeScriptCssStyles Label
|
HiLink typeScriptCssStyles Label
|
||||||
" Ajax Highlighting
|
|
||||||
HiLink typeScriptBrowserObjects Constant
|
|
||||||
|
|
||||||
HiLink typeScriptDOMObjects Constant
|
" Ajax Highlighting
|
||||||
HiLink typeScriptDOMMethods Exception
|
HiLink typeScriptBrowserObjects Constant
|
||||||
HiLink typeScriptDOMProperties Type
|
|
||||||
|
|
||||||
HiLink typeScriptAjaxObjects htmlH1
|
HiLink typeScriptDOMObjects Constant
|
||||||
HiLink typeScriptAjaxMethods Exception
|
HiLink typeScriptDOMMethods Function
|
||||||
HiLink typeScriptAjaxProperties Type
|
HiLink typeScriptDOMProperties Special
|
||||||
|
|
||||||
HiLink typeScriptFuncDef Title
|
HiLink typeScriptAjaxObjects Constant
|
||||||
HiLink typeScriptFuncArg Special
|
HiLink typeScriptAjaxMethods Function
|
||||||
HiLink typeScriptFuncComma Operator
|
HiLink typeScriptAjaxProperties Special
|
||||||
|
|
||||||
HiLink typeScriptHtmlEvents Special
|
HiLink typeScriptFuncDef Title
|
||||||
HiLink typeScriptHtmlElemProperties Type
|
HiLink typeScriptFuncArg Special
|
||||||
|
HiLink typeScriptFuncComma Operator
|
||||||
|
|
||||||
HiLink typeScriptEventListenerKeywords Keyword
|
HiLink typeScriptHtmlEvents Special
|
||||||
|
HiLink typeScriptHtmlElemProperties Special
|
||||||
|
|
||||||
HiLink typeScriptNumber Number
|
HiLink typeScriptEventListenerKeywords Keyword
|
||||||
HiLink typeScriptPropietaryObjects Constant
|
|
||||||
|
HiLink typeScriptNumber Number
|
||||||
|
HiLink typeScriptPropietaryObjects Constant
|
||||||
|
|
||||||
delcommand HiLink
|
delcommand HiLink
|
||||||
endif
|
endif
|
||||||
@@ -312,8 +314,8 @@ endif
|
|||||||
syntax cluster htmltypeScript contains=@typeScriptAll,typeScriptBracket,typeScriptParen,typeScriptBlock,typeScriptParenError
|
syntax cluster htmltypeScript contains=@typeScriptAll,typeScriptBracket,typeScriptParen,typeScriptBlock,typeScriptParenError
|
||||||
syntax cluster typeScriptExpression contains=@typeScriptAll,typeScriptBracket,typeScriptParen,typeScriptBlock,typeScriptParenError,@htmlPreproc
|
syntax cluster typeScriptExpression contains=@typeScriptAll,typeScriptBracket,typeScriptParen,typeScriptBlock,typeScriptParenError,@htmlPreproc
|
||||||
|
|
||||||
let b:current_syntax = "typeScript"
|
let b:current_syntax = "typescript"
|
||||||
if main_syntax == 'typeScript'
|
if main_syntax == 'typescript'
|
||||||
unlet main_syntax
|
unlet main_syntax
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user