From 303b3f1b434f26f936c241789c84dca6e2f50df2 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Sun, 6 Dec 2015 11:31:38 +0100 Subject: [PATCH] Update all bundles --- README.md | 10 +- after/ftdetect/javascript.vim | 24 --- after/indent/jsx.vim | 7 - after/jsx-config.vim | 37 ---- after/syntax/jsx.vim | 25 ++- after/syntax/rust.vim | 8 +- autoload/rust.vim | 315 +++++++++++++++++++++++++++------- autoload/rustfmt.vim | 83 +++++++++ compiler/rspec.vim | 2 +- compiler/rustc.vim | 2 +- ftdetect/polyglot.vim | 38 +++- ftplugin/ruby.vim | 6 +- ftplugin/rust.vim | 35 +++- ftplugin/swift.vim | 8 + indent/handlebars.vim | 104 +++++++++++ indent/rust.vim | 7 + indent/swift.vim | 229 +++++++++++++++++++++++- syntax/cpp.vim | 7 +- syntax/elixir.vim | 2 +- syntax/gitrebase.vim | 3 +- syntax/go.vim | 97 ++++++----- syntax/gotexttmpl.vim | 4 +- syntax/jade.vim | 6 +- syntax/perl.vim | 2 +- syntax/php.vim | 12 +- syntax/python.vim | 3 +- syntax/ruby.vim | 40 +++-- syntax/rust.vim | 57 +++--- syntax/swift.vim | 269 +++++++++++++++++++++++------ syntax/toml.vim | 4 +- 30 files changed, 1122 insertions(+), 324 deletions(-) delete mode 100644 after/ftdetect/javascript.vim delete mode 100644 after/jsx-config.vim create mode 100644 autoload/rustfmt.vim create mode 100644 ftplugin/swift.vim create mode 100644 indent/handlebars.vim diff --git a/README.md b/README.md index 73f33f3..9461c3b 100644 --- a/README.md +++ b/README.md @@ -26,9 +26,9 @@ Optionally download one of the [releases](https://github.com/sheerun/vim-polyglo ## Language packs - [arduino](https://github.com/sudar/vim-arduino-syntax) (syntax, indent, ftdetect) -- [blade](https://github.com/xsbeats/vim-blade) (syntax, indent, ftdetect) +- [blade](https://github.com/jwalton512/vim-blade) (syntax, indent, ftdetect) - [c++11](https://github.com/octol/vim-cpp-enhanced-highlight) (syntax) -- [c/c++](https://github.com/vim-jp/cpp-vim) (syntax) +- [c/c++](https://github.com/vim-jp/vim-cpp) (syntax) - [cjsx](https://github.com/mtscout6/vim-cjsx) (ftdetect, syntax, ftplugin) - [clojure](https://github.com/guns/vim-clojure-static) (syntax, indent, autoload, ftplugin, ftdetect) - [coffee-script](https://github.com/kchmck/vim-coffee-script) (syntax, indent, compiler, autoload, ftplugin, ftdetect) @@ -44,7 +44,7 @@ Optionally download one of the [releases](https://github.com/sheerun/vim-polyglo - [go](https://github.com/fatih/vim-go) (syntax, indent, ftdetect) - [groovy](https://github.com/vim-scripts/groovy.vim) (syntax) - [haml](https://github.com/tpope/vim-haml) (syntax, indent, compiler, ftplugin, ftdetect) -- [handlebars](https://github.com/mustache/vim-mustache-handlebars) (syntax, ftplugin, ftdetect) +- [handlebars](https://github.com/mustache/vim-mustache-handlebars) (syntax, indent, ftplugin, ftdetect) - [haskell](https://github.com/neovimhaskell/haskell-vim) (syntax, indent, ftplugin, ftdetect) - [haxe](https://github.com/yaymukund/vim-haxe) (syntax, ftdetect) - [html5](https://github.com/othree/html5.vim) (syntax, indent, autoload, ftplugin) @@ -53,7 +53,7 @@ Optionally download one of the [releases](https://github.com/sheerun/vim-polyglo - [javascript](https://github.com/sheerun/yajs.vim) (syntax, indent) - [json](https://github.com/sheerun/vim-json) (syntax, indent, ftdetect) - [jst](https://github.com/briancollins/vim-jst) (syntax, indent, ftdetect) -- [jsx](https://github.com/mxw/vim-jsx) (after) +- [jsx](https://github.com/mxw/vim-jsx) (ftdetect, after) - [julia](https://github.com/dcjones/julia-minimalist-vim) (syntax, indent, ftdetect) - [kotlin](https://github.com/udalov/kotlin-vim) (syntax, indent, ftdetect) - [latex](https://github.com/LaTeX-Box-Team/LaTeX-Box) (syntax, indent, ftplugin) @@ -86,7 +86,7 @@ Optionally download one of the [releases](https://github.com/sheerun/vim-polyglo - [textile](https://github.com/timcharper/textile.vim) (syntax, ftplugin, ftdetect) - [thrift](https://github.com/solarnz/thrift.vim) (syntax, ftdetect) - [tmux](https://github.com/tejr/vim-tmux) (syntax, ftdetect) -- [tomdoc](https://github.com/duwanis/tomdoc.vim) (syntax) +- [tomdoc](https://github.com/wellbredgrapefruit/tomdoc.vim) (syntax) - [toml](https://github.com/cespare/vim-toml) (syntax, ftplugin, ftdetect) - [twig](https://github.com/beyondwords/vim-twig) (syntax, ftplugin, ftdetect) - [typescript](https://github.com/leafgarland/typescript-vim) (syntax, indent, compiler, ftplugin, ftdetect) diff --git a/after/ftdetect/javascript.vim b/after/ftdetect/javascript.vim deleted file mode 100644 index a0de1b1..0000000 --- a/after/ftdetect/javascript.vim +++ /dev/null @@ -1,24 +0,0 @@ -if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jsx') == -1 - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Vim ftdetect file -" -" Language: JSX (JavaScript) -" Maintainer: Max Wang -" -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - -exec 'source '.fnameescape(expand(':p:h:h').'/jsx-config.vim') - -fu! EnableJSX() - if g:jsx_pragma_required && !b:jsx_pragma_found | return 0 | endif - if g:jsx_ext_required && !exists('b:jsx_ext_found') | return 0 | endif - return 1 -endfu - -autocmd BufNewFile,BufRead *.jsx let b:jsx_ext_found = 1 -autocmd BufNewFile,BufRead *.jsx set filetype=javascript.jsx -autocmd BufNewFile,BufRead *.js - \ if EnableJSX() | set filetype=javascript.jsx | endif - -endif diff --git a/after/indent/jsx.vim b/after/indent/jsx.vim index d33c13d..f4c3666 100644 --- a/after/indent/jsx.vim +++ b/after/indent/jsx.vim @@ -9,13 +9,6 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jsx') == -1 " """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Do nothing if we don't find the @jsx pragma (and we care). -exec 'source '.fnameescape(expand(':p:h:h').'/jsx-config.vim') -if g:jsx_pragma_required && !b:jsx_pragma_found | finish | endif - -" Do nothing if we don't have the .jsx extension (and we care). -if g:jsx_ext_required && !exists('b:jsx_ext_found') | finish | endif - " Prologue; load in XML indentation. if exists('b:did_indent') let s:did_indent=b:did_indent diff --git a/after/jsx-config.vim b/after/jsx-config.vim deleted file mode 100644 index 0303fb0..0000000 --- a/after/jsx-config.vim +++ /dev/null @@ -1,37 +0,0 @@ -if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jsx') == -1 - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Vimscript file -" -" Set up a bunch of configuration variables. -" -" Also check (if desired) whether or not the @jsx pragma is correctly included -" in '%'. Set the result in b:jsx_pragma_found. -" -" Language: JSX (JavaScript) -" Maintainer: Max Wang -" -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - -" Only check once. -if exists('b:jsx_pragma_found') - finish -endif - -" Whether the .jsx extension is required to enable JSX syntax/indent. -if !exists('g:jsx_ext_required') - let g:jsx_ext_required = 1 -endif - -" Whether the @jsx pragma is required to enable JSX syntax/indent. -if !exists('g:jsx_pragma_required') - let g:jsx_pragma_required = 0 -endif -if !g:jsx_pragma_required | finish | endif - -" Look for the @jsx pragma. It must be included in a docblock comment before -" anything else in the file (except whitespace). -let s:jsx_pragma_pattern = '\%^\_s*\/\*\*\%(\_.\%(\*\/\)\@!\)*@jsx\_.\{-}\*\/' -let b:jsx_pragma_found = search(s:jsx_pragma_pattern, 'npw') - -endif diff --git a/after/syntax/jsx.vim b/after/syntax/jsx.vim index 7efb05b..0aafca1 100644 --- a/after/syntax/jsx.vim +++ b/after/syntax/jsx.vim @@ -11,13 +11,6 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jsx') == -1 " """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Do nothing if we don't find the @jsx pragma (and we care). -exec 'source '.fnameescape(expand(':p:h:h').'/jsx-config.vim') -if g:jsx_pragma_required && !b:jsx_pragma_found | finish | endif - -" Do nothing if we don't have the .jsx extension (and we care). -if g:jsx_ext_required && !exists('b:jsx_ext_found') | finish | endif - " Prologue; load in XML syntax. if exists('b:current_syntax') let s:current_syntax=b:current_syntax @@ -28,9 +21,24 @@ if exists('s:current_syntax') let b:current_syntax=s:current_syntax endif +" Officially, vim-jsx depends on the pangloss/vim-javascript syntax package +" (and is tested against it exclusively). However, in practice, we make some +" effort towards compatibility with other packages. +" +" These are the plugin-to-syntax-element correspondences: +" +" - pangloss/vim-javascript: jsBlock, jsExpression +" - jelera/vim-javascript-syntax: javascriptBlock +" - othree/yajs.vim: javascriptNoReserved + + " Highlight JSX regions as XML; recursively match. +" +" Note that we prohibit JSX tags from having a < or word character immediately +" preceding it, to avoid conflicts with, respectively, the left shift operator +" and generic Flow type annotations (http://flowtype.org/). syn region jsxRegion contains=@XMLSyntax,jsxRegion,jsBlock,javascriptBlock - \ start=+<\@+ \ end=++ \ end=+/>+ @@ -45,7 +53,6 @@ syn region xmlString contained start=+{+ end=++ contains=jsBlock,javascriptBlock syn cluster jsExpression add=jsxRegion " Allow jsxRegion to contain reserved words. -" See: https://github.com/othree/yajs.vim syn cluster javascriptNoReserved add=jsxRegion endif diff --git a/after/syntax/rust.vim b/after/syntax/rust.vim index 5748c4d..cb13cd7 100644 --- a/after/syntax/rust.vim +++ b/after/syntax/rust.vim @@ -1,11 +1,11 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rust') == -1 -if !exists('g:rust_conceal') || !has('conceal') || &enc != 'utf-8' +if !exists('g:rust_conceal') || g:rust_conceal == 0 || !has('conceal') || &enc != 'utf-8' finish endif " For those who don't want to see `::`... -if exists('g:rust_conceal_mod_path') +if exists('g:rust_conceal_mod_path') && g:rust_conceal_mod_path != 0 syn match rustNiceOperator "::" conceal cchar=ㆍ endif @@ -20,7 +20,7 @@ syn match rustNiceOperator "=>" contains=rustFatRightArrowHead,rustFatRightArrow syn match rustNiceOperator /\<\@!_\(_*\>\)\@=/ conceal cchar=′ " For those who don't want to see `pub`... -if exists('g:rust_conceal_pub') +if exists('g:rust_conceal_pub') && g:rust_conceal_pub != 0 syn match rustPublicSigil contained "pu" conceal cchar=* syn match rustPublicRest contained "b" conceal cchar=  syn match rustNiceOperator "pub " contains=rustPublicSigil,rustPublicRest @@ -28,7 +28,7 @@ endif hi link rustNiceOperator Operator -if !exists('g:rust_conceal_mod_path') +if !exists('g:rust_conceal_mod_path') && g:rust_conceal_mod_path != 0 hi! link Conceal Operator endif diff --git a/autoload/rust.vim b/autoload/rust.vim index e6f7b05..1259139 100644 --- a/autoload/rust.vim +++ b/autoload/rust.vim @@ -36,72 +36,74 @@ endfunction " Run {{{1 function! rust#Run(bang, args) + let args = s:ShellTokenize(a:args) if a:bang - let idx = index(a:args, '--') + let idx = index(l:args, '--') if idx != -1 - let rustc_args = idx == 0 ? [] : a:args[:idx-1] - let args = a:args[idx+1:] + let rustc_args = idx == 0 ? [] : l:args[:idx-1] + let args = l:args[idx+1:] else - let rustc_args = a:args + let rustc_args = l:args let args = [] endif else let rustc_args = [] - let args = a:args endif - let b:rust_last_rustc_args = rustc_args - let b:rust_last_args = args + let b:rust_last_rustc_args = l:rustc_args + let b:rust_last_args = l:args call s:WithPath(function("s:Run"), rustc_args, args) endfunction -function! s:Run(path, rustc_args, args) - try - let exepath = tempname() - if has('win32') - let exepath .= '.exe' - endif +function! s:Run(dict, rustc_args, args) + let exepath = a:dict.tmpdir.'/'.fnamemodify(a:dict.path, ':t:r') + if has('win32') + let exepath .= '.exe' + endif - let rustc_args = [a:path, '-o', exepath] + a:rustc_args + let relpath = get(a:dict, 'tmpdir_relpath', a:dict.path) + let rustc_args = [relpath, '-o', exepath] + a:rustc_args - let rustc = exists("g:rustc_path") ? g:rustc_path : "rustc" + let rustc = exists("g:rustc_path") ? g:rustc_path : "rustc" - let output = system(shellescape(rustc) . " " . join(map(rustc_args, 'shellescape(v:val)'))) - if output != '' - echohl WarningMsg - echo output - echohl None - endif - if !v:shell_error - exe '!' . shellescape(exepath) . " " . join(map(a:args, 'shellescape(v:val)')) - endif - finally - if exists("exepath") - silent! call delete(exepath) - endif - endtry + let pwd = a:dict.istemp ? a:dict.tmpdir : '' + let output = s:system(pwd, shellescape(rustc) . " " . join(map(rustc_args, 'shellescape(v:val)'))) + if output != '' + echohl WarningMsg + echo output + echohl None + endif + if !v:shell_error + exe '!' . shellescape(exepath) . " " . join(map(a:args, 'shellescape(v:val)')) + endif endfunction " Expand {{{1 function! rust#Expand(bang, args) - if a:bang && !empty(a:args) - let pretty = a:args[0] - let args = a:args[1:] + let args = s:ShellTokenize(a:args) + if a:bang && !empty(l:args) + let pretty = remove(l:args, 0) else let pretty = "expanded" - let args = a:args endif call s:WithPath(function("s:Expand"), pretty, args) endfunction -function! s:Expand(path, pretty, args) +function! s:Expand(dict, pretty, args) try let rustc = exists("g:rustc_path") ? g:rustc_path : "rustc" - let args = [a:path, '--pretty', a:pretty] + a:args - let output = system(shellescape(rustc) . " " . join(map(args, "shellescape(v:val)"))) + if a:pretty =~? '^\%(everybody_loops$\|flowgraph=\)' + let flag = '--xpretty' + else + let flag = '--pretty' + endif + let relpath = get(a:dict, 'tmpdir_relpath', a:dict.path) + let args = [relpath, '-Z', 'unstable-options', l:flag, a:pretty] + a:args + let pwd = a:dict.istemp ? a:dict.tmpdir : '' + let output = s:system(pwd, shellescape(rustc) . " " . join(map(args, 'shellescape(v:val)'))) if v:shell_error echohl WarningMsg echo output @@ -115,6 +117,20 @@ function! s:Expand(path, pretty, args) setl buftype=nofile setl bufhidden=hide setl noswapfile + " give the buffer a nice name + let suffix = 1 + let basename = fnamemodify(a:dict.path, ':t:r') + while 1 + let bufname = basename + if suffix > 1 | let bufname .= ' ('.suffix.')' | endif + let bufname .= '.pretty.rs' + if bufexists(bufname) + let suffix += 1 + continue + endif + exe 'silent noautocmd keepalt file' fnameescape(bufname) + break + endwhile endif endtry endfunction @@ -122,7 +138,7 @@ endfunction function! rust#CompleteExpand(lead, line, pos) if a:line[: a:pos-1] =~ '^RustExpand!\s*\S*$' " first argument and it has a ! - let list = ["normal", "expanded", "typed", "expanded,identified", "flowgraph="] + let list = ["normal", "expanded", "typed", "expanded,identified", "flowgraph=", "everybody_loops"] if !empty(a:lead) call filter(list, "v:val[:len(a:lead)-1] == a:lead") endif @@ -135,72 +151,120 @@ endfunction " Emit {{{1 function! rust#Emit(type, args) - call s:WithPath(function("s:Emit"), a:type, a:args) + let args = s:ShellTokenize(a:args) + call s:WithPath(function("s:Emit"), a:type, args) endfunction -function! s:Emit(path, type, args) +function! s:Emit(dict, type, args) try + let output_path = a:dict.tmpdir.'/output' + let rustc = exists("g:rustc_path") ? g:rustc_path : "rustc" - let args = [a:path, '--emit', a:type, '-o', '-'] + a:args - let output = system(shellescape(rustc) . " " . join(map(args, "shellescape(v:val)"))) - if v:shell_error + let relpath = get(a:dict, 'tmpdir_relpath', a:dict.path) + let args = [relpath, '--emit', a:type, '-o', output_path] + a:args + let pwd = a:dict.istemp ? a:dict.tmpdir : '' + let output = s:system(pwd, shellescape(rustc) . " " . join(map(args, 'shellescape(v:val)'))) + if output != '' echohl WarningMsg echo output echohl None - else + endif + if !v:shell_error new - silent put =output + exe 'silent keepalt read' fnameescape(output_path) 1 d - if a:type == "ir" + if a:type == "llvm-ir" setl filetype=llvm + let extension = 'll' elseif a:type == "asm" setl filetype=asm + let extension = 's' endif setl buftype=nofile setl bufhidden=hide setl noswapfile + if exists('l:extension') + " give the buffer a nice name + let suffix = 1 + let basename = fnamemodify(a:dict.path, ':t:r') + while 1 + let bufname = basename + if suffix > 1 | let bufname .= ' ('.suffix.')' | endif + let bufname .= '.'.extension + if bufexists(bufname) + let suffix += 1 + continue + endif + exe 'silent noautocmd keepalt file' fnameescape(bufname) + break + endwhile + endif endif endtry endfunction " Utility functions {{{1 +" Invokes func(dict, ...) +" Where {dict} is a dictionary with the following keys: +" 'path' - The path to the file +" 'tmpdir' - The path to a temporary directory that will be deleted when the +" function returns. +" 'istemp' - 1 if the path is a file inside of {dict.tmpdir} or 0 otherwise. +" If {istemp} is 1 then an additional key is provided: +" 'tmpdir_relpath' - The {path} relative to the {tmpdir}. +" +" {dict.path} may be a path to a file inside of {dict.tmpdir} or it may be the +" existing path of the current buffer. If the path is inside of {dict.tmpdir} +" then it is guaranteed to have a '.rs' extension. function! s:WithPath(func, ...) + let buf = bufnr('') + let saved = {} + let dict = {} try - let save_write = &write + let saved.write = &write set write - let path = expand('%') - let pathisempty = empty(path) - if pathisempty || !save_write - " use a temporary file named 'unnamed.rs' inside a temporary - " directory. This produces better error messages - let tmpdir = tempname() - call mkdir(tmpdir) + let dict.path = expand('%') + let pathisempty = empty(dict.path) - let save_cwd = getcwd() - silent exe 'lcd' fnameescape(tmpdir) + " Always create a tmpdir in case the wrapped command wants it + let dict.tmpdir = tempname() + call mkdir(dict.tmpdir) - let path = 'unnamed.rs' + if pathisempty || !saved.write + let dict.istemp = 1 + " if we're doing this because of nowrite, preserve the filename + if !pathisempty + let filename = expand('%:t:r').".rs" + else + let filename = 'unnamed.rs' + endif + let dict.tmpdir_relpath = filename + let dict.path = dict.tmpdir.'/'.filename - let save_mod = &mod + let saved.mod = &mod set nomod - silent exe 'keepalt write! ' . fnameescape(path) + silent exe 'keepalt write! ' . fnameescape(dict.path) if pathisempty silent keepalt 0file endif else + let dict.istemp = 0 update endif - call call(a:func, [path] + a:000) + call call(a:func, [dict] + a:000) finally - if exists("save_mod") | let &mod = save_mod | endif - if exists("save_write") | let &write = save_write | endif - if exists("save_cwd") | silent exe 'lcd' fnameescape(save_cwd) | endif - if exists("tmpdir") | silent call s:RmDir(tmpdir) | endif + if bufexists(buf) + for [opt, value] in items(saved) + silent call setbufvar(buf, '&'.opt, value) + unlet value " avoid variable type mismatches + endfor + endif + if has_key(dict, 'tmpdir') | silent call s:RmDir(dict.tmpdir) | endif endtry endfunction @@ -210,6 +274,71 @@ function! rust#AppendCmdLine(text) return cmd endfunction +" Tokenize the string according to sh parsing rules +function! s:ShellTokenize(text) + " states: + " 0: start of word + " 1: unquoted + " 2: unquoted backslash + " 3: double-quote + " 4: double-quoted backslash + " 5: single-quote + let l:state = 0 + let l:current = '' + let l:args = [] + for c in split(a:text, '\zs') + if l:state == 0 || l:state == 1 " unquoted + if l:c ==# ' ' + if l:state == 0 | continue | endif + call add(l:args, l:current) + let l:current = '' + let l:state = 0 + elseif l:c ==# '\' + let l:state = 2 + elseif l:c ==# '"' + let l:state = 3 + elseif l:c ==# "'" + let l:state = 5 + else + let l:current .= l:c + let l:state = 1 + endif + elseif l:state == 2 " unquoted backslash + if l:c !=# "\n" " can it even be \n? + let l:current .= l:c + endif + let l:state = 1 + elseif l:state == 3 " double-quote + if l:c ==# '\' + let l:state = 4 + elseif l:c ==# '"' + let l:state = 1 + else + let l:current .= l:c + endif + elseif l:state == 4 " double-quoted backslash + if stridx('$`"\', l:c) >= 0 + let l:current .= l:c + elseif l:c ==# "\n" " is this even possible? + " skip it + else + let l:current .= '\'.l:c + endif + let l:state = 3 + elseif l:state == 5 " single-quoted + if l:c == "'" + let l:state = 1 + else + let l:current .= l:c + endif + endif + endfor + if l:state != 0 + call add(l:args, l:current) + endif + return l:args +endfunction + function! s:RmDir(path) " sanity check; make sure it's not empty, /, or $HOME if empty(a:path) @@ -222,6 +351,66 @@ function! s:RmDir(path) silent exe "!rm -rf " . shellescape(a:path) endfunction +" Executes {cmd} with the cwd set to {pwd}, without changing Vim's cwd. +" If {pwd} is the empty string then it doesn't change the cwd. +function! s:system(pwd, cmd) + let cmd = a:cmd + if !empty(a:pwd) + let cmd = 'cd ' . shellescape(a:pwd) . ' && ' . cmd + endif + return system(cmd) +endfunction + +" Playpen Support {{{1 +" Parts of gist.vim by Yasuhiro Matsumoto reused +" gist.vim available under the BSD license, available at +" http://github.com/mattn/gist-vim +function! s:has_webapi() + if !exists("*webapi#http#post") + try + call webapi#http#post() + catch + endtry + endif + return exists("*webapi#http#post") +endfunction + +function! rust#Play(count, line1, line2, ...) abort + redraw + + let l:rust_playpen_url = get(g:, 'rust_playpen_url', 'https://play.rust-lang.org/') + let l:rust_shortener_url = get(g:, 'rust_shortener_url', 'https://is.gd/') + + if !s:has_webapi() + echohl ErrorMsg | echomsg ':RustPlay depends on webapi.vim (https://github.com/mattn/webapi-vim)' | echohl None + return + endif + + let bufname = bufname('%') + if a:count < 1 + let content = join(getline(a:line1, a:line2), "\n") + else + let save_regcont = @" + let save_regtype = getregtype('"') + silent! normal! gvy + let content = @" + call setreg('"', save_regcont, save_regtype) + endif + + let body = l:rust_playpen_url."?code=".webapi#http#encodeURI(content) + + if strlen(body) > 5000 + echohl ErrorMsg | echomsg 'Buffer too large, max 5000 encoded characters ('.strlen(body).')' | echohl None + return + endif + + let payload = "format=simple&url=".webapi#http#encodeURI(body) + let res = webapi#http#post(l:rust_shortener_url.'create.php', payload, {}) + let url = res.content + + redraw | echomsg 'Done: '.url +endfunction + " }}}1 " vim: set noet sw=4 ts=4: diff --git a/autoload/rustfmt.vim b/autoload/rustfmt.vim new file mode 100644 index 0000000..20fd585 --- /dev/null +++ b/autoload/rustfmt.vim @@ -0,0 +1,83 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rust') == -1 + +" Author: Stephen Sugden +" +" Adapted from https://github.com/fatih/vim-go + +if !exists("g:rustfmt_autosave") + let g:rustfmt_autosave = 0 +endif + +if !exists("g:rustfmt_command") + let g:rustfmt_command = "rustfmt" +endif + +if !exists("g:rustfmt_options") + let g:rustfmt_options = "" +endif + +if !exists("g:rustfmt_fail_silently") + let g:rustfmt_fail_silently = 0 +endif + +let s:got_fmt_error = 0 + +function! rustfmt#Format() + let l:curw = winsaveview() + let l:tmpname = expand("%:p:h") . "/." . expand("%:p:t") . ".rustfmt" + call writefile(getline(1, '$'), l:tmpname) + + let command = g:rustfmt_command . " --write-mode=overwrite " + + let out = systemlist(command . g:rustfmt_options . " " . shellescape(l:tmpname)) + + if v:shell_error == 0 + " remove undo point caused via BufWritePre + try | silent undojoin | catch | endtry + + " Replace current file with temp file, then reload buffer + call rename(l:tmpname, expand('%')) + silent edit! + let &syntax = &syntax + + " only clear location list if it was previously filled to prevent + " clobbering other additions + if s:got_fmt_error + let s:got_fmt_error = 0 + call setloclist(0, []) + lwindow + endif + elseif g:rustfmt_fail_silently == 0 + " otherwise get the errors and put them in the location list + let errors = [] + + for line in out + " src/lib.rs:13:5: 13:10 error: expected `,`, or `}`, found `value` + let tokens = matchlist(line, '^\(.\{-}\):\(\d\+\):\(\d\+\):\s*\(\d\+:\d\+\s*\)\?\s*error: \(.*\)') + if !empty(tokens) + call add(errors, {"filename": @%, + \"lnum": tokens[2], + \"col": tokens[3], + \"text": tokens[5]}) + endif + endfor + + if empty(errors) + % | " Couldn't detect rustfmt error format, output errors + endif + + if !empty(errors) + call setloclist(0, errors, 'r') + echohl Error | echomsg "rustfmt returned error" | echohl None + endif + + let s:got_fmt_error = 1 + lwindow + " We didn't use the temp file, so clean up + call delete(l:tmpname) + endif + + call winrestview(l:curw) +endfunction + +endif diff --git a/compiler/rspec.vim b/compiler/rspec.vim index 13a7a8f..342b2a7 100644 --- a/compiler/rspec.vim +++ b/compiler/rspec.vim @@ -24,7 +24,7 @@ CompilerSet errorformat= \%f:%l:\ %tarning:\ %m, \%E%.%#:in\ `load':\ %f:%l:%m, \%E%f:%l:in\ `%*[^']':\ %m, - \%-Z\ \ \ \ \ \#\ %f:%l:%.%#, + \%-Z\ \ \ \ \ %\\+\#\ %f:%l:%.%#, \%E\ \ %\\d%\\+)%.%#, \%C\ \ \ \ \ %m, \%-G%.%# diff --git a/compiler/rustc.vim b/compiler/rustc.vim index e0aebba..e6a53cd 100644 --- a/compiler/rustc.vim +++ b/compiler/rustc.vim @@ -17,7 +17,7 @@ if exists(":CompilerSet") != 2 command -nargs=* CompilerSet setlocal endif -if exists("g:rustc_makeprg_no_percent") && g:rustc_makeprg_no_percent == 1 +if exists("g:rustc_makeprg_no_percent") && g:rustc_makeprg_no_percent != 0 CompilerSet makeprg=rustc else CompilerSet makeprg=rustc\ \% diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index d4b4427..ae2d8a4 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -134,6 +134,30 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jasmine') == -1 autocmd BufNewFile,BufRead *Spec.js,*_spec.js set filetype=jasmine.javascript syntax=jasmine endif +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jsx') == -1 + +if !exists('g:jsx_ext_required') + let g:jsx_ext_required = 1 +endif +if !exists('g:jsx_pragma_required') + let g:jsx_pragma_required = 0 +endif +if g:jsx_pragma_required + " Look for the @jsx pragma. It must be included in a docblock comment before + " anything else in the file (except whitespace). + let s:jsx_pragma_pattern = '\%^\_s*\/\*\*\%(\_.\%(\*\/\)\@!\)*@jsx\_.\{-}\*\/' + let b:jsx_pragma_found = search(s:jsx_pragma_pattern, 'npw') +endif +fu! EnableJSX() + if g:jsx_pragma_required && !b:jsx_pragma_found | return 0 | endif + if g:jsx_ext_required && !exists('b:jsx_ext_found') | return 0 | endif + return 1 +endfu +autocmd BufNewFile,BufRead *.jsx let b:jsx_ext_found = 1 +autocmd BufNewFile,BufRead *.jsx set filetype=javascript.jsx +autocmd BufNewFile,BufRead *.js + \ if EnableJSX() | set filetype=javascript.jsx | endif +endif if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'json') == -1 autocmd BufNewFile,BufRead *.json set filetype=json @@ -205,7 +229,7 @@ au BufRead,BufNewFile /etc/nginx/*,/usr/local/nginx/*,*/nginx/vhosts.d/*,nginx.c endif if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'opencl') == -1 -au BufRead,BufNewFile *.cl set filetype=opencl +au! BufRead,BufNewFile *.cl set filetype=opencl endif if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'perl') == -1 @@ -327,7 +351,17 @@ autocmd BufNewFile,BufReadPost *.stylus set filetype=stylus endif if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'swift') == -1 -autocmd BufNewFile,BufRead *.swift set filetype=swift +autocmd BufNewFile,BufRead *.swift setfiletype swift +autocmd BufRead * call s:Swift() +function! s:Swift() + if !empty(&filetype) + return + endif + let line = getline(1) + if line =~ "^#!.*swift" + setfiletype swift + endif +endfunction endif if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'systemd') == -1 diff --git a/ftplugin/ruby.vim b/ftplugin/ruby.vim index 0eb32b6..9a2283e 100644 --- a/ftplugin/ruby.vim +++ b/ftplugin/ruby.vim @@ -46,7 +46,7 @@ endif setlocal formatoptions-=t formatoptions+=croql setlocal include=^\\s*\\<\\(load\\>\\\|require\\>\\\|autoload\\s*:\\=[\"']\\=\\h\\w*[\"']\\=,\\) -setlocal includeexpr=substitute(substitute(v:fname,'::','/','g'),'$','.rb','') +setlocal includeexpr=substitute(substitute(v:fname,'::','/','g'),'\%(\.rb\)\=$','.rb','') setlocal suffixesadd=.rb if exists("&ofu") && has("ruby") @@ -361,7 +361,7 @@ function! RubyCursorFile() abort endtry let pre = matchstr(strpart(getline('.'), 0, col('.')-1), '.*\f\@' ? '.rb' : '' + let ext = getline('.') =~# '^\s*\%(require\%(_relative\)\=\|autoload\)\>' && cfile !~# '\.rb$' ? '.rb' : '' if s:synname() ==# 'rubyConstant' let cfile = substitute(cfile,'\.\w\+[?!=]\=$','','') let cfile = substitute(cfile,'::','/','g') @@ -369,7 +369,7 @@ function! RubyCursorFile() abort let cfile = substitute(cfile,'\(\l\|\d\)\(\u\)','\1_\2', 'g') return tolower(cfile) . '.rb' elseif getline('.') =~# '^\s*require_relative\s*\(["'']\).*\1\s*$' - let cfile = expand('%:p:h') . '/' . matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1') . '.rb' + let cfile = expand('%:p:h') . '/' . matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1') . ext elseif getline('.') =~# '^\s*\%(require[( ]\|load[( ]\|autoload[( ]:\w\+,\)\s*\%(::\)\=File\.expand_path(\(["'']\)\.\./.*\1,\s*__FILE__)\s*$' let target = matchstr(getline('.'),'\(["'']\)\.\.\zs/.\{-\}\ze\1') let cfile = expand('%:p:h') . target . ext diff --git a/ftplugin/rust.vim b/ftplugin/rust.vim index ace6788..e7c604e 100644 --- a/ftplugin/rust.vim +++ b/ftplugin/rust.vim @@ -4,7 +4,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rust') == -1 " Description: Vim syntax file for Rust " Maintainer: Chris Morgan " Maintainer: Kevin Ballard -" Last Change: Jul 07, 2014 +" Last Change: January 29, 2015 if exists("b:did_ftplugin") finish @@ -20,7 +20,7 @@ set cpo&vim " comments, so we'll use that as our default, but make it easy to switch. " This does not affect indentation at all (I tested it with and without " leader), merely whether a leader is inserted by default or not. -if exists("g:rust_bang_comment_leader") && g:rust_bang_comment_leader == 1 +if exists("g:rust_bang_comment_leader") && g:rust_bang_comment_leader != 0 " Why is the `,s0:/*,mb:\ ,ex:*/` there, you ask? I don't understand why, " but without it, */ gets indented one space even if there were no " leaders. I'm fairly sure that's a Vim bug. @@ -37,7 +37,7 @@ silent! setlocal formatoptions+=j " otherwise it's better than nothing. setlocal smartindent nocindent -if !exists("g:rust_recommended_style") || g:rust_recommended_style == 1 +if !exists("g:rust_recommended_style") || g:rust_recommended_style != 0 setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab setlocal textwidth=99 endif @@ -69,7 +69,7 @@ if has("folding") && exists('g:rust_fold') && g:rust_fold != 0 endif endif -if has('conceal') && exists('g:rust_conceal') +if has('conceal') && exists('g:rust_conceal') && g:rust_conceal != 0 let b:rust_set_conceallevel=1 setlocal conceallevel=2 endif @@ -84,19 +84,35 @@ xnoremap ]] :call rust#Jump('v', 'Forward') onoremap [[ :call rust#Jump('o', 'Back') onoremap ]] :call rust#Jump('o', 'Forward') +" %-matching. <:> is handy for generics. +set matchpairs+=<:> +" There are two minor issues with it; (a) comparison operators in expressions, +" where a less-than may match a greater-than later on—this is deemed a trivial +" issue—and (b) `Fn() -> X` syntax. This latter issue is irremediable from the +" highlighting perspective (built into Vim), but the actual % functionality +" can be fixed by this use of matchit.vim. +let b:match_skip = 's:comment\|string\|rustArrow' +source $VIMRUNTIME/macros/matchit.vim + " Commands {{{1 " See |:RustRun| for docs -command! -nargs=* -complete=file -bang -bar -buffer RustRun call rust#Run(0, []) +command! -nargs=* -complete=file -bang -buffer RustRun call rust#Run(0, ) " See |:RustExpand| for docs -command! -nargs=* -complete=customlist,rust#CompleteExpand -bang -bar -buffer RustExpand call rust#Expand(0, []) +command! -nargs=* -complete=customlist,rust#CompleteExpand -bang -buffer RustExpand call rust#Expand(0, ) " See |:RustEmitIr| for docs -command! -nargs=* -bar -buffer RustEmitIr call rust#Emit("ir", []) +command! -nargs=* -buffer RustEmitIr call rust#Emit("llvm-ir", ) " See |:RustEmitAsm| for docs -command! -nargs=* -bar -buffer RustEmitAsm call rust#Emit("asm", []) +command! -nargs=* -buffer RustEmitAsm call rust#Emit("asm", ) + +" See |:RustPlay| for docs +command! -range=% RustPlay :call rust#Play(, , , ) + +" See |:RustFmt| for docs +command! -buffer RustFmt call rustfmt#Format() " Mappings {{{1 @@ -134,6 +150,7 @@ let b:undo_ftplugin = " \|delcommand RustExpand \|delcommand RustEmitIr \|delcommand RustEmitAsm + \|delcommand RustPlay \|nunmap \|nunmap \|nunmap [[ @@ -142,6 +159,8 @@ let b:undo_ftplugin = " \|xunmap ]] \|ounmap [[ \|ounmap ]] + \|set matchpairs-=<:> + \|unlet b:match_skip \" " }}}1 diff --git a/ftplugin/swift.vim b/ftplugin/swift.vim new file mode 100644 index 0000000..f24535e --- /dev/null +++ b/ftplugin/swift.vim @@ -0,0 +1,8 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'swift') == -1 + +setlocal commentstring=//\ %s +" @-@ adds the literal @ to iskeyword for @IBAction and similar +setlocal iskeyword+=@-@,# +setlocal completefunc=syntaxcomplete#Complete + +endif diff --git a/indent/handlebars.vim b/indent/handlebars.vim new file mode 100644 index 0000000..a3ffbb8 --- /dev/null +++ b/indent/handlebars.vim @@ -0,0 +1,104 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'handlebars') == -1 + +" Mustache & Handlebars syntax +" Language: Mustache, Handlebars +" Maintainer: Juvenn Woo +" Screenshot: http://imgur.com/6F408 +" Version: 2 +" Last Change: Oct 10th 2015 +" Remarks: based on eruby indent plugin by tpope +" References: +" [Mustache](http://github.com/defunkt/mustache) +" [Handlebars](https://github.com/wycats/handlebars.js) +" [ctemplate](http://code.google.com/p/google-ctemplate/) +" [ctemplate doc](http://google-ctemplate.googlecode.com/svn/trunk/doc/howto.html) +" [et](http://www.ivan.fomichev.name/2008/05/erlang-template-engine-prototype.html) + +if exists("b:did_indent_hbs") + finish +endif + +unlet! b:did_indent +setlocal indentexpr= + +runtime! indent/html.vim +unlet! b:did_indent + +" Force HTML indent to not keep state. +let b:html_indent_usestate = 0 + +if &l:indentexpr == '' + if &l:cindent + let &l:indentexpr = 'cindent(v:lnum)' + else + let &l:indentexpr = 'indent(prevnonblank(v:lnum-1))' + endif +endif +let b:handlebars_subtype_indentexpr = &l:indentexpr + +let b:did_indent = 1 +let b:did_indent_hbs = 1 + +setlocal indentexpr=GetHandlebarsIndent() +setlocal indentkeys=o,O,*,<>>,{,},0),0],o,O,!^F,=end,=else,=elsif,=rescue,=ensure,=when + +" Only define the function once. +if exists("*GetHandlebarsIndent") + finish +endif + +function! GetHandlebarsIndent(...) + " The value of a single shift-width + if exists('*shiftwidth') + let sw = shiftwidth() + else + let sw = &sw + endif + + if a:0 && a:1 == '.' + let v:lnum = line('.') + elseif a:0 && a:1 =~ '^\d' + let v:lnum = a:1 + endif + let vcol = col('.') + call cursor(v:lnum,1) + call cursor(v:lnum,vcol) + exe "let ind = ".b:handlebars_subtype_indentexpr + + " Workaround for Andy Wokula's HTML indent. This should be removed after + " some time, since the newest version is fixed in a different way. + if b:handlebars_subtype_indentexpr =~# '^HtmlIndent(' + \ && exists('b:indent') + \ && type(b:indent) == type({}) + \ && has_key(b:indent, 'lnum') + " Force HTML indent to not keep state + let b:indent.lnum = -1 + endif + let lnum = prevnonblank(v:lnum-1) + let line = getline(lnum) + let cline = getline(v:lnum) + + " all indent rules only apply if the block opening/closing + " tag is on a separate line + + " indent after block {{#block + if line =~# '\v\s*\{\{\#.*\s*' + let ind = ind + sw + endif + " unindent after block close {{/block}} + if cline =~# '\v^\s*\{\{\/\S*\}\}\s*' + let ind = ind - sw + endif + " unindent {{else}} + if cline =~# '\v^\s*\{\{else.*\}\}\s*$' + let ind = ind - sw + endif + " indent again after {{else}} + if line =~# '\v^\s*\{\{else.*\}\}\s*$' + let ind = ind + sw + endif + + return ind +endfunction + +endif diff --git a/indent/rust.vim b/indent/rust.vim index 3033f06..0a3c334 100644 --- a/indent/rust.vim +++ b/indent/rust.vim @@ -123,6 +123,13 @@ function GetRustIndent(lnum) let prevlinenum = prevnonblank(prevlinenum - 1) let prevline = s:get_line_trimmed(prevlinenum) endwhile + + " Handle where clauses nicely: subsequent values should line up nicely. + if prevline[len(prevline) - 1] == "," + \ && prevline =~# '^\s*where\s' + return indent(prevlinenum) + 6 + endif + if prevline[len(prevline) - 1] == "," \ && s:get_line_trimmed(a:lnum) !~ '^\s*[\[\]{}]' \ && prevline !~ '^\s*fn\s' diff --git a/indent/swift.vim b/indent/swift.vim index 472b3cf..ba6d65e 100644 --- a/indent/swift.vim +++ b/indent/swift.vim @@ -1,19 +1,230 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'swift') == -1 -" Language: Swift -" Maintainer: toyama satoshi -" URL: http://github.com/toyamarinyon/vim-swift -" License: GPL +" File: swift.vim +" Author: Keith Smiley +" Description: The indent file for Swift +" Last Modified: December 05, 2014 -" Only load this indent file when no other was loaded. if exists("b:did_indent") - finish + finish endif let b:did_indent = 1 -" C indenting is built-in, thus this is very simple -setlocal cindent +let s:cpo_save = &cpo +set cpo&vim -let b:undo_indent = "setl cin<" +setlocal nosmartindent +setlocal indentkeys-=: +setlocal indentkeys-=e +setlocal indentkeys+=0] +setlocal indentexpr=SwiftIndent() + +function! s:NumberOfMatches(char, string, index) + let instances = 0 + let i = 0 + while i < strlen(a:string) + if a:string[i] == a:char && !s:IsExcludedFromIndentAtPosition(a:index, i + 1) + let instances += 1 + endif + + let i += 1 + endwhile + + return instances +endfunction + +function! s:SyntaxNameAtPosition(line, column) + return synIDattr(synID(a:line, a:column, 0), "name") +endfunction + +function! s:SyntaxName() + return s:SyntaxNameAtPosition(line("."), col(".")) +endfunction + +function! s:IsExcludedFromIndentAtPosition(line, column) + let name = s:SyntaxNameAtPosition(a:line, a:column) + return name ==# "swiftComment" || name ==# "swiftString" +endfunction + +function! s:IsExcludedFromIndent() + return s:SyntaxName() ==# "swiftComment" || s:SyntaxName() ==# "swiftString" +endfunction + +function! s:IsCommentLine(lnum) + return synIDattr(synID(a:lnum, + \ match(getline(a:lnum), "\S") + 1, 0), "name") + \ ==# "swiftComment" +endfunction + +function! SwiftIndent(...) + let clnum = a:0 ? a:1 : v:lnum + + let line = getline(clnum) + let previousNum = prevnonblank(clnum - 1) + while s:IsCommentLine(previousNum) != 0 + let previousNum = prevnonblank(previousNum - 1) + endwhile + + let previous = getline(previousNum) + let cindent = cindent(clnum) + let previousIndent = indent(previousNum) + + let numOpenParens = s:NumberOfMatches("(", previous, previousNum) + let numCloseParens = s:NumberOfMatches(")", previous, previousNum) + let numOpenBrackets = s:NumberOfMatches("{", previous, previousNum) + let numCloseBrackets = s:NumberOfMatches("}", previous, previousNum) + + let currentOpenBrackets = s:NumberOfMatches("{", line, clnum) + let currentCloseBrackets = s:NumberOfMatches("}", line, clnum) + + let numOpenSquare = s:NumberOfMatches("[", previous, previousNum) + let numCloseSquare = s:NumberOfMatches("]", previous, previousNum) + + let currentCloseSquare = s:NumberOfMatches("]", line, clnum) + if numOpenSquare > numCloseSquare && currentCloseSquare < 1 + return previousIndent + shiftwidth() + endif + + if currentCloseSquare > 0 && line !~ '\v\[.*\]' + let column = col(".") + call cursor(line("."), 1) + let openingSquare = searchpair("\\[", "", "\\]", "bWn", "s:IsExcludedFromIndent()") + call cursor(line("."), column) + + if openingSquare == 0 + return -1 + endif + + return indent(openingSquare) + endif + + if s:IsExcludedFromIndent() + return previousIndent + endif + + if line =~ ":$" + let switch = search("switch", "bWn") + return indent(switch) + elseif previous =~ ":$" + return previousIndent + shiftwidth() + endif + + if numOpenParens == numCloseParens + if numOpenBrackets > numCloseBrackets + if currentCloseBrackets > currentOpenBrackets || line =~ "\\v^\\s*}" + let column = col(".") + call cursor(line("."), 1) + let openingBracket = searchpair("{", "", "}", "bWn", "s:IsExcludedFromIndent()") + call cursor(line("."), column) + if openingBracket == 0 + return -1 + else + return indent(openingBracket) + endif + endif + + return previousIndent + shiftwidth() + elseif previous =~ "}.*{" + if line =~ "\\v^\\s*}" + return previousIndent + endif + + return previousIndent + shiftwidth() + elseif line =~ "}.*{" + let openingBracket = searchpair("{", "", "}", "bWn", "s:IsExcludedFromIndent()") + return indent(openingBracket) + elseif currentCloseBrackets > currentOpenBrackets + let column = col(".") + call cursor(line("."), 1) + let openingBracket = searchpair("{", "", "}", "bWn", "s:IsExcludedFromIndent()") + call cursor(line("."), column) + + let bracketLine = getline(openingBracket) + + let numOpenParensBracketLine = s:NumberOfMatches("(", bracketLine, openingBracket) + let numCloseParensBracketLine = s:NumberOfMatches(")", bracketLine, openingBracket) + if numCloseParensBracketLine > numOpenParensBracketLine + let line = line(".") + let column = col(".") + call cursor(openingParen, column) + let openingParen = searchpair("(", "", ")", "bWn", "s:IsExcludedFromIndent()") + call cursor(line, column) + return indent(openingParen) + endif + return indent(openingBracket) + else + return -1 + endif + endif + + if numCloseParens > 0 + if currentOpenBrackets > 0 || currentCloseBrackets > 0 + if currentOpenBrackets > 0 + if numOpenBrackets > numCloseBrackets + return previousIndent + shiftwidth() + endif + + if line =~ "}.*{" + let openingBracket = searchpair("{", "", "}", "bWn", "s:IsExcludedFromIndent()") + return indent(openingBracket) + endif + + if numCloseParens > numOpenParens + let line = line(".") + let column = col(".") + call cursor(line - 1, column) + let openingParen = searchpair("(", "", ")", "bWn", "s:IsExcludedFromIndent()") + call cursor(line, column) + return indent(openingParen) + endif + + return previousIndent + endif + + if currentCloseBrackets > 0 + let openingBracket = searchpair("{", "", "}", "bWn", "s:IsExcludedFromIndent()") + return indent(openingBracket) + endif + + return cindent + endif + + if numCloseParens < numOpenParens + if numOpenBrackets > numCloseBrackets + return previousIndent + shiftwidth() + endif + + let previousParen = match(previous, "(") + return previousParen + 1 + endif + + if numOpenBrackets > numCloseBrackets + let line = line(".") + let column = col(".") + call cursor(previousNum, column) + let openingParen = searchpair("(", "", ")", "bWn", "s:IsExcludedFromIndent()") + call cursor(line, column) + return indent(openingParen) + shiftwidth() + endif + + let line = line(".") + let column = col(".") + call cursor(previousNum, column) + let openingParen = searchpair("(", "", ")", "bWn", "s:IsExcludedFromIndent()") + call cursor(line, column) + + return indent(openingParen) + endif + + if numOpenParens > 0 + let previousParen = match(previous, "(") + return previousParen + 1 + endif + + return cindent +endfunction + +let &cpo = s:cpo_save +unlet s:cpo_save endif diff --git a/syntax/cpp.vim b/syntax/cpp.vim index aa242e4..8f440aa 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -25,7 +25,8 @@ endif " C++ extensions syn keyword cppStatement new delete this friend using syn keyword cppAccess public protected private -syn keyword cppType inline virtual explicit export bool wchar_t +syn keyword cppModifier inline virtual explicit export +syn keyword cppType bool wchar_t syn keyword cppExceptions throw try catch syn keyword cppOperator operator typeid syn keyword cppOperator and bitor or xor compl bitand and_eq or_eq xor_eq not not_eq @@ -38,7 +39,8 @@ syn keyword cppConstant __cplusplus " C++ 11 extensions if !exists("cpp_no_cpp11") - syn keyword cppType override final + syn keyword cppModifier override final + syn keyword cppType nullptr_t syn keyword cppExceptions noexcept syn keyword cppStorageClass constexpr decltype thread_local syn keyword cppConstant nullptr @@ -72,6 +74,7 @@ if version >= 508 || !exists("did_cpp_syntax_inits") HiLink cppExceptions Exception HiLink cppOperator Operator HiLink cppStatement Statement + HiLink cppModifier Type HiLink cppType Type HiLink cppStorageClass StorageClass HiLink cppStructure Structure diff --git a/syntax/elixir.vim b/syntax/elixir.vim index 26374cf..f2c5829 100644 --- a/syntax/elixir.vim +++ b/syntax/elixir.vim @@ -17,7 +17,7 @@ syn cluster elixirNotTop contains=@elixirRegexSpecial,@elixirStringContained,@el syn match elixirComment '#.*' contains=elixirTodo syn keyword elixirTodo FIXME NOTE TODO OPTIMIZE XXX HACK contained -syn keyword elixirKeyword case when cond for if unless try receive send +syn keyword elixirKeyword case when cond for if unless try receive spawn send syn keyword elixirKeyword exit raise throw after rescue catch else do end syn keyword elixirKeyword quote unquote super diff --git a/syntax/gitrebase.vim b/syntax/gitrebase.vim index 4fe38e8..025c9a3 100644 --- a/syntax/gitrebase.vim +++ b/syntax/gitrebase.vim @@ -4,7 +4,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'git') == -1 " Language: git rebase --interactive " Maintainer: Tim Pope " Filenames: git-rebase-todo -" Last Change: 2012 April 7 +" Last Change: 2015 November 21 if exists("b:current_syntax") finish @@ -20,6 +20,7 @@ syn match gitrebaseEdit "\v^e%(dit)=>" nextgroup=gitrebaseCommit skipwhite syn match gitrebaseSquash "\v^s%(quash)=>" nextgroup=gitrebaseCommit skipwhite syn match gitrebaseFixup "\v^f%(ixup)=>" nextgroup=gitrebaseCommit skipwhite syn match gitrebaseExec "\v^%(x|exec)>" nextgroup=gitrebaseCommand skipwhite +syn match gitrebaseDrop "\v^d%(rop)=>" nextgroup=gitrebaseCommit skipwhite syn match gitrebaseSummary ".*" contains=gitrebaseHash contained syn match gitrebaseCommand ".*" contained syn match gitrebaseComment "^#.*" contains=gitrebaseHash diff --git a/syntax/go.vim b/syntax/go.vim index 804608b..4cd53c4 100644 --- a/syntax/go.vim +++ b/syntax/go.vim @@ -56,23 +56,23 @@ if !exists("g:go_highlight_trailing_whitespace_error") endif if !exists("g:go_highlight_operators") - let g:go_highlight_operators = 0 + let g:go_highlight_operators = 0 endif if !exists("g:go_highlight_functions") - let g:go_highlight_functions = 0 + let g:go_highlight_functions = 0 endif if !exists("g:go_highlight_methods") - let g:go_highlight_methods = 0 + let g:go_highlight_methods = 0 endif if !exists("g:go_highlight_structs") - let g:go_highlight_structs = 0 + let g:go_highlight_structs = 0 endif if !exists("g:go_highlight_build_constraints") - let g:go_highlight_build_constraints = 0 + let g:go_highlight_build_constraints = 0 endif if !exists("g:go_highlight_string_spellcheck") @@ -119,8 +119,8 @@ syn match goDeclaration /\/ " Predefined functions and values -syn keyword goBuiltins append cap close complex copy delete imag len -syn keyword goBuiltins make new panic print println real recover +syn match goBuiltins /\<\v(append|cap|close|complex|copy|delete|imag|len)\ze\(/ +syn match goBuiltins /\<\v(make|new|panic|print|println|real|recover)\ze\(/ syn keyword goBoolean iota true false nil hi def link goBuiltins Keyword @@ -164,7 +164,7 @@ syn match goFormatSpecifier /%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\ hi def link goString String hi def link goRawString String -hi def link goFormatSpecifier goSpecialString +hi def link goFormatSpecifier goSpecialString " Characters; their contents syn cluster goCharacterGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU @@ -249,55 +249,74 @@ hi def link goTodo Todo " Operators; if g:go_highlight_operators != 0 - " match single-char operators: - + % < > ! & | ^ * = - " and corresponding two-char operators: -= += %= <= >= != &= |= ^= *= == - syn match goOperator /[-+%<>!&|^*=]=\?/ - " match / and /= - syn match goOperator /\/\%(=\|\ze[^/*]\)/ - " match two-char operators: << >> &^ - " and corresponding three-char operators: <<= >>= &^= - syn match goOperator /\%(<<\|>>\|&^\)=\?/ - " match remaining two-char operators: := && || <- ++ -- - syn match goOperator /:=\|||\|<-\|++\|--/ - " match ... - syn match goOperator /\.\.\./ + " match single-char operators: - + % < > ! & | ^ * = + " and corresponding two-char operators: -= += %= <= >= != &= |= ^= *= == + syn match goOperator /[-+%<>!&|^*=]=\?/ + " match / and /= + syn match goOperator /\/\%(=\|\ze[^/*]\)/ + " match two-char operators: << >> &^ + " and corresponding three-char operators: <<= >>= &^= + syn match goOperator /\%(<<\|>>\|&^\)=\?/ + " match remaining two-char operators: := && || <- ++ -- + syn match goOperator /:=\|||\|<-\|++\|--/ + " match ... + syn match goOperator /\.\.\./ endif -hi def link goOperator Operator +hi def link goOperator Operator " Functions; if g:go_highlight_functions != 0 - syn match goFunction /\(func\s\+\)\@<=\w\+\((\)\@=/ - syn match goFunction /\()\s\+\)\@<=\w\+\((\)\@=/ + syn match goFunction /\(func\s\+\)\@<=\w\+\((\)\@=/ + syn match goFunction /\()\s\+\)\@<=\w\+\((\)\@=/ endif -hi def link goFunction Function +hi def link goFunction Function " Methods; if g:go_highlight_methods != 0 - syn match goMethod /\(\.\)\@<=\w\+\((\)\@=/ + syn match goMethod /\(\.\)\@<=\w\+\((\)\@=/ endif -hi def link goMethod Type +hi def link goMethod Type " Structs; if g:go_highlight_structs != 0 - syn match goStruct /\(.\)\@<=\w\+\({\)\@=/ - syn match goStructDef /\(type\s\+\)\@<=\w\+\(\s\+struct\s\+{\)\@=/ + syn match goStruct /\(.\)\@<=\w\+\({\)\@=/ + syn match goStructDef /\(type\s\+\)\@<=\w\+\(\s\+struct\s\+{\)\@=/ endif -hi def link goStruct Function +hi def link goStruct Function hi def link goStructDef Function " Build Constraints if g:go_highlight_build_constraints != 0 - syn keyword goBuildOs contained ignore cgo android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows - syn keyword goBuildArch contained 386 amd64 amd64p32 arm - syn match goBuildDirective display contained "+build" - syn region goBuildComment start="//\s*+build" end="$" contains=goBuildDirective,goBuildOs,goBuildArch - syn region goBuildComment start="/\*\s*+build" end="\*/" contains=goBuildDirective,goBuildOs,goBuildArch -endif + syn match goBuildKeyword display contained "+build" + " Highlight the known values of GOOS, GOARCH, and other +build options. + syn keyword goBuildDirectives contained + \ android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 + \ solaris windows 386 amd64 amd64p32 arm armbe arm64 arm64be ppc64 + \ ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32le ppc + \ s390 s390x sparc sparc64 cgo ignore race -hi def link goBuildComment Comment -hi def link goBuildOs Type -hi def link goBuildArch Type -hi def link goBuildDirective PreProc + " Other words in the build directive are build tags not listed above, so + " avoid highlighting them as comments by using a matchgroup just for the + " start of the comment. + " The rs=s+2 option lets the \s*+build portion be part of the inner region + " instead of the matchgroup so it will be highlighted as a goBuildKeyword. + syn region goBuildComment matchgroup=goBuildCommentStart + \ start="//\s*+build\s"rs=s+2 end="$" + \ contains=goBuildKeyword,goBuildDirectives + hi def link goBuildCommentStart Comment + hi def link goBuildDirectives Type + hi def link goBuildKeyword PreProc + + " One or more line comments that are followed immediately by a "package" + " declaration are treated like package documentation, so these must be + " matched as comments to avoid looking like working build constraints. + " The he, me, and re options let the "package" itself be highlighted by + " the usual rules. + syn region goPackageComment start=/\v(\/\/.*\n)+\s*package/ + \ end=/\v\n\s*package/he=e-7,me=e-7,re=e-7 + \ contains=@goCommentGroup,@Spell + hi def link goPackageComment Comment +endif " Search backwards for a global declaration to start processing the syntax. diff --git a/syntax/gotexttmpl.vim b/syntax/gotexttmpl.vim index 77b26e4..14b8bf8 100644 --- a/syntax/gotexttmpl.vim +++ b/syntax/gotexttmpl.vim @@ -39,7 +39,7 @@ hi def link goRawString String " Characters; their contents syn cluster goCharacterGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU -syn region goCharacter start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=@goCharacterGroup +syn region goCharacter contained start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=@goCharacterGroup hi def link goCharacter Character @@ -67,7 +67,7 @@ hi def link goImaginary Number syn cluster gotplLiteral contains=goString,goRawString,goCharacter,@goInt,goFloat,goImaginary syn keyword gotplControl contained if else end range with template syn keyword gotplFunctions contained and html index js len not or print printf println urlquery eq ne lt le gt ge -syn match gotplVariable contained /\$[^ ]*\>/ +syn match gotplVariable contained /\$[a-zA-Z0-9_]*\>/ syn match goTplIdentifier contained /\.[^\s}]*\>/ hi def link gotplControl Keyword diff --git a/syntax/jade.vim b/syntax/jade.vim index c14ee69..27f2da8 100644 --- a/syntax/jade.vim +++ b/syntax/jade.vim @@ -18,6 +18,8 @@ silent! syntax include @htmlCoffeescript syntax/coffee.vim unlet! b:current_syntax silent! syntax include @htmlStylus syntax/stylus.vim unlet! b:current_syntax +silent! syntax include @htmlCss syntax/css.vim +unlet! b:current_syntax silent! syntax include @htmlMarkdown syntax/markdown.vim unlet! b:current_syntax @@ -37,7 +39,7 @@ syn region jadeCommentBlock start="\z(\s*\)\/\/.*$" end="^\%(\z1\s\|\s*$\)\@!" syn region jadeHtmlConditionalComment start="" syn region jadeAttributes matchgroup=jadeAttributesDelimiter start="(" end=")" contained contains=@htmlJavascript,jadeHtmlArg,htmlArg,htmlEvent,htmlCssDefinition nextgroup=@jadeComponent syn match jadeClassChar "\." contained nextgroup=jadeClass -syn match jadeBlockExpansionChar ":\s\+" contained nextgroup=jadeTag +syn match jadeBlockExpansionChar ":\s\+" contained nextgroup=jadeTag,jadeClassChar,jadeIdChar syn match jadeIdChar "#[[{]\@!" contained nextgroup=jadeId syn match jadeClass "\%(\w\|-\)\+" contained nextgroup=@jadeComponent syn match jadeId "\%(\w\|-\)\+" contained nextgroup=@jadeComponent @@ -69,7 +71,7 @@ syn keyword jadeScriptLoopKeywords for in contained syn region jadeJavascript start="^\z(\s*\)script\%(:\w\+\)\=" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlJavascript,jadeJavascriptTag,jadeCoffeescriptFilter keepend -syn region jadeCoffeescriptFilter matchgroup=jadeFilter start="^\z(\s*\):coffeescript\s*$" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlCoffeescript contained +syn region jadeCoffeescriptFilter matchgroup=jadeFilter start="^\z(\s*\):coffee-\?script\s*$" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlCoffeescript contained syn region jadeJavascriptTag contained start="^\z(\s*\)script\%(:\w\+\)\=" end="$" contains=jadeBegin,jadeTag syn region jadeCssBlock start="^\z(\s*\)style" nextgroup=@jadeComponent,jadeError end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlCss keepend diff --git a/syntax/perl.vim b/syntax/perl.vim index e272d97..6e6e6ef 100644 --- a/syntax/perl.vim +++ b/syntax/perl.vim @@ -424,7 +424,7 @@ if exists("perl_fold") endif if exists("perl_fold_blocks") - syn region perlBlockFold start="^\z(\s*\)\%(if\|elsif\|unless\|for\|while\|until\|given\)\s*(.*)\%(\s*{\)\=\s*\%(#.*\)\=$" start="^\z(\s*\)foreach\s*\%(\%(my\|our\)\=\s*\S\+\s*\)\=(.*)\%(\s*{\)\=\s*\%(#.*\)\=$" end="^\z1}\s*;\=\%(#.*\)\=$" transparent fold keepend + syn region perlBlockFold start="^\z(\s*\)\%(if\|elsif\|unless\|for\|while\|until\|given\)\s*(.*)\%(\s*{\)\=\s*\%(#.*\)\=$" start="^\z(\s*\)for\%(each\)\=\s*\%(\%(my\|our\)\=\s*\S\+\s*\)\=(.*)\%(\s*{\)\=\s*\%(#.*\)\=$" end="^\z1}\s*;\=\%(#.*\)\=$" transparent fold keepend syn region perlBlockFold start="^\z(\s*\)\%(do\|else\)\%(\s*{\)\=\s*\%(#.*\)\=$" end="^\z1}\s*while" end="^\z1}\s*;\=\%(#.*\)\=$" transparent fold keepend endif diff --git a/syntax/php.vim b/syntax/php.vim index 4272402..ba39603 100644 --- a/syntax/php.vim +++ b/syntax/php.vim @@ -521,7 +521,7 @@ syn keyword phpStatement __construct __destruct __call __callStatic __get __set syn keyword phpKeyword die exit eval empty isset unset list instanceof insteadof contained " Include & friends -syn keyword phpInclude include include_once require require_once namespace use contained +syn keyword phpInclude include include_once require require_once namespace contained " Types syn keyword phpType bool[ean] int[eger] real double float string array object null self parent global this stdClass callable contained @@ -681,6 +681,16 @@ syntax match phpClassImplements contained syntax match phpClassDelimiter contained \ nextgroup=phpClassImplements skipwhite skipempty /,/ +" use statement +syn keyword phpInclude use contained + \ nextgroup=phpUseFunction,phpUseClass skipwhite skipempty +syn match phpUseFunction /function\_s\+\(\\\|\h\w*\)*\h\w*/ contained contains=phpUseKeyword + \ nextgroup=phpUseAlias skipwhite skipempty +syn match phpUseClass /\(function\_s\+\)\@!\(\\\|\h\w*\)*\h\w*/ contained + \ nextgroup=phpUseAlias skipwhite skipempty +syn match phpUseAlias /as\_s\+\h\w*/ contained contains=phpUseKeyword +syn match phpUseKeyword /\(function\|as\)\_s\+/ contained contains=phpKeyword + " Function name syn keyword phpKeyword function contained \ nextgroup=phpFunction skipwhite skipempty diff --git a/syntax/python.vim b/syntax/python.vim index 0991292..b55dc65 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -88,6 +88,7 @@ syn keyword pythonStatement exec return syn keyword pythonStatement pass raise syn keyword pythonStatement global assert syn keyword pythonStatement lambda yield +syn keyword pythonStatement async await syn keyword pythonStatement with nonlocal True False None syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" display contained @@ -210,7 +211,7 @@ if exists("python_highlight_builtins") && python_highlight_builtins != 0 syn keyword pythonBuiltinObj Ellipsis NotImplemented syn keyword pythonBuiltinFunc __import__ abs all any apply - syn keyword pythonBuiltinFunc basestring bool buffer callable + syn keyword pythonBuiltinFunc basestring bool buffer bytearray bytes callable syn keyword pythonBuiltinFunc chr classmethod cmp coerce compile complex syn keyword pythonBuiltinFunc delattr dict dir divmod enumerate eval syn keyword pythonBuiltinFunc execfile file filter float frozenset getattr diff --git a/syntax/ruby.vim b/syntax/ruby.vim index 79d2e1b..43dd3d3 100644 --- a/syntax/ruby.vim +++ b/syntax/ruby.vim @@ -32,7 +32,7 @@ endif " Operators if exists("ruby_operators") - syn match rubyOperator "[~!^&|*/%+-]\|\%(class\s*\)\@\|<=\|\%(<\|\>\|>=\|=\@\|\*\*\|\.\.\.\|\.\.\|::" + syn match rubyOperator "[~!^|*/%+-]\|&\.\@!\|\%(class\s*\)\@\|<=\|\%(<\|\>\|>=\|=\@\|\*\*\|\.\.\.\|\.\.\|::" syn match rubyOperator "->\|-=\|/=\|\*\*=\|\*=\|&&=\|&=\|&&\|||=\||=\|||\|%=\|+=\|!\~\|!=" syn region rubyBracketOperator matchgroup=rubyOperator start="\%(\w[?!]\=\|[]})]\)\@<=\[\s*" end="\s*]" contains=ALLBUT,@rubyNotTop endif @@ -82,13 +82,13 @@ syn cluster rubyExtendedStringSpecial contains=@rubyStringSpecial,rubyNestedPare syn cluster rubyRegexpSpecial contains=rubyInterpolation,rubyNoInterpolation,rubyStringEscape,rubyRegexpSpecial,rubyRegexpEscape,rubyRegexpBrackets,rubyRegexpCharClass,rubyRegexpDot,rubyRegexpQuantifier,rubyRegexpAnchor,rubyRegexpParens,rubyRegexpComment " Numbers and ASCII Codes -syn match rubyASCIICode "\%(\w\|[]})\"'/\.]\)\@" display -syn match rubyInteger "\%(\%(\w\|[]})\"']\s*\)\@" display -syn match rubyInteger "\%(\%(\w\|[]})\"']\s*\)\@" display -syn match rubyInteger "\%(\%(\w\|[]})\"']\s*\)\@" display -syn match rubyFloat "\%(\%(\w\|[]})\"']\s*\)\@" display -syn match rubyFloat "\%(\%(\w\|[]})\"']\s*\)\@" display +syn match rubyASCIICode "\%(\w\|[]})\"'/]\)\@" display +syn match rubyInteger "\%(\%(\w\|[]})\"']\s*\)\@" display +syn match rubyInteger "\%(\%(\w\|[]})\"']\s*\)\@" display +syn match rubyInteger "\%(\%(\w\|[]})\"']\s*\)\@" display +syn match rubyFloat "\%(\%(\w\|[]})\"']\s*\)\@" display +syn match rubyFloat "\%(\%(\w\|[]})\"']\s*\)\@" display " Identifiers syn match rubyLocalVariableOrMethod "\<[_[:lower:]][_[:alnum:]]*[?!=]\=" contains=NONE display transparent @@ -98,7 +98,7 @@ syn match rubyConstant "\%(\%(^\|[^.]\)\.\s*\)\@ syn match rubyClassVariable "@@\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" display syn match rubyInstanceVariable "@\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" display syn match rubyGlobalVariable "$\%(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\|-.\)" -syn match rubySymbol "[]})\"':]\@\|<=\|<\|===\|[=!]=\|[=!]\~\|!\|>>\|>=\|>\||\|-@\|-\|/\|\[]=\|\[]\|\*\*\|\*\|&\|%\|+@\|+\|`\)" +syn match rubySymbol "[]})\"':]\@\|<=\|<\|===\|[=!]=\|[=!]\~\|!@\|!\|>>\|>=\|>\||\|-@\|-\|/\|\[]=\|\[]\|\*\*\|\*\|&\|%\|+@\|+\|`\)" syn match rubySymbol "[]})\"':]\@_,;:!?/.'"@$*\&+0]\)" syn match rubySymbol "[]})\"':]\@\@!\)\=" @@ -125,11 +125,12 @@ syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\%(^\|\<\%(and\|o syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\h\k*\s\+\)\@<=/[ \t=]\@!" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial fold " Generalized Regular Expression -syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z([~`!@#$%^&*_\-+=|\:;"',.? /]\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial fold -syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r{" end="}[iomxneus]*" skip="\\\\\|\\}" contains=@rubyRegexpSpecial fold -syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r<" end=">[iomxneus]*" skip="\\\\\|\\>" contains=@rubyRegexpSpecial,rubyNestedAngleBrackets,rubyDelimEscape fold -syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\[" end="\][iomxneus]*" skip="\\\\\|\\\]" contains=@rubyRegexpSpecial fold -syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r(" end=")[iomxneus]*" skip="\\\\\|\\)" contains=@rubyRegexpSpecial fold +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial fold +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r{" end="}[iomxneus]*" skip="\\\\\|\\}" contains=@rubyRegexpSpecial fold +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r<" end=">[iomxneus]*" skip="\\\\\|\\>" contains=@rubyRegexpSpecial,rubyNestedAngleBrackets,rubyDelimEscape fold +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\[" end="\][iomxneus]*" skip="\\\\\|\\\]" contains=@rubyRegexpSpecial fold +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r(" end=")[iomxneus]*" skip="\\\\\|\\)" contains=@rubyRegexpSpecial fold +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z(\s\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial fold " Normal String let s:spell_cluster = exists('ruby_spellcheck_strings') ? ',@Spell' : '' @@ -145,12 +146,13 @@ syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]{" end="} syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]<" end=">" skip="\\\\\|\\>" fold contains=rubyNestedAngleBrackets,rubyDelimEscape syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\[" end="\]" skip="\\\\\|\\\]" fold contains=rubyNestedSquareBrackets,rubyDelimEscape syn region rubyString matchgroup=rubyStringDelimiter start="%[qw](" end=")" skip="\\\\\|\\)" fold contains=rubyNestedParentheses,rubyDelimEscape -syn region rubyString matchgroup=rubyStringDelimiter start="%q " end=" " skip="\\\\\|\\)" fold -syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s\z([~`!@#$%^&*_\-+=|\:;"',.? /]\)" end="\z1" skip="\\\\\|\\\z1" fold +syn region rubyString matchgroup=rubyStringDelimiter start="%q\z(\s\)" end="\z1" skip="\\\\\|\\\z1" fold +syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s{" end="}" skip="\\\\\|\\}" fold contains=rubyNestedCurlyBraces,rubyDelimEscape syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s<" end=">" skip="\\\\\|\\>" fold contains=rubyNestedAngleBrackets,rubyDelimEscape syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s\[" end="\]" skip="\\\\\|\\\]" fold contains=rubyNestedSquareBrackets,rubyDelimEscape syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s(" end=")" skip="\\\\\|\\)" fold contains=rubyNestedParentheses,rubyDelimEscape +syn region rubyString matchgroup=rubyStringDelimiter start="%s\z(\s\)" end="\z1" skip="\\\\\|\\\z1" fold " Generalized Double Quoted String and Array of Strings and Shell Command Output " Note: %= is not matched here as the beginning of a double quoted string @@ -160,7 +162,7 @@ syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\={" en syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=<" end=">" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimEscape fold syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimEscape fold syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimEscape fold -syn region rubyString matchgroup=rubyStringDelimiter start="%[Qx] " end=" " skip="\\\\\|\\)" contains=@rubyStringSpecial fold +syn region rubyString matchgroup=rubyStringDelimiter start="%[Qx]\z(\s\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold " Array of Symbols syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold @@ -203,7 +205,7 @@ syn match rubyClassDeclaration "[^[:space:];#<]\+" contained contains=rubyC syn match rubyModuleDeclaration "[^[:space:];#<]\+" contained contains=rubyConstant,rubyOperator syn match rubyFunction "\<[_[:alpha:]][_[:alnum:]]*[?!=]\=[[:alnum:]_.:?!=]\@!" contained containedin=rubyMethodDeclaration syn match rubyFunction "\%(\s\|^\)\@<=[_[:alpha:]][_[:alnum:]]*[?!=]\=\%(\s\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2 -syn match rubyFunction "\%([[:space:].]\|^\)\@<=\%(\[\]=\=\|\*\*\|[+-]@\=\|[*/%|&^~]\|<<\|>>\|[<>]=\=\|<=>\|===\|[=!]=\|[=!]\~\|!\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration +syn match rubyFunction "\%([[:space:].]\|^\)\@<=\%(\[\]=\=\|\*\*\|[-+!~]@\=\|[*/%|&^~]\|<<\|>>\|[<>]=\=\|<=>\|===\|[=!]=\|[=!]\~\|!\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration syn cluster rubyDeclaration contains=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration,rubyModuleDeclaration,rubyClassDeclaration,rubyFunction,rubyBlockParameter @@ -287,7 +289,7 @@ syn match rubySharpBang "\%^#!.*" display syn keyword rubyTodo FIXME NOTE TODO OPTIMIZE HACK REVIEW XXX todo contained syn match rubyComment "#.*" contains=rubySharpBang,rubySpaceError,rubyTodo,@Spell if !exists("ruby_no_comment_fold") - syn region rubyMultilineComment start="\%(\%(^\s*#.*\n\)\@ " Maintainer: Ben Blum " Maintainer: Chris Morgan -" Last Change: January 5, 2015 +" Last Change: January 29, 2015 if version < 600 syntax clear @@ -26,9 +26,9 @@ syn keyword rustKeyword continue syn keyword rustKeyword extern nextgroup=rustExternCrate,rustObsoleteExternMod skipwhite skipempty syn keyword rustKeyword fn nextgroup=rustFuncName skipwhite skipempty syn keyword rustKeyword for in if impl let -syn keyword rustKeyword loop once pub +syn keyword rustKeyword loop pub syn keyword rustKeyword return super -syn keyword rustKeyword unsafe virtual where while +syn keyword rustKeyword unsafe where while syn keyword rustKeyword use nextgroup=rustModPath skipwhite skipempty " FIXME: Scoped impl's name is also fallen in this category syn keyword rustKeyword mod trait struct enum type nextgroup=rustIdentifier skipwhite skipempty @@ -45,7 +45,6 @@ syn match rustIdentifier contains=rustIdentifierPrime "\%([^[:cntrl:][:spac syn match rustFuncName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained syn region rustBoxPlacement matchgroup=rustBoxPlacementParens start="(" end=")" contains=TOP contained -syn keyword rustBoxPlacementExpr GC containedin=rustBoxPlacement " Ideally we'd have syntax rules set up to match arbitrary expressions. Since " we don't, we'll just define temporary contained rules to handle balancing " delimiters. @@ -58,13 +57,13 @@ syn match rustMacroRepeatCount ".\?[*+]" contained syn match rustMacroVariable "$\w\+" " Reserved (but not yet used) keywords {{{2 -syn keyword rustReservedKeyword alignof be do offsetof priv pure sizeof typeof unsized yield abstract final override macro +syn keyword rustReservedKeyword alignof become do offsetof priv pure sizeof typeof unsized yield abstract virtual final override macro " Built-in types {{{2 -syn keyword rustType isize usize float char bool u8 u16 u32 u64 f32 +syn keyword rustType isize usize char bool u8 u16 u32 u64 f32 syn keyword rustType f64 i8 i16 i32 i64 str Self -" Things from the prelude (src/libstd/prelude.rs) {{{2 +" Things from the libstd v1 prelude (src/libstd/prelude/v1.rs) {{{2 " This section is just straight transformation of the contents of the prelude, " to make it easy to update. @@ -73,30 +72,27 @@ syn keyword rustTrait Copy Send Sized Sync syn keyword rustTrait Drop Fn FnMut FnOnce " Reexported functions {{{3 -syn keyword rustFunction drop +" There’s no point in highlighting these; when one writes drop( or drop::< it +" gets the same highlighting anyway, and if someone writes `let drop = …;` we +" don’t really want *that* drop to be highlighted. +"syn keyword rustFunction drop " Reexported types and traits {{{3 syn keyword rustTrait Box -syn keyword rustTrait CharExt +syn keyword rustTrait ToOwned syn keyword rustTrait Clone syn keyword rustTrait PartialEq PartialOrd Eq Ord -syn keyword rustTrait DoubleEndedIterator -syn keyword rustTrait ExactSizeIterator -syn keyword rustTrait Iterator IteratorExt Extend +syn keyword rustTrait AsRef AsMut Into From +syn keyword rustTrait Default +syn keyword rustTrait Iterator Extend IntoIterator +syn keyword rustTrait DoubleEndedIterator ExactSizeIterator syn keyword rustEnum Option syn keyword rustEnumVariant Some None -syn keyword rustTrait PtrExt MutPtrExt syn keyword rustEnum Result syn keyword rustEnumVariant Ok Err -syn keyword rustTrait AsSlice -syn keyword rustTrait SliceExt SliceConcatExt -syn keyword rustTrait Str StrExt +syn keyword rustTrait SliceConcatExt syn keyword rustTrait String ToString syn keyword rustTrait Vec -" FIXME: remove when path reform lands -syn keyword rustTrait Path GenericPath -" FIXME: remove when I/O reform lands -syn keyword rustTrait Buffer Writer Reader Seek BufferPrelude " Other syntax {{{2 syn keyword rustSelf self @@ -122,6 +118,9 @@ syn match rustSigil display /[&~@*][^)= \t\r\n]/he=e-1,me=e-1 " This isn't actually correct; a closure with no arguments can be `|| { }`. " Last, because the & in && isn't a sigil syn match rustOperator display "&&\|||" +" This is rustArrowCharacter rather than rustArrow for the sake of matchparen, +" so it skips the ->; see http://stackoverflow.com/a/30309949 for details. +syn match rustArrowCharacter display "->" syn match rustMacro '\w\(\w\)*!' contains=rustAssert,rustPanic syn match rustMacro '#\w\(\w\)*' contains=rustAssert,rustPanic @@ -136,13 +135,16 @@ syn region rustString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=rustEs syn region rustString start='b\?r\z(#*\)"' end='"\z1' contains=@Spell syn region rustAttribute start="#!\?\[" end="\]" contains=rustString,rustDerive -syn region rustDerive start="derive(" end=")" contained contains=rustTrait +syn region rustDerive start="derive(" end=")" contained contains=rustDeriveTrait +" This list comes from src/libsyntax/ext/deriving/mod.rs +" Some are deprecated (Encodable, Decodable) or to be removed after a new snapshot (Show). +syn keyword rustDeriveTrait contained Clone Hash RustcEncodable RustcDecodable Encodable Decodable PartialEq Eq PartialOrd Ord Rand Show Debug Default FromPrimitive Send Sync Copy " Number literals -syn match rustDecNumber display "\<[0-9][0-9_]*\%([iu]\%(s\|8\|16\|32\|64\)\)\=" -syn match rustHexNumber display "\<0x[a-fA-F0-9_]\+\%([iu]\%(s\|8\|16\|32\|64\)\)\=" -syn match rustOctNumber display "\<0o[0-7_]\+\%([iu]\%(s\|8\|16\|32\|64\)\)\=" -syn match rustBinNumber display "\<0b[01_]\+\%([iu]\%(s\|8\|16\|32\|64\)\)\=" +syn match rustDecNumber display "\<[0-9][0-9_]*\%([iu]\%(size\|8\|16\|32\|64\)\)\=" +syn match rustHexNumber display "\<0x[a-fA-F0-9_]\+\%([iu]\%(size\|8\|16\|32\|64\)\)\=" +syn match rustOctNumber display "\<0o[0-7_]\+\%([iu]\%(size\|8\|16\|32\|64\)\)\=" +syn match rustBinNumber display "\<0b[01_]\+\%([iu]\%(size\|8\|16\|32\|64\)\)\=" " Special case for numbers of the form "1." which are float literals, unless followed by " an identifier, which makes them integer literals with a method call or field access, @@ -168,6 +170,7 @@ syn match rustCharacterInvalidUnicode display contained /b'\zs[^[:cntrl:][:g syn match rustCharacter /b'\([^\\]\|\\\(.\|x\x\{2}\)\)'/ contains=rustEscape,rustEscapeError,rustCharacterInvalid,rustCharacterInvalidUnicode syn match rustCharacter /'\([^\\]\|\\\(.\|x\x\{2}\|u\x\{4}\|U\x\{8}\|u{\x\{1,6}}\)\)'/ contains=rustEscape,rustEscapeUnicode,rustEscapeError,rustCharacterInvalid +syn match rustShebang /\%^#![^[].*/ syn region rustCommentLine start="//" end="$" contains=rustTodo,@Spell syn region rustCommentLineDoc start="//\%(//\@!\|!\)" end="$" contains=rustTodo,@Spell syn region rustCommentBlock matchgroup=rustCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=rustTodo,rustCommentBlockNest,@Spell @@ -200,6 +203,7 @@ hi def link rustOctNumber rustNumber hi def link rustBinNumber rustNumber hi def link rustIdentifierPrime rustIdentifier hi def link rustTrait rustType +hi def link rustDeriveTrait rustTrait hi def link rustMacroRepeatCount rustMacroRepeatDelimiters hi def link rustMacroRepeatDelimiters Macro @@ -220,6 +224,7 @@ hi def link rustEnumVariant rustConstant hi def link rustConstant Constant hi def link rustSelf Constant hi def link rustFloat Float +hi def link rustArrowCharacter rustOperator hi def link rustOperator Operator hi def link rustKeyword Keyword hi def link rustReservedKeyword Error @@ -231,6 +236,7 @@ hi def link rustModPathSep Delimiter hi def link rustFunction Function hi def link rustFuncName Function hi def link rustFuncCall Function +hi def link rustShebang Comment hi def link rustCommentLine Comment hi def link rustCommentLineDoc SpecialComment hi def link rustCommentBlock rustCommentLine @@ -249,7 +255,6 @@ hi def link rustInvalidBareKeyword Error hi def link rustExternCrate rustKeyword hi def link rustObsoleteExternMod Error hi def link rustBoxPlacementParens Delimiter -hi def link rustBoxPlacementExpr rustKeyword " Other Suggestions: " hi rustAttribute ctermfg=cyan diff --git a/syntax/swift.vim b/syntax/swift.vim index cbe46d3..4f5230a 100644 --- a/syntax/swift.vim +++ b/syntax/swift.vim @@ -1,68 +1,229 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'swift') == -1 -" Language: Swift -" Maintainer: toyama satoshi -" URL: http://github.com/toyamarinyon/vim-swift -" License: GPL +" File: swift.vim +" Author: Keith Smiley +" Description: Runtime files for Swift +" Last Modified: June 15, 2014 -" Bail if our syntax is already loaded. -if exists('b:current_syntax') && b:current_syntax == 'swift' +if exists("b:current_syntax") finish endif -" {{{ Whitespace and Comments -syntax region swiftComment start=#\/\*# end=#\*\/# -syntax match swiftComment /\/\/.*/ +" Comments +" Shebang +syntax match swiftShebang "\v#!.*$" + +" Comment contained keywords +syntax keyword swiftTodos contained TODO XXX FIXME NOTE +syntax keyword swiftMarker contained MARK +syntax match swiftDocString "\v^\s*-\s*parameter"hs=s+1 contained +syntax match swiftDocString "\v^\s*-\s*returns"hs=s+1 contained + +" Literals +" Strings +syntax region swiftString start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=swiftInterpolatedWrapper +syntax region swiftInterpolatedWrapper start="\v[^\\]\\\(\s*" end="\v\s*\)" contained containedin=swiftString contains=swiftInterpolatedString +syntax match swiftInterpolatedString "\v\w+(\(\))?" contained containedin=swiftInterpolatedWrapper + +" Numbers +syntax match swiftNumber "\v<\d+>" +syntax match swiftNumber "\v<(\d+_+)+\d+(\.\d+(_+\d+)*)?>" +syntax match swiftNumber "\v<\d+\.\d+>" +syntax match swiftNumber "\v<\d*\.?\d+([Ee]-?)?\d+>" +syntax match swiftNumber "\v<0x\x+([Pp]-?)?\x+>" +syntax match swiftNumber "\v<0b[01]+>" +syntax match swiftNumber "\v<0o\o+>" + +" BOOLs +syntax keyword swiftBoolean + \ true + \ false + + +" Operators +syntax match swiftOperator "\v\~" +syntax match swiftOperator "\v\s+!" +syntax match swiftOperator "\v\%" +syntax match swiftOperator "\v\^" +syntax match swiftOperator "\v\&" +syntax match swiftOperator "\v\*" +syntax match swiftOperator "\v-" +syntax match swiftOperator "\v\+" +syntax match swiftOperator "\v\=" +syntax match swiftOperator "\v\|" +syntax match swiftOperator "\v\/" +syntax match swiftOperator "\v\." +syntax match swiftOperator "\v\<" +syntax match swiftOperator "\v\>" +syntax match swiftOperator "\v\?\?" + +" Methods/Functions +syntax match swiftMethod "\(\.\)\@<=\w\+\((\)\@=" + +" Swift closure arguments +syntax match swiftClosureArgument "\$\d\+\(\.\d\+\)\?" + +syntax match swiftAvailability "\v((\*(\s*,\s*[a-zA-Z="0-9.]+)*)|(\w+\s+\d+(\.\d+(.\d+)?)?\s*,\s*)+\*)" contains=swiftString +syntax keyword swiftPlatforms OSX iOS watchOS OSXApplicationExtension iOSApplicationExtension contained containedin=swiftAvailability +syntax keyword swiftAvailabilityArg renamed unavailable introduced deprecated obsoleted message contained containedin=swiftAvailability + +" Keywords {{{ +syntax keyword swiftKeywords + \ as + \ atexit + \ break + \ case + \ catch + \ class + \ continue + \ convenience + \ default + \ defer + \ deinit + \ didSet + \ do + \ dynamic + \ else + \ extension + \ fallthrough + \ final + \ for + \ func + \ get + \ guard + \ if + \ import + \ in + \ indirect + \ infix + \ init + \ inout + \ internal + \ is + \ lazy + \ let + \ mutating + \ nil + \ nonmutating + \ operator + \ optional + \ override + \ postfix + \ prefix + \ private + \ protocol + \ public + \ repeat + \ required + \ rethrows + \ return + \ self + \ set + \ static + \ subscript + \ super + \ switch + \ throw + \ throws + \ try + \ typealias + \ unowned + \ var + \ weak + \ where + \ while + \ willSet +" }}} + +" Names surrounded by backticks. This aren't limited to keywords because 1) +" Swift doesn't limit them to keywords and 2) I couldn't make the keywords not +" highlight at the same time +syntax region swiftEscapedReservedWord start="`" end="`" oneline + +syntax keyword swiftAttributes + \ @assignment + \ @autoclosure + \ @available + \ @convention + \ @exported + \ @IBAction + \ @IBDesignable + \ @IBInspectable + \ @IBOutlet + \ @noescape + \ @nonobjc + \ @noreturn + \ @NSApplicationMain + \ @NSCopying + \ @NSManaged + \ @objc + \ @testable + \ @UIApplicationMain + \ @warn_unused_result + +syntax keyword swiftConditionStatement #available + +syntax keyword swiftStructure + \ struct + \ enum + +syntax region swiftTypeWrapper start="\v:\s*" skip="\s*,\s*$*\s*" end="$" contains=swiftString,swiftBoolean,swiftNumber,swiftType,swiftGenericsWrapper transparent +syntax region swiftGenericsWrapper start="\v\<" end="\v\>" contains=swiftType transparent oneline +syntax region swiftLiteralWrapper start="\v\=\s*" skip="\v[^\[\]]\(\)" end="\v(\[\]|\(\))" contains=swiftType,swiftString transparent oneline +syntax region swiftReturnWrapper start="\v-\>\s*" end="\v(\{|$)" contains=swiftType transparent oneline +syntax match swiftType "\v<\u\w*" contained containedin=swiftGenericsWrapper,swiftTypeWrapper,swiftLiteralWrapper,swiftGenericsWrapper + +syntax keyword swiftImports import + + +" 'preprocesor' stuff +syntax keyword swiftPreprocessor + \ #if + \ #elseif + \ #else + \ #endif + + +" Comment patterns +syntax match swiftComment "\v\/\/.*$" + \ contains=swiftTodos,swiftDocString,swiftMarker,@Spell oneline +syntax region swiftComment start="/\*" end="\*/" + \ contains=swiftTodos,swiftDocString,swiftMarker,swiftComment,@Spell fold + + +" Set highlights +highlight default link swiftTodos Todo +highlight default link swiftDocString String +highlight default link swiftShebang Comment highlight default link swiftComment Comment -" }}} +highlight default link swiftMarker Comment -" {{{ Identifiers -syntax match swiftIdentifier /[[:alpha:]_][[:alnum:]_]*/ -highlight default link swiftIdentifier Identifier -" }}} +highlight default link swiftString String +highlight default link swiftInterpolatedWrapper Delimiter +highlight default link swiftNumber Number +highlight default link swiftBoolean Boolean -" {{{ Keywords -" Keywords used in declarations: -syntax keyword swiftDeclarationKeywords class deinit enum extension func import init let protocol static struct subscript typealias var -highlight default link swiftDeclarationKeywords Keyword -" Keywords used in statements: -syntax keyword swiftStatementKeywords break case continue default do else fallthrough if in for return switch where while -highlight default link swiftStatementKeywords Keyword -" Keywords used in expressions and types: -syntax keyword swiftExpressionTypeKeywords as dynamicType is new super self Self Type __COLUMN__ __FILE__ __FUNCTION__ __LINE__ -highlight default link swiftExpressionTypeKeywords Keyword -" Keywords reserved in particular contexts: -syntax keyword swiftReserveKeywords associativity didSet get infix inout left mutating none nonmutating operator override postfix precedence prefix right set unowned unowned(safe) unowned(unsafe) weak willSet -highlight default link swiftReserveKeywords Keyword -" }}} +highlight default link swiftOperator Operator +highlight default link swiftKeywords Keyword +highlight default link swiftEscapedReservedWord Normal +highlight default link swiftClosureArgument Operator +highlight default link swiftAttributes PreProc +highlight default link swiftConditionStatement PreProc +highlight default link swiftStructure Structure +highlight default link swiftType Type +highlight default link swiftImports Include +highlight default link swiftPreprocessor PreProc +highlight default link swiftMethod Function -" {{{ Literals -" Integer literal -syntax match swiftIntegerLiteral /\<\d\+\%(_\d\+\)*\%(\.\d\+\%(_\d\+\)*\)\=\>/ -syntax match swiftIntegerLiteral /\<\d\+\%(_\d\+\)*\%(\.\d\+\%(_\d\+\)*\)\=\%([eE][-+]\=\d\+\%(_\d\+\)*\)\>/ -syntax match swiftIntegerLiteral /\<0x\x\+\%(_\x\+\)*\>/ -syntax match swiftIntegerLiteral /\<0o\o\+\%(_\o\+\)*\>/ -syntax match swiftIntegerLiteral /\<0b[01]\+\%(_[01]\+\)*\>/ -highlight default link swiftIntegerLiteral Number -" String literal -syntax region swiftStringLiteral start=/"/ skip=/\\"/ end=/"/ -highlight default link swiftStringLiteral String -" }}} +highlight default link swiftConditionStatement PreProc +highlight default link swiftAvailability Normal +highlight default link swiftAvailabilityArg Normal +highlight default link swiftPlatforms Keyword -" {{{ Operators -syntax keyword swiftOperatorKeywords / = - + ! * % < > & \| ^ ~ . -highlight default link swiftOperatorKeywords Operator -" }}} +" Force vim to sync at least x lines. This solves the multiline comment not +" being highlighted issue +syn sync minlines=100 -" {{{ Type -syntax match swiftTypeIdentifier /\<[[:alpha:]_][[:alnum:]_.]*/ contained -syntax match swiftType /: .*/ contains=swiftTypeIdentifier -highlight default link swiftType Operator -highlight default link swiftTypeIdentifier Type -" }}} - -if !exists('b:current_syntax') - let b:current_syntax = 'swift' -endif +let b:current_syntax = "swift" endif diff --git a/syntax/toml.vim b/syntax/toml.vim index 4ead203..694a9af 100644 --- a/syntax/toml.vim +++ b/syntax/toml.vim @@ -2,7 +2,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'toml') == -1 " Language: TOML " Maintainer: Caleb Spare -" URL: http://github.com/cespare/vim-toml +" URL: https://github.com/cespare/vim-toml " LICENSE: MIT if exists("b:current_syntax") @@ -37,7 +37,7 @@ hi def link tomlFloat Float syn match tomlBoolean /\<\%(true\|false\)\>/ display hi def link tomlBoolean Boolean -" http://tools.ietf.org/html/rfc3339 +" https://tools.ietf.org/html/rfc3339 syn match tomlDate /\d\{4\}-\d\{2\}-\d\{2\}T\d\{2\}:\d\{2\}:\d\{2\}\%(\.\d\+\)\?\%(Z\|[+-]\d\{2\}:\d\{2\}\)/ display hi def link tomlDate Constant