From ed677c34d55a0e025b7008f29419498a3989cde2 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Mon, 4 Mar 2019 09:15:44 +0100 Subject: [PATCH] Update --- README.md | 2 +- after/syntax/yaml.vim | 2 +- autoload/RstFold.vim | 14 +- autoload/elixir/indent.vim | 2 +- autoload/go/config.vim | 10 +- autoload/rubycomplete.vim | 66 +++- autoload/rust.vim | 59 +++- compiler/ruby.vim | 1 - compiler/sbt.vim | 4 +- extras/flow.vim | 38 +- ftdetect/polyglot.vim | 66 ++-- ftplugin/elixir.vim | 6 +- ftplugin/eruby.vim | 17 +- ftplugin/graphql.vim | 2 + ftplugin/kotlin.vim | 9 + ftplugin/rst.vim | 9 +- ftplugin/ruby.vim | 36 +- ftplugin/rust.vim | 10 +- ftplugin/terraform.vim | 4 +- ftplugin/toml.vim | 20 +- indent/ansible.vim | 2 +- indent/blade.vim | 4 +- indent/crystal.vim | 6 +- indent/eruby.vim | 16 +- indent/graphql.vim | 2 +- indent/ruby.vim | 33 +- syntax/crystal.vim | 30 +- syntax/dart.vim | 5 +- syntax/elixir.vim | 181 +++++----- syntax/gitrebase.vim | 6 +- syntax/go.vim | 74 ++-- syntax/i3config.vim | 18 +- syntax/javascript.vim | 6 +- syntax/julia.vim | 54 +-- syntax/kotlin.vim | 19 +- syntax/markdown.vim | 26 +- syntax/mustache.vim | 2 +- syntax/pug.vim | 13 +- syntax/python.vim | 28 +- syntax/racket.vim | 39 ++- syntax/rst.vim | 4 +- syntax/ruby.vim | 627 ++++++++++++++++----------------- syntax/rust.vim | 4 +- syntax/terraform.vim | 692 ++++++++++++++++++++++++++++++++++++- syntax/vifm.vim | 12 +- 45 files changed, 1575 insertions(+), 705 deletions(-) create mode 100644 ftplugin/kotlin.vim diff --git a/README.md b/README.md index 2e9b101..4f9489d 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ If you need full functionality of any plugin, please use it directly with your p - [jst](https://github.com/briancollins/vim-jst) (syntax, indent) - [jsx](https://github.com/mxw/vim-jsx) (after) - [julia](https://github.com/JuliaEditorSupport/julia-vim) (syntax, indent, autoload, ftplugin) -- [kotlin](https://github.com/udalov/kotlin-vim) (syntax, indent) +- [kotlin](https://github.com/udalov/kotlin-vim) (syntax, indent, ftplugin) - [latex](https://github.com/LaTeX-Box-Team/LaTeX-Box) (syntax, indent, ftplugin) - [less](https://github.com/groenewege/vim-less) (syntax, indent, ftplugin) - [liquid](https://github.com/tpope/vim-liquid) (syntax, indent, ftplugin) diff --git a/after/syntax/yaml.vim b/after/syntax/yaml.vim index 489691b..a73bbf5 100644 --- a/after/syntax/yaml.vim +++ b/after/syntax/yaml.vim @@ -27,7 +27,7 @@ syn match yamlBlock "[>|]\d\?[+-]" syn region yamlComment start="\#" end="$" syn match yamlIndicator "#YAML:\S\+" -syn region yamlString start="\(^\|\s\|\[\|\,\|\-\)'" end="'" skip="\\'" +syn region yamlString start="\(^\|\s\|\[\|\,\|\-\)\@<='" end="'" skip="\\'" syn region yamlString start='"' end='"' skip='\\"' contains=yamlEscape syn region yamlString matchgroup=yamlBlock start=/[>|]\s*\n\+\z(\s\+\)\S/rs=s+1 skip=/^\%(\z1\S\|^$\)/ end=/^\z1\@!.*/me=s-1 syn region yamlString matchgroup=yamlBlock start=/[>|]\(\d\|[+-]\)\s*\n\+\z(\s\+\)\S/rs=s+2 skip=/^\%(\z1\S\|^$\)/ end=/^\z1\@!.*/me=s-1 diff --git a/autoload/RstFold.vim b/autoload/RstFold.vim index 558fe46..2d80284 100644 --- a/autoload/RstFold.vim +++ b/autoload/RstFold.vim @@ -2,9 +2,13 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rst') == -1 " Author: Antony Lee " Description: Helper functions for reStructuredText syntax folding -" Last Modified: 2018-01-07 +" Last Modified: 2018-12-29 function s:CacheRstFold() + if !g:rst_fold_enabled + return + endif + let closure = {'header_types': {}, 'max_level': 0, 'levels': {}} function closure.Process(match) dict let curline = getcurpos()[1] @@ -30,6 +34,10 @@ function s:CacheRstFold() endfunction function RstFold#GetRstFold() + if !g:rst_fold_enabled + return + endif + if !has_key(b:, 'RstFoldCache') call s:CacheRstFold() endif @@ -41,6 +49,10 @@ function RstFold#GetRstFold() endfunction function RstFold#GetRstFoldText() + if !g:rst_fold_enabled + return + endif + if !has_key(b:, 'RstFoldCache') call s:CacheRstFold() endif diff --git a/autoload/elixir/indent.vim b/autoload/elixir/indent.vim index 20271ac..4b5906e 100644 --- a/autoload/elixir/indent.vim +++ b/autoload/elixir/indent.vim @@ -267,7 +267,7 @@ function! elixir#indent#handle_inside_block(context) let config = { \'f': {'aligned_clauses': s:keyword('end'), 'pattern_match_clauses': never_match}, \'c': {'aligned_clauses': s:keyword('end'), 'pattern_match_clauses': never_match}, - \'t': {'aligned_clauses': s:keyword('end\|catch\|rescue\|after'), 'pattern_match_clauses': s:keyword('catch\|rescue')}, + \'t': {'aligned_clauses': s:keyword('end\|catch\|rescue\|after\|else'), 'pattern_match_clauses': s:keyword('catch\|rescue\|else')}, \'r': {'aligned_clauses': s:keyword('end\|after'), 'pattern_match_clauses': s:keyword('after')}, \'i': {'aligned_clauses': s:keyword('end\|else'), 'pattern_match_clauses': never_match}, \'[': {'aligned_clauses': ']', 'pattern_match_clauses': never_match}, diff --git a/autoload/go/config.vim b/autoload/go/config.vim index 97cb363..3020ee7 100644 --- a/autoload/go/config.vim +++ b/autoload/go/config.vim @@ -390,8 +390,9 @@ function! go#config#HighlightFunctions() abort return get(g:, 'go_highlight_functions', 0) endfunction -function! go#config#HighlightFunctionArguments() abort - return get(g:, 'go_highlight_function_arguments', 0) +function! go#config#HighlightFunctionParameters() abort + " fallback to highlight_function_arguments for backwards compatibility + return get(g:, 'go_highlight_function_parameters', get(g:, 'go_highlight_function_arguments', 0)) endfunction function! go#config#HighlightFunctionCalls() abort @@ -441,6 +442,11 @@ function! go#config#FoldEnable(...) abort return get(g:, 'go_fold_enable', ['block', 'import', 'varconst', 'package_comment']) endfunction +function! go#config#EchoGoInfo() abort + return get(g:, "go_echo_go_info", 1) +endfunction + + " Set the default value. A value of "1" is a shortcut for this, for " compatibility reasons. if exists("g:go_gorename_prefill") && g:go_gorename_prefill == 1 diff --git a/autoload/rubycomplete.vim b/autoload/rubycomplete.vim index 88dfaad..a7f3fc1 100644 --- a/autoload/rubycomplete.vim +++ b/autoload/rubycomplete.vim @@ -1,11 +1,10 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'ruby') == -1 " Vim completion script -" Language: Ruby -" Maintainer: Mark Guzman -" URL: https://github.com/vim-ruby/vim-ruby -" Release Coordinator: Doug Kearns -" Maintainer Version: 0.8.1 +" Language: Ruby +" Maintainer: Mark Guzman +" URL: https://github.com/vim-ruby/vim-ruby +" Release Coordinator: Doug Kearns " ---------------------------------------------------------------------------- " " Ruby IRB/Complete author: Keiju ISHITSUKA(keiju@ishitsuka.com) @@ -55,6 +54,23 @@ if !exists("g:rubycomplete_include_objectspace") endif " }}} configuration failsafe initialization +" {{{ regex patterns + +" Regex that defines the start-match for the 'end' keyword. +let s:end_start_regex = + \ '\C\%(^\s*\|[=,*/%+\-|;{]\|<<\|>>\|:\s\)\s*\zs' . + \ '\<\%(module\|class\|if\|for\|while\|until\|case\|unless\|begin' . + \ '\|\%(\K\k*[!?]\?\s\+\)\=def\):\@!\>' . + \ '\|\%(^\|[^.:@$]\)\@<=\' + +" Regex that defines the middle-match for the 'end' keyword. +let s:end_middle_regex = '\<\%(ensure\|else\|\%(\%(^\|;\)\s*\)\@<=\\|when\|elsif\):\@!\>' + +" Regex that defines the end-match for the 'end' keyword. +let s:end_end_regex = '\%(^\|[^.:@$]\)\@<=\' + +" }}} regex patterns + " {{{ vim-side support functions let s:rubycomplete_debug = 0 @@ -105,7 +121,7 @@ function! s:GetBufferRubyEntity( name, type, ... ) endif let curpos = getpos(".") - let [enum,ecol] = searchpairpos( crex, '', '\(end\|}\)', 'W' ) + let [enum,ecol] = searchpairpos( s:end_start_regex, s:end_middle_regex, s:end_end_regex, 'W' ) call cursor(lastpos[1], lastpos[2]) if lnum > enum @@ -130,19 +146,28 @@ function! s:IsPosInClassDef(pos) return ret endfunction +function! s:IsInComment(pos) + let stack = synstack(a:pos[0], a:pos[1]) + if !empty(stack) + return synIDattr(stack[0], 'name') =~ 'ruby\%(.*Comment\|Documentation\)' + else + return 0 + endif +endfunction + function! s:GetRubyVarType(v) let stopline = 1 let vtp = '' - let pos = getpos('.') + let curpos = getpos('.') let sstr = '^\s*#\s*@var\s*'.escape(a:v, '*').'\>\s\+[^ \t]\+\s*$' let [lnum,lcol] = searchpos(sstr,'nb',stopline) if lnum != 0 && lcol != 0 - call setpos('.',pos) + call setpos('.',curpos) let str = getline(lnum) let vtp = substitute(str,sstr,'\1','') return vtp endif - call setpos('.',pos) + call setpos('.',curpos) let ctors = '\(now\|new\|open\|get_instance' if exists('g:rubycomplete_rails') && g:rubycomplete_rails == 1 && s:rubycomplete_rails_loaded == 1 let ctors = ctors.'\|find\|create' @@ -152,9 +177,13 @@ function! s:GetRubyVarType(v) let fstr = '=\s*\([^ \t]\+.' . ctors .'\>\|[\[{"''/]\|%[xwQqr][(\[{@]\|[A-Za-z0-9@:\-()\.]\+...\?\|lambda\|&\)' let sstr = ''.escape(a:v, '*').'\>\s*[+\-*/]*'.fstr - let [lnum,lcol] = searchpos(sstr,'nb',stopline) - if lnum != 0 && lcol != 0 - let str = matchstr(getline(lnum),fstr,lcol) + let pos = searchpos(sstr,'bW') + while pos != [0,0] && s:IsInComment(pos) + let pos = searchpos(sstr,'bW') + endwhile + if pos != [0,0] + let [lnum, col] = pos + let str = matchstr(getline(lnum),fstr,col) let str = substitute(str,'^=\s*','','') call setpos('.',pos) @@ -176,7 +205,7 @@ function! s:GetRubyVarType(v) end return '' endif - call setpos('.',pos) + call setpos('.',curpos) return '' endfunction @@ -673,11 +702,10 @@ class VimRubyCompletion methods.delete_if { |c| c.match( /'/ ) } end - when /^::([A-Z][^:\.\(]*)$/ # Absolute Constant or class methods + when /^::([A-Z][^:\.\(]*)?$/ # Absolute Constant or class methods dprint "const or cls" receiver = $1 - methods = Object.constants - methods.grep(/^#{receiver}/).collect{|e| "::" + e} + methods = Object.constants.collect{ |c| c.to_s }.grep(/^#{receiver}/) when /^(((::)?[A-Z][^:.\(]*)+?)::?([^:.]*)$/ # Constant or class methods receiver = $1 @@ -686,13 +714,13 @@ class VimRubyCompletion load_buffer_class( receiver ) load_buffer_module( receiver ) begin - classes = eval("#{receiver}.constants") - #methods = eval("#{receiver}.methods") + constants = eval("#{receiver}.constants").collect{ |c| c.to_s }.grep(/^#{message}/) + methods = eval("#{receiver}.methods").collect{ |m| m.to_s }.grep(/^#{message}/) rescue Exception dprint "exception: %s" % $! + constants = [] methods = [] end - methods.grep(/^#{message}/).collect{|e| receiver + "::" + e} when /^(:[^:.]+)\.([^.]*)$/ # Symbol dprint "symbol" diff --git a/autoload/rust.vim b/autoload/rust.vim index 81f8c63..d5a2e29 100644 --- a/autoload/rust.vim +++ b/autoload/rust.vim @@ -5,23 +5,59 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rust') == -1 " Last Modified: May 27, 2014 " For bugs, patches and license go to https://github.com/rust-lang/rust.vim -" Jump {{{1 - -function! rust#Load() +function! rust#Load() " Utility call to get this script loaded, for debugging endfunction function! rust#GetConfigVar(name, default) " Local buffer variable with same name takes predeence over global - if has_key(b:, a:name) + if has_key(b:, a:name) return get(b:, a:name) endif - if has_key(g:, a:name) + if has_key(g:, a:name) return get(g:, a:name) endif return a:default endfunction +" Include expression {{{1 + +function! rust#IncludeExpr(fname) abort + " Remove leading 'crate::' to deal with 2018 edition style 'use' + " statements + let l:fname = substitute(a:fname, '^crate::', '', '') + + " Remove trailing colons arising from lines like + " + " use foo::{Bar, Baz}; + let l:fname = substitute(l:fname, ':\+$', '', '') + + " Replace '::' with '/' + let l:fname = substitute(l:fname, '::', '/', 'g') + + " When we have + " + " use foo::bar::baz; + " + " we can't tell whether baz is a module or a function; and we can't tell + " which modules correspond to files. + " + " So we work our way up, trying + " + " foo/bar/baz.rs + " foo/bar.rs + " foo.rs + while l:fname !=# '.' + let l:path = findfile(l:fname) + if !empty(l:path) + return l:fname + endif + let l:fname = fnamemodify(l:fname, ':h') + endwhile + return l:fname +endfunction + +" Jump {{{1 function! rust#Jump(mode, function) range let cnt = v:count1 @@ -487,14 +523,6 @@ function! rust#Test(all, options) abort return endif - let mod_name = expand('%:t:r') - if mod_name ==# '' - echohl ErrorMsg - echo 'Cannot extract a module name from file name. Please add ! to command if you want to run all tests' - echohl None - return - endif - let saved = getpos('.') try let func_name = s:SearchTestFunctionNameUnderCursor() @@ -504,11 +532,10 @@ function! rust#Test(all, options) abort echohl None return endif - let spec = mod_name . '::' . func_name if a:options ==# '' - execute cmd . 'cargo test --manifest-path' manifest spec + execute cmd . 'cargo test --manifest-path' manifest func_name else - execute cmd . 'cargo test --manifest-path' manifest spec a:options + execute cmd . 'cargo test --manifest-path' manifest func_name a:options endif return finally diff --git a/compiler/ruby.vim b/compiler/ruby.vim index 453b398..c3cb12f 100644 --- a/compiler/ruby.vim +++ b/compiler/ruby.vim @@ -6,7 +6,6 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'ruby') == -1 " Maintainer: Tim Pope " URL: https://github.com/vim-ruby/vim-ruby " Release Coordinator: Doug Kearns -" ---------------------------------------------------------------------------- if exists("current_compiler") finish diff --git a/compiler/sbt.vim b/compiler/sbt.vim index 41504d7..521f528 100644 --- a/compiler/sbt.vim +++ b/compiler/sbt.vim @@ -22,8 +22,8 @@ set cpo-=C CompilerSet makeprg=sbt\ -Dsbt.log.noformat=true\ compile CompilerSet errorformat= - \%E\ %#[error]\ %f:%l:\ %m,%C\ %#[error]\ %p^,%-C%.%#,%Z, - \%W\ %#[warn]\ %f:%l:\ %m,%C\ %#[warn]\ %p^,%-C%.%#,%Z, + \%E\ %#[error]\ %f:%l:%c:\ %m,%C\ %#[error]\ %p^,%-C%.%#,%Z, + \%W\ %#[warn]\ %f:%l:%c:\ %m,%C\ %#[warn]\ %p^,%-C%.%#,%Z, \%-G%.%# let &cpo = s:cpo_save diff --git a/extras/flow.vim b/extras/flow.vim index f5166df..ecd368b 100644 --- a/extras/flow.vim +++ b/extras/flow.vim @@ -5,13 +5,14 @@ syntax region jsFlowArgumentDef contained start=/:/ syntax region jsFlowArray contained matchgroup=jsFlowNoise start=/\[/ end=/\]/ contains=@jsFlowCluster,jsComment fold syntax region jsFlowObject contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=@jsFlowCluster,jsComment fold syntax region jsFlowExactObject contained matchgroup=jsFlowNoise start=/{|/ end=/|}/ contains=@jsFlowCluster,jsComment fold -syntax region jsFlowParens contained matchgroup=jsFlowNoise start=/(/ end=/)/ contains=@jsFlowCluster keepend fold +syntax region jsFlowParens contained matchgroup=jsFlowNoise start=/(/ end=/)/ contains=@jsFlowCluster nextgroup=jsFlowArrow skipwhite keepend extend fold syntax match jsFlowNoise contained /[:;,<>]/ syntax keyword jsFlowType contained boolean number string null void any mixed JSON array Function object array bool class -syntax keyword jsFlowTypeof contained typeof skipempty skipempty nextgroup=jsFlowTypeCustom,jsFlowType -syntax match jsFlowTypeCustom contained /[0-9a-zA-Z_.]*/ skipwhite skipempty nextgroup=jsFlowGroup -syntax region jsFlowGroup contained matchgroup=jsFlowNoise start=// contains=@jsFlowCluster -syntax region jsFlowArrowArguments contained matchgroup=jsFlowNoise start=/(/ end=/)\%(\s*=>\)\@=/ oneline skipwhite skipempty nextgroup=jsFlowArrow contains=@jsFlowCluster +syntax keyword jsFlowTypeof contained typeof skipempty skipwhite nextgroup=jsFlowTypeCustom,jsFlowType +syntax match jsFlowTypeCustom contained /[0-9a-zA-Z_.]*/ skipwhite skipempty nextgroup=jsFlowGeneric +syntax region jsFlowGeneric matchgroup=jsFlowNoise start=/\k\@<=/ contains=@jsFlowCluster containedin=@jsExpression,jsFlowDeclareBlock +syntax region jsFlowGeneric contained matchgroup=jsFlowNoise start=/(\@=/ oneline contains=@jsFlowCluster containedin=@jsExpression,jsFlowDeclareBlock +syntax region jsFlowObjectGeneric contained matchgroup=jsFlowNoise start=/\k\@<=/ contains=@jsFlowCluster nextgroup=jsFuncArgs syntax match jsFlowArrow contained /=>/ skipwhite skipempty nextgroup=jsFlowType,jsFlowTypeCustom,jsFlowParens syntax match jsFlowObjectKey contained /[0-9a-zA-Z_$?]*\(\s*:\)\@=/ contains=jsFunctionKey,jsFlowMaybe skipwhite skipempty nextgroup=jsObjectValue containedin=jsObject syntax match jsFlowOrOperator contained /|/ skipwhite skipempty nextgroup=@jsFlowCluster @@ -19,7 +20,7 @@ syntax keyword jsFlowImportType contained type typeof skipwhite skipempty ne syntax match jsFlowWildcard contained /*/ syntax match jsFlowReturn contained /:\s*/ contains=jsFlowNoise skipwhite skipempty nextgroup=@jsFlowReturnCluster,jsFlowArrow,jsFlowReturnParens -syntax region jsFlowReturnObject contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp fold +syntax region jsFlowReturnObject contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp extend fold syntax region jsFlowReturnArray contained matchgroup=jsFlowNoise start=/\[/ end=/\]/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp fold syntax region jsFlowReturnParens contained matchgroup=jsFlowNoise start=/(/ end=/)/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp,jsFlowReturnArrow fold syntax match jsFlowReturnArrow contained /=>/ skipwhite skipempty nextgroup=@jsFlowReturnCluster @@ -28,13 +29,15 @@ syntax match jsFlowReturnMaybe contained /?/ skipwhite skipempty nextgroup= syntax region jsFlowReturnGroup contained matchgroup=jsFlowNoise start=// contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp syntax match jsFlowReturnOrOp contained /\s*|\s*/ skipwhite skipempty nextgroup=@jsFlowReturnCluster syntax match jsFlowWildcardReturn contained /*/ skipwhite skipempty nextgroup=jsFuncBlock +syntax keyword jsFlowTypeofReturn contained typeof skipempty skipwhite nextgroup=@jsFlowReturnCluster syntax region jsFlowFunctionGroup contained matchgroup=jsFlowNoise start=// contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncArgs syntax region jsFlowClassGroup contained matchgroup=jsFlowNoise start=// contains=@jsFlowCluster skipwhite skipempty nextgroup=jsClassBlock syntax region jsFlowClassFunctionGroup contained matchgroup=jsFlowNoise start=// contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncArgs +syntax match jsFlowObjectFuncName contained /\<\K\k*<\@=/ skipwhite skipempty nextgroup=jsFlowObjectGeneric containedin=jsObject syntax region jsFlowTypeStatement start=/\(opaque\s\+\)\?type\%(\s\+\k\)\@=/ end=/=\@=/ contains=jsFlowTypeOperator oneline skipwhite skipempty nextgroup=jsFlowTypeValue keepend -syntax region jsFlowTypeValue contained matchgroup=jsFlowNoise start=/=/ end=/[\n;]/ contains=@jsFlowCluster,jsFlowGroup,jsFlowMaybe +syntax region jsFlowTypeValue contained matchgroup=jsFlowNoise start=/=/ end=/\%(;\|\n\%(\s*|\)\@!\)/ contains=@jsFlowCluster,jsFlowGeneric,jsFlowMaybe syntax match jsFlowTypeOperator contained /=/ containedin=jsFlowTypeValue syntax match jsFlowTypeOperator contained /=/ syntax keyword jsFlowTypeKeyword contained type @@ -43,20 +46,17 @@ syntax keyword jsFlowDeclare declare skipwhite skipempty nextgr syntax match jsFlowClassProperty contained /\<[0-9a-zA-Z_$]*\>:\@=/ skipwhite skipempty nextgroup=jsFlowClassDef containedin=jsClassBlock syntax region jsFlowClassDef contained start=/:/ end=/\%(\s*[,=;)\n]\)\@=/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsClassValue -syntax region jsFlowModule contained start=/module/ end=/{\@=/ skipempty skipempty nextgroup=jsFlowDeclareBlock contains=jsString -syntax region jsFlowInterface contained start=/interface/ end=/{\@=/ skipempty skipempty nextgroup=jsFlowInterfaceBlock contains=@jsFlowCluster +syntax region jsFlowModule contained start=/module/ end=/\%({\|:\)\@=/ skipempty skipwhite nextgroup=jsFlowDeclareBlock contains=jsString +syntax region jsFlowInterface contained start=/interface/ end=/{\@=/ skipempty skipwhite nextgroup=jsFlowInterfaceBlock contains=@jsFlowCluster syntax region jsFlowDeclareBlock contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=jsFlowDeclare,jsFlowNoise fold -" NOTE: It appears the nextgroup was causing a ton of breakages... testing it -" witout a nextgroup, but keeping this arround for reference incase something breaks -" syntax match jsFlowMaybe contained /?/ nextgroup=jsFlowType,jsFlowTypeCustom,jsFlowParens,jsFlowArrowArguments,jsFlowObject,jsFlowReturnObject extend keepend syntax match jsFlowMaybe contained /?/ -syntax region jsFlowInterfaceBlock contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=jsObjectKey,jsObjectKeyString,jsObjectKeyComputed,jsObjectSeparator,jsObjectFuncName,jsObjectMethodType,jsGenerator,jsComment,jsObjectStringKey,jsSpreadExpression,jsFlowNoise keepend fold +syntax region jsFlowInterfaceBlock contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=jsObjectKey,jsObjectKeyString,jsObjectKeyComputed,jsObjectSeparator,jsObjectFuncName,jsFlowObjectFuncName,jsObjectMethodType,jsGenerator,jsComment,jsObjectStringKey,jsSpreadExpression,jsFlowNoise,jsFlowParens,jsFlowGeneric keepend fold syntax region jsFlowParenAnnotation contained start=/:/ end=/[,=)]\@=/ containedin=jsParen contains=@jsFlowCluster -syntax cluster jsFlowReturnCluster contains=jsFlowNoise,jsFlowReturnObject,jsFlowReturnArray,jsFlowReturnKeyword,jsFlowReturnGroup,jsFlowReturnMaybe,jsFlowReturnOrOp,jsFlowWildcardReturn,jsFlowReturnArrow -syntax cluster jsFlowCluster contains=jsFlowArray,jsFlowObject,jsFlowExactObject,jsFlowNoise,jsFlowTypeof,jsFlowType,jsFlowGroup,jsFlowArrowArguments,jsFlowMaybe,jsFlowParens,jsFlowOrOperator,jsFlowWildcard +syntax cluster jsFlowReturnCluster contains=jsFlowNoise,jsFlowReturnObject,jsFlowReturnArray,jsFlowReturnKeyword,jsFlowReturnGroup,jsFlowReturnMaybe,jsFlowReturnOrOp,jsFlowWildcardReturn,jsFlowReturnArrow,jsFlowTypeofReturn +syntax cluster jsFlowCluster contains=jsFlowArray,jsFlowObject,jsFlowExactObject,jsFlowNoise,jsFlowTypeof,jsFlowType,jsFlowGeneric,jsFlowMaybe,jsFlowParens,jsFlowOrOperator,jsFlowWildcard if version >= 508 || !exists("did_javascript_syn_inits") if version < 508 @@ -71,21 +71,22 @@ if version >= 508 || !exists("did_javascript_syn_inits") HiLink jsFlowType Type HiLink jsFlowTypeCustom PreProc HiLink jsFlowTypeof PreProc + HiLink jsFlowTypeofReturn PreProc HiLink jsFlowArray PreProc HiLink jsFlowObject PreProc HiLink jsFlowExactObject PreProc HiLink jsFlowParens PreProc - HiLink jsFlowGroup PreProc + HiLink jsFlowGeneric PreProc + HiLink jsFlowObjectGeneric jsFlowGeneric HiLink jsFlowReturn PreProc HiLink jsFlowParenAnnotation PreProc HiLink jsFlowReturnObject jsFlowReturn HiLink jsFlowReturnArray jsFlowArray HiLink jsFlowReturnParens jsFlowParens - HiLink jsFlowReturnGroup jsFlowGroup + HiLink jsFlowReturnGroup jsFlowGeneric HiLink jsFlowFunctionGroup PreProc HiLink jsFlowClassGroup PreProc HiLink jsFlowClassFunctionGroup PreProc - HiLink jsFlowArrowArguments PreProc HiLink jsFlowArrow PreProc HiLink jsFlowReturnArrow PreProc HiLink jsFlowTypeStatement PreProc @@ -105,6 +106,7 @@ if version >= 508 || !exists("did_javascript_syn_inits") HiLink jsFlowWildcardReturn PreProc HiLink jsFlowImportType PreProc HiLink jsFlowTypeValue PreProc + HiLink jsFlowObjectFuncName jsObjectFuncName delcommand HiLink endif diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 888f78e..1b6c984 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -141,9 +141,18 @@ function! s:setupTemplate() set ft=jinja2 endfunction -au BufNewFile,BufRead * if s:isAnsible() | set ft=yaml.ansible | en -au BufNewFile,BufRead *.j2 call s:setupTemplate() -au BufNewFile,BufRead hosts set ft=ansible_hosts +augroup ansible_vim_ftyaml_ansible + au! + au BufNewFile,BufRead * if s:isAnsible() | set ft=yaml.ansible | en +augroup END +augroup ansible_vim_ftjinja2 + au! + au BufNewFile,BufRead *.j2 call s:setupTemplate() +augroup END +augroup ansible_vim_fthosts + au! + au BufNewFile,BufRead hosts set ft=ansible_hosts +augroup END augroup end endif @@ -363,45 +372,19 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'go') == -1 let s:cpo_save = &cpo set cpo&vim -" We take care to preserve the user's fileencodings and fileformats, -" because those settings are global (not buffer local), yet we want -" to override them for loading Go files, which are defined to be UTF-8. -let s:current_fileformats = '' -let s:current_fileencodings = '' - -" define fileencodings to open as utf-8 encoding even if it's ascii. -function! s:gofiletype_pre(type) - let s:current_fileformats = &g:fileformats - let s:current_fileencodings = &g:fileencodings - set fileencodings=utf-8 fileformats=unix - let &l:filetype = a:type -endfunction - -" restore fileencodings as others -function! s:gofiletype_post() - let &g:fileformats = s:current_fileformats - let &g:fileencodings = s:current_fileencodings -endfunction - " Note: should not use augroup in ftdetect (see :help ftdetect) -au BufNewFile *.go setfiletype go | if &modifiable | setlocal fileencoding=utf-8 fileformat=unix | endif -au BufRead *.go call s:gofiletype_pre("go") -au BufReadPost *.go call s:gofiletype_post() - -au BufNewFile *.s setfiletype asm | if &modifiable | setlocal fileencoding=utf-8 fileformat=unix | endif -au BufRead *.s call s:gofiletype_pre("asm") -au BufReadPost *.s call s:gofiletype_post() - -au BufRead,BufNewFile *.tmpl set filetype=gohtmltmpl +au BufRead,BufNewFile *.go setfiletype go +au BufRead,BufNewFile *.s setfiletype asm +au BufRead,BufNewFile *.tmpl setfiletype gohtmltmpl " remove the autocommands for modsim3, and lprolog files so that their " highlight groups, syntax, etc. will not be loaded. *.MOD is included, so " that on case insensitive file systems the module2 autocmds will not be " executed. -au! BufNewFile,BufRead *.mod,*.MOD +au! BufRead,BufNewFile *.mod,*.MOD " Set the filetype if the first non-comment and non-blank line starts with " 'module '. -au BufNewFile,BufRead go.mod call s:gomod() +au BufRead,BufNewFile go.mod call s:gomod() fun! s:gomod() for l:i in range(1, line('$')) @@ -411,7 +394,7 @@ fun! s:gomod() endif if l:l =~# '^module .\+' - set filetype=gomod + setfiletype gomod endif break @@ -663,9 +646,14 @@ endif if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'markdown') == -1 augroup filetypedetect " markdown, from markdown.vim in plasticboy/vim-markdown:_SYNTAX +if !has('patch-7.4.480') + " Before this patch, vim used modula2 for .md. + au! filetypedetect BufRead,BufNewFile *.md +endif + " markdown filetype file -au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn} set filetype=markdown -au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn}.{des3,des,bf,bfa,aes,idea,cast,rc2,rc4,rc5,desx} set filetype=markdown +au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn} setfiletype markdown +au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn}.{des3,des,bf,bfa,aes,idea,cast,rc2,rc4,rc5,desx} setfiletype markdown augroup end endif @@ -1040,7 +1028,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rust') == -1 " rust, from rust.vim in rust-lang/rust.vim " vint: -ProhibitAutocmdWithNoGroup -autocmd BufRead,BufNewFile *.rs set filetype=rust +autocmd BufRead,BufNewFile *.rs setf rust autocmd BufRead,BufNewFile Cargo.toml if &filetype == "" | set filetype=cfg | endif " vim: set et sw=4 sts=4 ts=8: @@ -1164,7 +1152,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'toml') == -1 augroup filetypedetect " toml, from toml.vim in cespare/vim-toml " Go dep and Rust use several TOML config files that are not named with .toml. -autocmd BufNewFile,BufRead *.toml,Gopkg.lock,Cargo.lock,*/.cargo/config,*/.cargo/credentials,Pipfile set filetype=toml +autocmd BufNewFile,BufRead *.toml,Gopkg.lock,Cargo.lock,*/.cargo/config,*/.cargo/credentials,Pipfile setf toml augroup end endif diff --git a/ftplugin/elixir.vim b/ftplugin/elixir.vim index debaa10..f37efe6 100644 --- a/ftplugin/elixir.vim +++ b/ftplugin/elixir.vim @@ -30,7 +30,7 @@ let &l:path = \ &g:path \ ], ',') setlocal includeexpr=elixir#util#get_filename(v:fname) -setlocal suffixesadd=.ex,.exs,.eex,.erl,.yrl,.hrl +setlocal suffixesadd=.ex,.exs,.eex,.erl,.xrl,.yrl,.hrl let &l:define = 'def\(macro\|guard\|delegate\)\=p\=' @@ -49,9 +49,7 @@ onoremap [[ ':silent keeppatterns ?'.b:block_begin.' ][ ':silent keeppatterns /'.b:block_end .'' onoremap [] ':silent keeppatterns ?'.b:block_end .'' -silent! setlocal formatoptions-=t formatoptions+=croqlj - -let b:undo_ftplugin = 'setlocal sw< sts< et< isk< com< cms< path< inex< sua< def<'. +let b:undo_ftplugin = 'setlocal sw< sts< et< isk< com< cms< path< inex< sua< def< fo<'. \ '| unlet! b:match_ignorecase b:match_words b:block_begin b:block_end' endif diff --git a/ftplugin/eruby.vim b/ftplugin/eruby.vim index 12d3245..07558f9 100644 --- a/ftplugin/eruby.vim +++ b/ftplugin/eruby.vim @@ -7,7 +7,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'ruby') == -1 " Release Coordinator: Doug Kearns " Only do this when not done yet for this buffer -if get(b:, 'did_ftplugin') =~# '\' +if exists("b:did_ftplugin") finish endif @@ -25,8 +25,6 @@ endif if &filetype =~ '^eruby\.' let b:eruby_subtype = matchstr(&filetype,'^eruby\.\zs\w\+') -elseif &filetype =~ '^.*\.eruby\>' - let b:eruby_subtype = matchstr(&filetype,'^.\{-\}\ze\.eruby\>') elseif !exists("b:eruby_subtype") let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$") let b:eruby_subtype = matchstr(s:lines,'eruby_subtype=\zs\w\+') @@ -49,14 +47,11 @@ elseif !exists("b:eruby_subtype") endif endif -if &filetype =~# '^eruby\>' - if exists("b:eruby_subtype") && b:eruby_subtype != '' && b:eruby_subtype !=? 'eruby' - exe "runtime! ftplugin/".b:eruby_subtype.".vim ftplugin/".b:eruby_subtype."_*.vim ftplugin/".b:eruby_subtype."/*.vim" - else - runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim - endif +if exists("b:eruby_subtype") && b:eruby_subtype != '' && b:eruby_subtype !=? 'eruby' + exe "runtime! ftplugin/".b:eruby_subtype.".vim ftplugin/".b:eruby_subtype."_*.vim ftplugin/".b:eruby_subtype."/*.vim" +else + runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim endif -let s:did_ftplugin = get(b:, 'did_ftplugin', 1) unlet! b:did_ftplugin " Override our defaults if these were set by an included ftplugin. @@ -89,7 +84,7 @@ let s:path = &l:path let s:suffixesadd = &l:suffixesadd runtime! ftplugin/ruby.vim ftplugin/ruby_*.vim ftplugin/ruby/*.vim -let b:did_ftplugin = s:did_ftplugin . '.eruby' +let b:did_ftplugin = 1 " Combine the new set of values with those previously included. if exists("b:undo_ftplugin") diff --git a/ftplugin/graphql.vim b/ftplugin/graphql.vim index d1ac432..ce5fd3d 100644 --- a/ftplugin/graphql.vim +++ b/ftplugin/graphql.vim @@ -17,4 +17,6 @@ setlocal softtabstop=2 setlocal shiftwidth=2 setlocal expandtab +let b:undo_ftplugin = 'setlocal com< cms< fo< isk< sts< sw< et<' + endif diff --git a/ftplugin/kotlin.vim b/ftplugin/kotlin.vim new file mode 100644 index 0000000..0fceaf3 --- /dev/null +++ b/ftplugin/kotlin.vim @@ -0,0 +1,9 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'kotlin') == -1 + +if exists("b:did_ftplugin") | finish | endif +let b:did_ftplugin = 1 + +setlocal comments=:// +setlocal commentstring=//\ %s + +endif diff --git a/ftplugin/rst.vim b/ftplugin/rst.vim index e6ef32c..edd1f97 100644 --- a/ftplugin/rst.vim +++ b/ftplugin/rst.vim @@ -5,7 +5,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rst') == -1 " Maintainer: Marshall Ward " Original Maintainer: Nikolai Weibull " Website: https://github.com/marshallward/vim-restructuredtext -" Latest Revision: 2018-01-07 +" Latest Revision: 2018-12-29 if exists("b:did_ftplugin") finish @@ -15,6 +15,11 @@ let b:did_ftplugin = 1 let s:cpo_save = &cpo set cpo&vim +"Disable folding +if !exists('g:rst_fold_enabled') + let g:rst_fold_enabled = 0 +endif + let b:undo_ftplugin = "setl com< cms< et< fo<" setlocal comments=fb:.. commentstring=..\ %s expandtab @@ -27,7 +32,7 @@ setlocal formatoptions+=tcroql " " More sophisticated indentation rules should be revisted in the future. -if !exists("g:rst_style") || g:rst_style != 0 +if exists("g:rst_style") && g:rst_style != 0 setlocal expandtab shiftwidth=3 softtabstop=3 tabstop=8 endif diff --git a/ftplugin/ruby.vim b/ftplugin/ruby.vim index 5b763e1..4c925fa 100644 --- a/ftplugin/ruby.vim +++ b/ftplugin/ruby.vim @@ -4,8 +4,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'ruby') == -1 " Language: Ruby " Maintainer: Tim Pope " URL: https://github.com/vim-ruby/vim-ruby -" Release Coordinator: Doug Kearns -" ---------------------------------------------------------------------------- +" Release Coordinator: Doug Kearns if (exists("b:did_ftplugin")) finish @@ -26,20 +25,20 @@ if exists("loaded_matchit") && !exists("b:match_words") let b:match_ignorecase = 0 let b:match_words = - \ '\<\%(if\|unless\|case\|while\|until\|for\|do\|class\|module\|def\|begin\)\>=\@!' . + \ '\<\%(if\|unless\|case\|while\|until\|for\|do\|class\|module\|def\|=\@=\@!' . \ ':' . \ '\<\%(else\|elsif\|ensure\|when\|rescue\|break\|redo\|next\|retry\)\>' . \ ':' . - \ '\%(^\|[^.\:@$]\)\@<=\' . + \ '\%(^\|[^.\:@$=]\)\@<=\' . + \ ',^=begin\>:^=end\>,' . \ ',{:},\[:\],(:)' let b:match_skip = \ "synIDattr(synID(line('.'),col('.'),0),'name') =~ '" . - \ "\\'" endif @@ -154,7 +153,7 @@ endif function! s:map(mode, flags, map) abort let from = matchstr(a:map, '\S\+') if empty(mapcheck(from, a:mode)) - exe a:mode.'map' '' a:map + exe a:mode.'map' '' a:flags a:map let b:undo_ftplugin .= '|sil! '.a:mode.'unmap '.from endif endfunction @@ -313,13 +312,16 @@ function! s:synid() abort endfunction function! s:wrap_i(back,forward) abort - execute 'norm k'.a:forward + execute 'norm! k' + execute 'norm '.a:forward let line = line('.') execute 'norm '.a:back if line('.') == line - 1 return s:wrap_a(a:back,a:forward) endif - execute 'norm jV'.a:forward.'k' + execute 'norm! jV' + execute 'norm '.a:forward + execute 'norm! k' endfunction function! s:wrap_a(back,forward) abort @@ -332,11 +334,15 @@ function! s:wrap_a(back,forward) abort - endwhile if exists('after') - execute 'norm V'.a:forward.'j' + execute 'norm! V' + execute 'norm '.a:forward + execute 'norm! j' elseif line('.') > 1 && getline(line('.')-1) =~# '^\s*$' - execute 'norm kV'.a:forward + execute 'norm! kV' + execute 'norm '.a:forward else - execute 'norm V'.a:forward + execute 'norm! V' + execute 'norm '.a:forward endif endfunction diff --git a/ftplugin/rust.vim b/ftplugin/rust.vim index cdc318f..fa9e156 100644 --- a/ftplugin/rust.vim +++ b/ftplugin/rust.vim @@ -5,7 +5,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rust') == -1 " Maintainer: Chris Morgan " Maintainer: Kevin Ballard " Last Change: June 08, 2016 -" For bugs, patches and license go to https://github.com/rust-lang/rust.vim +" For bugs, patches and license go to https://github.com/rust-lang/rust.vim if exists("b:did_ftplugin") finish @@ -54,8 +54,8 @@ if get(g:, 'rust_recommended_style', 1) setlocal textwidth=99 endif -" This includeexpr isn't perfect, but it's a good start -setlocal includeexpr=substitute(v:fname,'::','/','g') +setlocal include=\\v^\\s*(pub\\s+)?use\\s+\\zs(\\f\|:)+ +setlocal includeexpr=rust#IncludeExpr(v:fname) setlocal suffixesadd=.rs @@ -149,7 +149,7 @@ endif " Cleanup {{{1 let b:undo_ftplugin = " - \ setlocal formatoptions< comments< commentstring< includeexpr< suffixesadd< + \ setlocal formatoptions< comments< commentstring< include< includeexpr< suffixesadd< \|if exists('b:rust_set_style') \|setlocal tabstop< shiftwidth< softtabstop< expandtab< textwidth< \|endif @@ -188,7 +188,7 @@ let b:undo_ftplugin = " " Code formatting on save augroup rust.vim.PreWrite autocmd! - autocmd BufWritePre silent! call rustfmt#PreWrite() + autocmd BufWritePre *.rs silent! call rustfmt#PreWrite() augroup END setlocal matchpairs+=<:> diff --git a/ftplugin/terraform.vim b/ftplugin/terraform.vim index bbebacb..c5c3062 100644 --- a/ftplugin/terraform.vim +++ b/ftplugin/terraform.vim @@ -3,6 +3,8 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'terraform') == " terraform.vim - basic vim/terraform integration " Maintainer: HashiVim +set formatoptions-=t + if exists("g:loaded_terraform") || v:version < 700 || &cp || !executable('terraform') finish endif @@ -44,7 +46,7 @@ endfunction " https://github.com/fatih/vim-hclfmt/blob/master/autoload/fmt.vim function! terraform#fmt() let l:curw = winsaveview() - let l:tmpfile = tempname() + let l:tmpfile = tempname() . ".tf" call writefile(getline(1, "$"), l:tmpfile) let output = system("terraform fmt -write " . l:tmpfile) if v:shell_error == 0 diff --git a/ftplugin/toml.vim b/ftplugin/toml.vim index baa19ba..b440a71 100644 --- a/ftplugin/toml.vim +++ b/ftplugin/toml.vim @@ -3,7 +3,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'toml') == -1 " File: ftplugin/toml.vim " Author: Kevin Ballard " Description: FileType Plugin for Toml -" Last Change: Dec 09, 2014 +" Last Change: Feb 12, 2019 if exists('b:did_ftplugin') finish @@ -12,24 +12,10 @@ let b:did_ftplugin = 1 let s:save_cpo = &cpo set cpo&vim +let b:undo_ftplugin = 'setlocal commentstring< comments<' setlocal commentstring=#\ %s - -" Add NERDCommenter delimiters - -let s:delims = { 'left': '#' } -if exists('g:NERDDelimiterMap') - if !has_key(g:NERDDelimiterMap, 'toml') - let g:NERDDelimiterMap.toml = s:delims - endif -elseif exists('g:NERDCustomDelimiters') - if !has_key(g:NERDCustomDelimiters, 'toml') - let g:NERDCustomDelimiters.toml = s:delims - endif -else - let g:NERDCustomDelimiters = { 'toml': s:delims } -endif -unlet s:delims +setlocal comments=:# let &cpo = s:save_cpo unlet s:save_cpo diff --git a/indent/ansible.vim b/indent/ansible.vim index d94d3a2..29fc8e7 100644 --- a/indent/ansible.vim +++ b/indent/ansible.vim @@ -10,7 +10,7 @@ setlocal expandtab setlocal softtabstop=2 setlocal shiftwidth=2 setlocal commentstring=#%s -setlocal formatoptions=cl +setlocal formatoptions+=cl " c -> wrap long comments, including # " l -> do not wrap long lines diff --git a/indent/blade.vim b/indent/blade.vim index e93d48c..9fe9574 100644 --- a/indent/blade.vim +++ b/indent/blade.vim @@ -55,9 +55,9 @@ function! GetBladeIndent() let indent = indent(lnum) " 1. Check for special directives - " @section is a single-line directive if it has a second argument. + " @section and @slot are single-line if they have a second argument. " @php is a single-line directive if it is followed by parentheses. - if (line =~# '@section\%(.*@end\)\@!' && line !~# '@section\s*([^,]*)') + if (line =~# '@\%(section\|slot\)\%(.*@end\)\@!' && line !~# '@\%(section\|slot\)\s*([^,]*)') \ || line =~# '@php\s*(' return indent endif diff --git a/indent/crystal.vim b/indent/crystal.vim index 9fd6c1f..ae900b6 100644 --- a/indent/crystal.vim +++ b/indent/crystal.vim @@ -49,8 +49,8 @@ let s:skip_expr = " Regex used for words that, at the start of a line, add a level of indent. let s:crystal_indent_keywords = - \ '^\s*\zs\<\%(module\|\%(abstract\)\=\s*\%(class\|struct\)\|enum\|if\|for\|macro' . - \ '\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure\|rescue\|lib' . + \ '^\s*\zs\<\%(module\|\%(private\s\+\)\=\%(abstract\s\+\)\=\%(class\|struct\)\|enum\|if' . + \ '\|for\|macro\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure\|rescue\|lib' . \ '\|\%(protected\|private\)\=\s*def\):\@!\>' . \ '\|\%([=,*/%+-]\|<<\|>>\|:\s\)\s*\zs' . \ '\<\%(if\|for\|while\|until\|case\|unless\|begin\):\@!\>' . @@ -66,7 +66,7 @@ let s:crystal_deindent_keywords = let s:end_start_regex = \ '{%\s*\<\%(if\|for\|while\|until\|unless\|begin\|lib\)\>\|' . \ '\C\%(^\s*\|[=,*/%+\-|;{]\|<<\|>>\|:\s\)\s*\zs' . - \ '\<\%(module\|\%(abstract\)\=\s*\%(class\|struct\)\|enum\|macro\|if\|for\|while\|until\|case\|unless\|begin\|lib' . + \ '\<\%(module\|\%(private\s\+\)\=\%(abstract\s\+\)\=\%(class\|struct\)\|enum\|macro\|if\|for\|while\|until\|case\|unless\|begin\|lib' . \ '\|\%(protected\|private\)\=\s*def\):\@!\>' . \ '\|\%(^\|[^.:@$]\)\@<=\' diff --git a/indent/eruby.vim b/indent/eruby.vim index cdc5fed..6fd7660 100644 --- a/indent/eruby.vim +++ b/indent/eruby.vim @@ -6,7 +6,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'ruby') == -1 " URL: https://github.com/vim-ruby/vim-ruby " Release Coordinator: Doug Kearns -if get(b:, 'did_indent') =~# '\' +if exists("b:did_indent") finish endif @@ -14,14 +14,12 @@ runtime! indent/ruby.vim unlet! b:did_indent setlocal indentexpr= -if &filetype =~# '^eruby\>' - if exists("b:eruby_subtype") && b:eruby_subtype != '' && b:eruby_subtype !=# 'eruby' - exe "runtime! indent/".b:eruby_subtype.".vim" - else - runtime! indent/html.vim - endif +if exists("b:eruby_subtype") && b:eruby_subtype != '' && b:eruby_subtype !=# 'eruby' + exe "runtime! indent/".b:eruby_subtype.".vim" +else + runtime! indent/html.vim endif -let b:did_indent = get(b:, 'did_indent', 1) . '.eruby' +unlet! b:did_indent " Force HTML indent to not keep state. let b:html_indent_usestate = 0 @@ -35,6 +33,8 @@ if &l:indentexpr == '' endif let b:eruby_subtype_indentexpr = &l:indentexpr +let b:did_indent = 1 + setlocal indentexpr=GetErubyIndent() setlocal indentkeys=o,O,*,<>>,{,},0),0],o,O,!^F,=end,=else,=elsif,=rescue,=ensure,=when diff --git a/indent/graphql.vim b/indent/graphql.vim index ed9cfaa..9d17577 100644 --- a/indent/graphql.vim +++ b/indent/graphql.vim @@ -15,7 +15,7 @@ setlocal nolisp setlocal nosmartindent setlocal indentexpr=GetGraphQLIndent() -setlocal indentkeys=0{,0},0),0[,0],0#,!^F,o,O,e +setlocal indentkeys=0{,0},0),0[,0],0#,!^F,o,O " If our indentation function already exists, we have nothing more to do. if exists('*GetGraphQLIndent') diff --git a/indent/ruby.vim b/indent/ruby.vim index 78d10d7..a3141ed 100644 --- a/indent/ruby.vim +++ b/indent/ruby.vim @@ -2,7 +2,8 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'ruby') == -1 " Vim indent file " Language: Ruby -" Maintainer: Nikolai Weibull +" Maintainer: Andrew Radev +" Previous Maintainer: Nikolai Weibull " URL: https://github.com/vim-ruby/vim-ruby " Release Coordinator: Doug Kearns @@ -51,15 +52,26 @@ set cpo&vim " Syntax group names that are strings. let s:syng_string = - \ ['String', 'Interpolation', 'InterpolationDelimiter', 'NoInterpolation', 'StringEscape'] + \ ['String', 'Interpolation', 'InterpolationDelimiter', 'StringEscape'] " Syntax group names that are strings or documentation. let s:syng_stringdoc = s:syng_string + ['Documentation'] " Syntax group names that are or delimit strings/symbols/regexes or are comments. -let s:syng_strcom = s:syng_stringdoc + - \ ['Regexp', 'RegexpDelimiter', 'RegexpEscape', - \ 'Symbol', 'StringDelimiter', 'ASCIICode', 'Comment'] +let s:syng_strcom = s:syng_stringdoc + [ + \ 'Character', + \ 'Comment', + \ 'HeredocDelimiter', + \ 'PercentRegexpDelimiter', + \ 'PercentStringDelimiter', + \ 'PercentSymbolDelimiter', + \ 'Regexp', + \ 'RegexpDelimiter', + \ 'RegexpEscape', + \ 'StringDelimiter', + \ 'Symbol', + \ 'SymbolDelimiter', + \ ] " Expression used to check whether we should skip a match with searchpair(). let s:skip_expr = @@ -69,7 +81,7 @@ let s:skip_expr = let s:ruby_indent_keywords = \ '^\s*\zs\<\%(module\|class\|if\|for' . \ '\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure\|rescue' . - \ '\|\%(\K\k*[!?]\?\)\=\s*def\):\@!\>' . + \ '\|\%(\K\k*[!?]\?\s\+\)\=def\):\@!\>' . \ '\|\%([=,*/%+-]\|<<\|>>\|:\s\)\s*\zs' . \ '\<\%(if\|for\|while\|until\|case\|unless\|begin\):\@!\>' @@ -83,7 +95,7 @@ let s:ruby_deindent_keywords = let s:end_start_regex = \ '\C\%(^\s*\|[=,*/%+\-|;{]\|<<\|>>\|:\s\)\s*\zs' . \ '\<\%(module\|class\|if\|for\|while\|until\|case\|unless\|begin' . - \ '\|\%(\K\k*[!?]\?\)\=\s*def\):\@!\>' . + \ '\|\%(\K\k*[!?]\?\s\+\)\=def\):\@!\>' . \ '\|\%(^\|[^.:@$]\)\@<=\' " Regex that defines the middle-match for the 'end' keyword. @@ -146,7 +158,7 @@ let s:block_regex = let s:block_continuation_regex = '^\s*[^])}\t ].*'.s:block_regex " Regex that describes a leading operator (only a method call's dot for now) -let s:leading_operator_regex = '^\s*[.]' +let s:leading_operator_regex = '^\s*\%(&\=\.\)' " 2. GetRubyIndent Function {{{1 " ========================= @@ -695,7 +707,10 @@ endfunction " Check if the character at lnum:col is inside a string delimiter function! s:IsInStringDelimiter(lnum, col) abort - return s:IsInRubyGroup(['StringDelimiter'], a:lnum, a:col) + return s:IsInRubyGroup( + \ ['HeredocDelimiter', 'PercentStringDelimiter', 'StringDelimiter'], + \ a:lnum, a:col + \ ) endfunction function! s:IsAssignment(str, pos) abort diff --git a/syntax/crystal.vim b/syntax/crystal.vim index 637e207..d972d3c 100644 --- a/syntax/crystal.vim +++ b/syntax/crystal.vim @@ -83,6 +83,12 @@ syn match crystalFloat "\%(\%(\w\|[]})\"']\s*\)\@\|::\)\@=" contained +syn match crystalClassName "\%(\%([.@$]\@\|::\)\@=" contained +syn match crystalModuleName "\%(\%([.@$]\@\|::\)\@=" contained +syn match crystalStructName "\%(\%([.@$]\@\|::\)\@=" contained +syn match crystalLibName "\%(\%([.@$]\@\|::\)\@=" contained +syn match crystalEnumName "\%(\%([.@$]\@\|::\)\@=" contained syn match crystalConstant "\%(\%([.@$]\@\|::\)\@=" syn match crystalClassVariable "@@\%(\h\|%\|[^\x00-\x7F]\)\%(\w\|%\|[^\x00-\x7F]\)*" display syn match crystalInstanceVariable "@\%(\h\|%\|[^\x00-\x7F]\)\%(\w\|%\|[^\x00-\x7F]\)*" display @@ -176,15 +182,15 @@ end syn match crystalAliasDeclaration "[^[:space:];#.()]\+" contained contains=crystalSymbol,crystalGlobalVariable,crystalPredefinedVariable nextgroup=crystalAliasDeclaration2 skipwhite syn match crystalAliasDeclaration2 "[^[:space:];#.()]\+" contained contains=crystalSymbol,crystalGlobalVariable,crystalPredefinedVariable -syn match crystalMethodDeclaration "[^[:space:];#(]\+" contained contains=crystalConstant,crystalBoolean,crystalPseudoVariable,crystalInstanceVariable,crystalClassVariable,crystalGlobalVariable -syn match crystalFunctionDeclaration "[^[:space:];#(=]\+" contained contains=crystalConstant -syn match crystalTypeDeclaration "[^[:space:];#=]\+" contained contains=crystalConstant -syn match crystalClassDeclaration "[^[:space:];#<]\+" contained contains=crystalConstant,crystalOperator -syn match crystalModuleDeclaration "[^[:space:];#<]\+" contained contains=crystalConstant,crystalOperator -syn match crystalStructDeclaration "[^[:space:];#<]\+" contained contains=crystalConstant,crystalOperator -syn match crystalLibDeclaration "[^[:space:];#<]\+" contained contains=crystalConstant,crystalOperator -syn match crystalMacroDeclaration "[^[:space:];#<\"]\+" contained contains=crystalConstant,crystalOperator -syn match crystalEnumDeclaration "[^[:space:];#<\"]\+" contained contains=crystalConstant +syn match crystalMethodDeclaration "[^[:space:];#(]\+" contained contains=crystalConstant,crystalFunction,crystalBoolean,crystalPseudoVariable,crystalInstanceVariable,crystalClassVariable,crystalGlobalVariable +syn match crystalFunctionDeclaration "[^[:space:];#(=]\+" contained contains=crystalFunction +syn match crystalTypeDeclaration "[^[:space:];#=]\+" contained contains=crystalTypeName +syn match crystalClassDeclaration "[^[:space:];#<]\+" contained contains=crystalClassName,crystalOperator +syn match crystalModuleDeclaration "[^[:space:];#]\+" contained contains=crystalModuleName,crystalOperator +syn match crystalStructDeclaration "[^[:space:];#<]\+" contained contains=crystalStructName,crystalOperator +syn match crystalLibDeclaration "[^[:space:];#]\+" contained contains=crystalLibName,crystalOperator +syn match crystalMacroDeclaration "[^[:space:];#(]\+" contained contains=crystalFunction +syn match crystalEnumDeclaration "[^[:space:];#<\"]\+" contained contains=crystalEnumName syn match crystalFunction "\<[_[:alpha:]][_[:alnum:]]*[?!=]\=[[:alnum:]_.:?!=]\@!" contained containedin=crystalMethodDeclaration,crystalFunctionDeclaration syn match crystalFunction "\%(\s\|^\)\@<=[_[:alpha:]][_[:alnum:]]*[?!=]\=\%(\s\|$\)\@=" contained containedin=crystalAliasDeclaration,crystalAliasDeclaration2 syn match crystalFunction "\%([[:space:].]\|^\)\@<=\%(\[\][=?]\=\|\*\*\|[+-]@\=\|[*/%|&^~]\|<<\|>>\|[<>]=\=\|<=>\|===\|[=!]=\|[=!]\~\|!\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=crystalAliasDeclaration,crystalAliasDeclaration2,crystalMethodDeclaration,crystalFunctionDeclaration @@ -345,6 +351,12 @@ else endif hi def link crystalClassVariable crystalIdentifier hi def link crystalConstant Type +hi def link crystalTypeName crystalConstant +hi def link crystalClassName crystalConstant +hi def link crystalModuleName crystalConstant +hi def link crystalStructName crystalConstant +hi def link crystalLibName crystalConstant +hi def link crystalEnumName crystalConstant hi def link crystalGlobalVariable crystalIdentifier hi def link crystalBlockParameter crystalIdentifier hi def link crystalInstanceVariable crystalIdentifier diff --git a/syntax/dart.vim b/syntax/dart.vim index f957153..40dd030 100644 --- a/syntax/dart.vim +++ b/syntax/dart.vim @@ -28,14 +28,15 @@ syntax keyword dartConstant null syntax keyword dartTypedef this super class typedef enum mixin syntax keyword dartOperator new is as in syntax match dartOperator "+=\=\|-=\=\|*=\=\|/=\=\|%=\=\|\~/=\=\|<<=\=\|>>=\=\|[<>]=\=\|===\=\|\!==\=\|&=\=\|\^=\=\||=\=\|||\|&&\|\[\]=\=\|=>\|!\|\~\|?\|:" -syntax keyword dartType void var bool int double num dynamic covariant +syntax keyword dartType void var bool int double num dynamic syntax keyword dartStatement return syntax keyword dartStorageClass static abstract final const factory syntax keyword dartExceptions throw rethrow try on catch finally syntax keyword dartAssert assert syntax keyword dartClassDecl extends with implements syntax keyword dartBranch break continue nextgroup=dartUserLabelRef skipwhite -syntax keyword dartKeyword get set operator call external async await yield sync native +syntax keyword dartKeyword get set operator call external async await + \ yield sync native covariant syntax match dartUserLabelRef "\k\+" contained syntax region dartLabelRegion transparent matchgroup=dartLabel start="\" matchgroup=NONE end=":" diff --git a/syntax/elixir.vim b/syntax/elixir.vim index 53e5590..1fa114b 100644 --- a/syntax/elixir.vim +++ b/syntax/elixir.vim @@ -13,7 +13,7 @@ syn sync minlines=2000 syn cluster elixirNotTop contains=@elixirRegexSpecial,@elixirStringContained,@elixirDeclaration,elixirTodo,elixirArguments,elixirBlockDefinition,elixirUnusedVariable,elixirStructDelimiter syn cluster elixirRegexSpecial contains=elixirRegexEscape,elixirRegexCharClass,elixirRegexQuantifier,elixirRegexEscapePunctuation syn cluster elixirStringContained contains=elixirInterpolation,elixirRegexEscape,elixirRegexCharClass -syn cluster elixirDeclaration contains=elixirFunctionDeclaration,elixirModuleDeclaration,elixirProtocolDeclaration,elixirImplDeclaration,elixirRecordDeclaration,elixirMacroDeclaration,elixirDelegateDeclaration,elixirOverridableDeclaration,elixirExceptionDeclaration,elixirCallbackDeclaration,elixirStructDeclaration +syn cluster elixirDeclaration contains=elixirFunctionDeclaration,elixirPrivateFunctionDeclaration,elixirModuleDeclaration,elixirProtocolDeclaration,elixirImplDeclaration,elixirRecordDeclaration,elixirPrivateRecordDeclaration,elixirMacroDeclaration,elixirPrivateMacroDeclaration,elixirDelegateDeclaration,elixirOverridableDeclaration,elixirExceptionDeclaration,elixirCallbackDeclaration,elixirStructDeclaration syn match elixirComment '#.*' contains=elixirTodo,@Spell syn keyword elixirTodo FIXME NOTE TODO OPTIMIZE XXX HACK contained @@ -84,7 +84,6 @@ syn match elixirAtomInterpolated ':\("\)\@=' contains=elixirString syn match elixirString "\(\w\)\@\|0[0-7]{0,2}[0-7]\@!\>\|[^x0MC]\)\|(\\[MC]-)+\w\|[^\s\\]\)" syn region elixirBlock matchgroup=elixirBlockDefinition start="\:\@!" end="\" contains=ALLBUT,@elixirNotTop fold -syn region elixirElseBlock matchgroup=elixirBlockDefinition start="\:\@!" end="\" contains=ALLBUT,@elixirNotTop fold syn region elixirAnonymousFunction matchgroup=elixirBlockDefinition start="\" end="\" contains=ALLBUT,@elixirNotTop fold syn region elixirArguments start="(" end=")" contained contains=elixirOperator,elixirAtom,elixirPseudoVariable,elixirAlias,elixirBoolean,elixirVariable,elixirUnusedVariable,elixirNumber,elixirDocString,elixirAtomInterpolated,elixirRegex,elixirString,elixirStringDelimiter,elixirRegexDelimiter,elixirInterpolationDelimiter,elixirSigil,elixirAnonymousFunction,elixirComment @@ -120,102 +119,110 @@ else syn region elixirDocTest start="^\s*\%(iex\|\.\.\.\)\%((\d*)\)\?>\s" end="^\s*$" contained endif -syn region elixirDocString matchgroup=elixirSigilDelimiter start="\%(@\w*doc\s\+\)\@<=\~[Ss]\z(/\|\"\|'\||\)" end="\z1" skip="\\\\\|\\\z1" contains=@elixirDocStringContained fold keepend -syn region elixirDocString matchgroup=elixirSigilDelimiter start="\%(@\w*doc\s\+\)\@<=\~[Ss]{" end="}" skip="\\\\\|\\}" contains=@elixirDocStringContained fold keepend -syn region elixirDocString matchgroup=elixirSigilDelimiter start="\%(@\w*doc\s\+\)\@<=\~[Ss]<" end=">" skip="\\\\\|\\>" contains=@elixirDocStringContained fold keepend -syn region elixirDocString matchgroup=elixirSigilDelimiter start="\%(@\w*doc\s\+\)\@<=\~[Ss]\[" end="\]" skip="\\\\\|\\\]" contains=@elixirDocStringContained fold keepend -syn region elixirDocString matchgroup=elixirSigilDelimiter start="\%(@\w*doc\s\+\)\@<=\~[Ss](" end=")" skip="\\\\\|\\)" contains=@elixirDocStringContained fold keepend -syn region elixirDocString matchgroup=elixirStringDelimiter start=+\%(@\w*doc\s\+\)\@<=\z("\)+ end=+\z1+ skip=+\\\\\|\\\z1+ contains=@elixirDocStringContained keepend -syn region elixirDocString matchgroup=elixirStringDelimiter start=+\%(@\w*doc\s\+\)\@<=\z("""\)+ end=+\z1+ contains=@elixirDocStringContained fold keepend -syn region elixirDocString matchgroup=elixirSigilDelimiter start=+\%(@\w*doc\s\+\)\@<=\~[Ss]\z('''\)+ end=+\z1+ skip=+\\'+ contains=@elixirDocStringContained fold keepend -syn region elixirDocString matchgroup=elixirSigilDelimiter start=+\%(@\w*doc\s\+\)\@<=\~[Ss]\z("""\)+ end=+\z1+ skip=+\\"+ contains=@elixirDocStringContained fold keepend +syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\s\+\)\@<=\~[Ss]\z(/\|\"\|'\||\)" end="\z1" skip="\\\\\|\\\z1" contains=@elixirDocStringContained fold keepend +syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\s\+\)\@<=\~[Ss]{" end="}" skip="\\\\\|\\}" contains=@elixirDocStringContained fold keepend +syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\s\+\)\@<=\~[Ss]<" end=">" skip="\\\\\|\\>" contains=@elixirDocStringContained fold keepend +syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\s\+\)\@<=\~[Ss]\[" end="\]" skip="\\\\\|\\\]" contains=@elixirDocStringContained fold keepend +syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\s\+\)\@<=\~[Ss](" end=")" skip="\\\\\|\\)" contains=@elixirDocStringContained fold keepend +syn region elixirDocString matchgroup=elixirDocStringDelimiter start=+\%(@\w*doc\s\+\)\@<=\z("\)+ end=+\z1+ skip=+\\\\\|\\\z1+ contains=@elixirDocStringContained keepend +syn region elixirDocString matchgroup=elixirDocStringDelimiter start=+\%(@\w*doc\s\+\)\@<=\z("""\)+ end=+\z1+ contains=@elixirDocStringContained fold keepend +syn region elixirDocString matchgroup=elixirDocSigilDelimiter start=+\%(@\w*doc\s\+\)\@<=\~[Ss]\z('''\)+ end=+\z1+ skip=+\\'+ contains=@elixirDocStringContained fold keepend +syn region elixirDocString matchgroup=elixirDocSigilDelimiter start=+\%(@\w*doc\s\+\)\@<=\~[Ss]\z("""\)+ end=+\z1+ skip=+\\"+ contains=@elixirDocStringContained fold keepend " Defines -syn match elixirDefine '\\(:\)\@!' nextgroup=elixirFunctionDeclaration skipwhite skipnl -syn match elixirPrivateDefine '\\(:\)\@!' nextgroup=elixirFunctionDeclaration skipwhite skipnl -syn match elixirGuard '\\(:\)\@!' nextgroup=elixirFunctionDeclaration skipwhite skipnl -syn match elixirPrivateGuard '\\(:\)\@!' nextgroup=elixirFunctionDeclaration skipwhite skipnl -syn match elixirModuleDefine '\\(:\)\@!' nextgroup=elixirModuleDeclaration skipwhite skipnl -syn match elixirProtocolDefine '\\(:\)\@!' nextgroup=elixirProtocolDeclaration skipwhite skipnl -syn match elixirImplDefine '\\(:\)\@!' nextgroup=elixirImplDeclaration skipwhite skipnl -syn match elixirRecordDefine '\\(:\)\@!' nextgroup=elixirRecordDeclaration skipwhite skipnl -syn match elixirPrivateRecordDefine '\\(:\)\@!' nextgroup=elixirRecordDeclaration skipwhite skipnl -syn match elixirMacroDefine '\\(:\)\@!' nextgroup=elixirMacroDeclaration skipwhite skipnl -syn match elixirPrivateMacroDefine '\\(:\)\@!' nextgroup=elixirMacroDeclaration skipwhite skipnl -syn match elixirDelegateDefine '\\(:\)\@!' nextgroup=elixirDelegateDeclaration skipwhite skipnl -syn match elixirOverridableDefine '\\(:\)\@!' nextgroup=elixirOverridableDeclaration skipwhite skipnl -syn match elixirExceptionDefine '\\(:\)\@!' nextgroup=elixirExceptionDeclaration skipwhite skipnl -syn match elixirCallbackDefine '\\(:\)\@!' nextgroup=elixirCallbackDeclaration skipwhite skipnl +syn match elixirDefine '\\(:\)\@!' nextgroup=elixirFunctionDeclaration skipwhite skipnl +syn match elixirPrivateDefine '\\(:\)\@!' nextgroup=elixirPrivateFunctionDeclaration skipwhite skipnl +syn match elixirGuard '\\(:\)\@!' nextgroup=elixirFunctionDeclaration skipwhite skipnl +syn match elixirPrivateGuard '\\(:\)\@!' nextgroup=elixirPrivateFunctionDeclaration skipwhite skipnl +syn match elixirModuleDefine '\\(:\)\@!' nextgroup=elixirModuleDeclaration skipwhite skipnl +syn match elixirProtocolDefine '\\(:\)\@!' nextgroup=elixirProtocolDeclaration skipwhite skipnl +syn match elixirImplDefine '\\(:\)\@!' nextgroup=elixirImplDeclaration skipwhite skipnl +syn match elixirRecordDefine '\\(:\)\@!' nextgroup=elixirRecordDeclaration skipwhite skipnl +syn match elixirPrivateRecordDefine '\\(:\)\@!' nextgroup=elixirPrivateRecordDeclaration skipwhite skipnl +syn match elixirMacroDefine '\\(:\)\@!' nextgroup=elixirMacroDeclaration skipwhite skipnl +syn match elixirPrivateMacroDefine '\\(:\)\@!' nextgroup=elixirPrivateMacroDeclaration skipwhite skipnl +syn match elixirDelegateDefine '\\(:\)\@!' nextgroup=elixirDelegateDeclaration skipwhite skipnl +syn match elixirOverridableDefine '\\(:\)\@!' nextgroup=elixirOverridableDeclaration skipwhite skipnl +syn match elixirExceptionDefine '\\(:\)\@!' nextgroup=elixirExceptionDeclaration skipwhite skipnl +syn match elixirCallbackDefine '\\(:\)\@!' nextgroup=elixirCallbackDeclaration skipwhite skipnl syn match elixirStructDefine '\\(:\)\@!' skipwhite skipnl " Declarations -syn match elixirModuleDeclaration "[^[:space:];#<]\+" contained nextgroup=elixirBlock skipwhite skipnl -syn match elixirFunctionDeclaration "[^[:space:];#<,()\[\]]\+" contained nextgroup=elixirArguments skipwhite skipnl -syn match elixirProtocolDeclaration "[^[:space:];#<]\+" contained contains=elixirAlias skipwhite skipnl -syn match elixirImplDeclaration "[^[:space:];#<]\+" contained contains=elixirAlias skipwhite skipnl -syn match elixirRecordDeclaration "[^[:space:];#<]\+" contained contains=elixirAlias,elixirAtom skipwhite skipnl -syn match elixirMacroDeclaration "[^[:space:];#<,()\[\]]\+" contained nextgroup=elixirArguments skipwhite skipnl -syn match elixirDelegateDeclaration "[^[:space:];#<,()\[\]]\+" contained contains=elixirFunctionDeclaration skipwhite skipnl -syn region elixirDelegateDeclaration start='\[' end='\]' contained contains=elixirFunctionDeclaration skipwhite skipnl -syn match elixirOverridableDeclaration "[^[:space:];#<]\+" contained contains=elixirAlias,elixirAtom skipwhite skipnl -syn match elixirExceptionDeclaration "[^[:space:];#<]\+" contained contains=elixirAlias,elixirAtom skipwhite skipnl -syn match elixirCallbackDeclaration "[^[:space:];#<,()\[\]]\+" contained contains=elixirFunctionDeclaration skipwhite skipnl +syn match elixirModuleDeclaration "[^[:space:];#<,()\[\]]\+" contained nextgroup=elixirBlock skipwhite skipnl +syn match elixirFunctionDeclaration "[^[:space:];#<,()\[\]]\+" contained nextgroup=elixirArguments skipwhite skipnl +syn match elixirPrivateFunctionDeclaration "[^[:space:];#<,()\[\]]\+" contained nextgroup=elixirArguments skipwhite skipnl +syn match elixirProtocolDeclaration "[^[:space:];#<]\+" contained contains=elixirAlias skipwhite skipnl +syn match elixirImplDeclaration "[^[:space:];#<]\+" contained contains=elixirAlias skipwhite skipnl +syn match elixirRecordDeclaration "[^[:space:];#<]\+" contained contains=elixirAlias,elixirAtom skipwhite skipnl +syn match elixirPrivateRecordDeclaration "[^[:space:];#<]\+" contained contains=elixirAlias,elixirAtom skipwhite skipnl +syn match elixirMacroDeclaration "[^[:space:];#<,()\[\]]\+" contained nextgroup=elixirArguments skipwhite skipnl +syn match elixirPrivateMacroDeclaration "[^[:space:];#<,()\[\]]\+" contained nextgroup=elixirArguments skipwhite skipnl +syn match elixirDelegateDeclaration "[^[:space:];#<,()\[\]]\+" contained contains=elixirFunctionDeclaration skipwhite skipnl +syn region elixirDelegateDeclaration start='\[' end='\]' contained contains=elixirFunctionDeclaration skipwhite skipnl +syn match elixirOverridableDeclaration "[^[:space:];#<]\+" contained contains=elixirAlias,elixirAtom skipwhite skipnl +syn match elixirExceptionDeclaration "[^[:space:];#<]\+" contained contains=elixirAlias,elixirAtom skipwhite skipnl +syn match elixirCallbackDeclaration "[^[:space:];#<,()\[\]]\+" contained contains=elixirFunctionDeclaration skipwhite skipnl " ExUnit syn match elixirExUnitMacro "\(^\s*\)\@<=\<\(test\|describe\|setup\|setup_all\|on_exit\|doctest\)\>" syn match elixirExUnitAssert "\(^\s*\)\@<=\<\(assert\|assert_in_delta\|assert_raise\|assert_receive\|assert_received\|catch_error\)\>" syn match elixirExUnitAssert "\(^\s*\)\@<=\<\(catch_exit\|catch_throw\|flunk\|refute\|refute_in_delta\|refute_receive\|refute_received\)\>" -hi def link elixirBlockDefinition Define -hi def link elixirDefine Define -hi def link elixirPrivateDefine Define -hi def link elixirGuard Define -hi def link elixirPrivateGuard Define -hi def link elixirModuleDefine Define -hi def link elixirProtocolDefine Define -hi def link elixirImplDefine Define -hi def link elixirRecordDefine Define -hi def link elixirPrivateRecordDefine Define -hi def link elixirMacroDefine Define -hi def link elixirPrivateMacroDefine Define -hi def link elixirDelegateDefine Define -hi def link elixirOverridableDefine Define -hi def link elixirExceptionDefine Define -hi def link elixirCallbackDefine Define -hi def link elixirStructDefine Define -hi def link elixirExUnitMacro Define -hi def link elixirModuleDeclaration Type -hi def link elixirFunctionDeclaration Function -hi def link elixirMacroDeclaration Macro -hi def link elixirInclude Include -hi def link elixirComment Comment -hi def link elixirTodo Todo -hi def link elixirKeyword Define -hi def link elixirExUnitAssert Keyword -hi def link elixirOperator Operator -hi def link elixirAtom Constant -hi def link elixirPseudoVariable Constant -hi def link elixirAlias Type -hi def link elixirBoolean Boolean -hi def link elixirVariable Identifier -hi def link elixirSelf Identifier -hi def link elixirUnusedVariable Comment -hi def link elixirNumber Number -hi def link elixirDocString Comment -hi def link elixirDocTest elixirKeyword -hi def link elixirAtomInterpolated elixirAtom -hi def link elixirRegex elixirString -hi def link elixirRegexEscape elixirSpecial -hi def link elixirRegexEscapePunctuation elixirSpecial -hi def link elixirRegexCharClass elixirSpecial -hi def link elixirRegexQuantifier elixirSpecial -hi def link elixirSpecial Special -hi def link elixirString String -hi def link elixirSigil String -hi def link elixirStringDelimiter Delimiter -hi def link elixirRegexDelimiter Delimiter -hi def link elixirInterpolationDelimiter Delimiter -hi def link elixirSigilDelimiter Delimiter +hi def link elixirBlockDefinition Define +hi def link elixirDefine Define +hi def link elixirPrivateDefine Define +hi def link elixirGuard Define +hi def link elixirPrivateGuard Define +hi def link elixirModuleDefine Define +hi def link elixirProtocolDefine Define +hi def link elixirImplDefine Define +hi def link elixirRecordDefine Define +hi def link elixirPrivateRecordDefine Define +hi def link elixirMacroDefine Define +hi def link elixirPrivateMacroDefine Define +hi def link elixirDelegateDefine Define +hi def link elixirOverridableDefine Define +hi def link elixirExceptionDefine Define +hi def link elixirCallbackDefine Define +hi def link elixirStructDefine Define +hi def link elixirExUnitMacro Define +hi def link elixirModuleDeclaration Type +hi def link elixirPrivateFunctionDeclaration elixirFunctionDeclaration +hi def link elixirFunctionDeclaration Function +hi def link elixirPrivateMacroDeclaration elixirMacroDeclaration +hi def link elixirMacroDeclaration Macro +hi def link elixirInclude Include +hi def link elixirComment Comment +hi def link elixirTodo Todo +hi def link elixirKeyword Define +hi def link elixirExUnitAssert Keyword +hi def link elixirOperator Operator +hi def link elixirAtom Constant +hi def link elixirPseudoVariable Constant +hi def link elixirAlias Type +hi def link elixirBoolean Boolean +hi def link elixirVariable Identifier +hi def link elixirSelf Identifier +hi def link elixirUnusedVariable Comment +hi def link elixirNumber Number +hi def link elixirDocString Comment +hi def link elixirDocTest elixirKeyword +hi def link elixirAtomInterpolated elixirAtom +hi def link elixirRegex elixirString +hi def link elixirRegexEscape elixirSpecial +hi def link elixirRegexEscapePunctuation elixirSpecial +hi def link elixirRegexCharClass elixirSpecial +hi def link elixirRegexQuantifier elixirSpecial +hi def link elixirSpecial Special +hi def link elixirString String +hi def link elixirSigil String +hi def link elixirDocStringDelimiter elixirStringDelimiter +hi def link elixirDocSigilDelimiter elixirSigilDelimiter +hi def link elixirStringDelimiter Delimiter +hi def link elixirRegexDelimiter Delimiter +hi def link elixirInterpolationDelimiter Delimiter +hi def link elixirSigilDelimiter Delimiter +hi def link elixirPrivateRecordDeclaration elixirRecordDeclaration let b:current_syntax = "elixir" diff --git a/syntax/gitrebase.vim b/syntax/gitrebase.vim index dad1605..da1c4a2 100644 --- a/syntax/gitrebase.vim +++ b/syntax/gitrebase.vim @@ -20,8 +20,9 @@ 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 gitrebaseBreak "\v^b%(reak)=>" nextgroup=gitrebaseCommit skipwhite +syn match gitrebaseDrop "\v^d%(rop)=>" nextgroup=gitrebaseCommit skipwhite +syn match gitrebaseNoop "\v^noop>" syn match gitrebaseSummary ".*" contains=gitrebaseHash contained syn match gitrebaseCommand ".*" contained syn match gitrebaseComment "^\s*#.*" contains=gitrebaseHash @@ -35,8 +36,9 @@ hi def link gitrebaseEdit PreProc hi def link gitrebaseSquash Type hi def link gitrebaseFixup Special hi def link gitrebaseExec Function -hi def link gitrebaseDrop Comment hi def link gitrebaseBreak Macro +hi def link gitrebaseDrop Comment +hi def link gitrebaseNoop Comment hi def link gitrebaseSummary String hi def link gitrebaseComment Comment hi def link gitrebaseSquashError Error diff --git a/syntax/go.vim b/syntax/go.vim index 51f1a60..a06f62d 100644 --- a/syntax/go.vim +++ b/syntax/go.vim @@ -74,7 +74,7 @@ hi def link goComment Comment hi def link goTodo Todo if go#config#HighlightGenerateTags() - syn match goGenerateVariables contained /\(\$GOARCH\|\$GOOS\|\$GOFILE\|\$GOLINE\|\$GOPACKAGE\|\$DOLLAR\)\>/ + syn match goGenerateVariables contained /\%(\$GOARCH\|\$GOOS\|\$GOFILE\|\$GOLINE\|\$GOPACKAGE\|\$DOLLAR\)\>/ syn region goGenerate start="^\s*//go:generate" end="$" contains=goGenerateVariables hi def link goGenerate PreProc hi def link goGenerateVariables Special @@ -115,7 +115,7 @@ if go#config#HighlightFormatStrings() " 5. Match [n] or nothing before a verb " 6. Match a formatting verb syn match goFormatSpecifier /\ - \([^%]\(%%\)*\)\ + \%([^%]\%(%%\)*\)\ \@<=%[-#0 +]*\ \%(\%(\%(\[\d\+\]\)\=\*\)\|\d\+\)\=\ \%(\.\%(\%(\%(\[\d\+\]\)\=\*\)\|\d\+\)\=\)\=\ @@ -150,18 +150,18 @@ endif " var, const if go#config#FoldEnable('varconst') syn region goVar start='var (' end='^\s*)$' transparent fold - \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goArgumentName,goArgumentType,goSimpleArguments,goPointerOperator + \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator syn region goConst start='const (' end='^\s*)$' transparent fold - \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goArgumentName,goArgumentType,goSimpleArguments,goPointerOperator + \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator else syn region goVar start='var (' end='^\s*)$' transparent - \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goArgumentName,goArgumentType,goSimpleArguments,goPointerOperator + \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator syn region goConst start='const (' end='^\s*)$' transparent - \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goArgumentName,goArgumentType,goSimpleArguments,goPointerOperator + \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator endif " Single-line var, const, and import. -syn match goSingleDecl /\(import\|var\|const\) [^(]\@=/ contains=goImport,goVar,goConst +syn match goSingleDecl /\%(import\|var\|const\) [^(]\@=/ contains=goImport,goVar,goConst " Integers syn match goDecimalInt "\<-\=\d\+\%([Ee][-+]\=\d\+\)\=\>" @@ -192,7 +192,7 @@ hi def link goImaginaryFloat Float " Spaces after "[]" if go#config#HighlightArrayWhitespaceError() - syn match goSpaceError display "\(\[\]\)\@<=\s\+" + syn match goSpaceError display "\%(\[\]\)\@<=\s\+" endif " Spacing errors around the 'chan' keyword @@ -201,24 +201,24 @@ if go#config#HighlightChanWhitespaceError() " " \(\\)\@\)\@\)\@=" + syn match goSpaceError display "\%(\%(\\)\@\)\@=" " send-only annotation on chan type " " \(<-\)\@ (only pick chan when it doesn't come after an arrow) " this prevents picking up '<-chan <-chan' but not 'chan <-' - syn match goSpaceError display "\(\(<-\)\@\)\@<=\s\+\(<-\)\@=" + syn match goSpaceError display "\%(\%(<-\)\@\)\@<=\s\+\%(<-\)\@=" " value-ignoring receives in a few contexts - syn match goSpaceError display "\(\(^\|[={(,;]\)\s*<-\)\@<=\s\+" + syn match goSpaceError display "\%(\%(^\|[={(,;]\)\s*<-\)\@<=\s\+" endif " Extra types commonly seen if go#config#HighlightExtraTypes() - syn match goExtraType /\/ - syn match goExtraType /\/ - syn match goExtraType /\/ - syn match goExtraType /\/ + syn match goExtraType /\/ + syn match goExtraType /\/ + syn match goExtraType /\/ + syn match goExtraType /\/ syn match goExtraType /\/ endif @@ -265,21 +265,22 @@ endif hi def link goOperator Operator " Functions; -if go#config#HighlightFunctions() || go#config#HighlightFunctionArguments() - syn match goDeclaration /\/ nextgroup=goReceiver,goFunction,goSimpleArguments skipwhite skipnl - syn match goReceiverVar /\w\+\ze\s\+\(\w\|\*\)/ nextgroup=goPointerOperator,goReceiverType skipwhite skipnl contained +if go#config#HighlightFunctions() || go#config#HighlightFunctionParameters() + syn match goDeclaration /\/ nextgroup=goReceiver,goFunction,goSimpleParams skipwhite skipnl + syn match goReceiverVar /\w\+\ze\s\+\%(\w\|\*\)/ nextgroup=goPointerOperator,goReceiverType skipwhite skipnl contained syn match goPointerOperator /\*/ nextgroup=goReceiverType contained skipwhite skipnl - syn match goFunction /\w\+/ nextgroup=goSimpleArguments contained skipwhite skipnl + syn match goFunction /\w\+/ nextgroup=goSimpleParams contained skipwhite skipnl syn match goReceiverType /\w\+/ contained -if go#config#HighlightFunctionArguments() - syn match goSimpleArguments /(\(\w\|\_s\|[*\.\[\],\{\}<>-]\)*)/ contained contains=goArgumentName nextgroup=goSimpleArguments skipwhite skipnl - syn match goArgumentName /\w\+\(\s*,\s*\w\+\)*\ze\s\+\(\w\|\.\|\*\|\[\)/ contained nextgroup=goArgumentType skipwhite skipnl - syn match goArgumentType /\([^,)]\|\_s\)\+,\?/ contained nextgroup=goArgumentName skipwhite skipnl - \ contains=goVarArgs,goType,goSignedInts,goUnsignedInts,goFloats,goComplexes,goDeclType,goBlock - hi def link goReceiverVar goArgumentName - hi def link goArgumentName Identifier -endif - syn match goReceiver /(\s*\w\+\(\s\+\*\?\s*\w\+\)\?\s*)\ze\s*\w/ contained nextgroup=goFunction contains=goReceiverVar skipwhite skipnl + if go#config#HighlightFunctionParameters() + syn match goSimpleParams /(\%(\w\|\_s\|[*\.\[\],\{\}<>-]\)*)/ contained contains=goParamName,goType nextgroup=goFunctionReturn skipwhite skipnl + syn match goFunctionReturn /(\%(\w\|\_s\|[*\.\[\],\{\}<>-]\)*)/ contained contains=goParamName,goType skipwhite skipnl + syn match goParamName /\w\+\%(\s*,\s*\w\+\)*\ze\s\+\%(\w\|\.\|\*\|\[\)/ contained nextgroup=goParamType skipwhite skipnl + syn match goParamType /\%([^,)]\|\_s\)\+,\?/ contained nextgroup=goParamName skipwhite skipnl + \ contains=goVarArgs,goType,goSignedInts,goUnsignedInts,goFloats,goComplexes,goDeclType,goBlock + hi def link goReceiverVar goParamName + hi def link goParamName Identifier + endif + syn match goReceiver /(\s*\w\+\%(\s\+\*\?\s*\w\+\)\?\s*)\ze\s*\w/ contained nextgroup=goFunction contains=goReceiverVar skipwhite skipnl else syn keyword goDeclaration func endif @@ -293,7 +294,20 @@ hi def link goFunctionCall Type " Fields; if go#config#HighlightFields() - syn match goField /\.\w\+\([.\ \n\r\:\)\[,]\)\@=/hs=s+1 + " 1. Match a sequence of word characters coming after a '.' + " 2. Require the following but dont match it: ( \@= see :h E59) + " - The symbols: / - + * % OR + " - The symbols: [] {} <> ) OR + " - The symbols: \n \r space OR + " - The symbols: , : . + " 3. Have the start of highlight (hs) be the start of matched + " pattern (s) offsetted one to the right (+1) (see :h E401) + syn match goField /\.\w\+\ + \%(\%([\/\-\+*%]\)\|\ + \%([\[\]{}<\>\)]\)\|\ + \%([\!=\^|&]\)\|\ + \%([\n\r\ ]\)\|\ + \%([,\:.]\)\)\@=/hs=s+1 endif hi def link goField Identifier @@ -302,7 +316,7 @@ if go#config#HighlightTypes() syn match goTypeConstructor /\<\w\+{\@=/ syn match goTypeDecl /\/ nextgroup=goTypeName skipwhite skipnl syn match goTypeName /\w\+/ contained nextgroup=goDeclType skipwhite skipnl - syn match goDeclType /\<\(interface\|struct\)\>/ skipwhite skipnl + syn match goDeclType /\<\%(interface\|struct\)\>/ skipwhite skipnl hi def link goReceiverType Type else syn keyword goDeclType struct interface diff --git a/syntax/i3config.vim b/syntax/i3config.vim index 1d6367f..4763ba4 100644 --- a/syntax/i3config.vim +++ b/syntax/i3config.vim @@ -55,8 +55,12 @@ syn keyword InitializeKeyword set contained syn match Initialize /^\s*set\s\+.*$/ contains=Variable,InitializeKeyword,Color,String " Gaps -syn keyword GapStyleKeyword inner outer current all set plus minus contained -syn match GapStyle /^\s*\(gaps\)\s\+\(inner\|outer\)\(\s\+\(current\|all\)\)\?\(\s\+\(set\|plus\|minus\)\)\?\(\s\+\d\+\)$/ contains=GapStyleKeyword,number +syn keyword GapStyleKeyword inner outer horizontal vertical top right bottom left current all set plus minus toggle contained +syn match GapStyle /^\s*\(gaps\)\s\+\(inner\|outer\|horizontal\|vertical\|left\|top\|right\|bottom\)\(\s\+\(current\|all\)\)\?\(\s\+\(set\|plus\|minus\|toggle\)\)\?\(\s\+\(\d\+\|\$.*\)\)$/ contains=GapStyleKeyword,number,Variable +syn keyword SmartGapKeyword on inverse_outer contained +syn match SmartGap /^\s*smart_gaps\s\+\(on\|inverse_outer\)\s\?$/ contains=SmartGapKeyword +syn keyword SmartBorderKeyword on no_gaps contained +syn match SmartBorder /^\s*smart_borders\s\+\(on\|no_gaps\)\s\?$/ contains=SmartBorderKeyword " Keyboard bindings syn keyword Action toggle fullscreen restart key import kill shrink grow contained @@ -87,8 +91,8 @@ syn keyword BorderStyleKeyword none normal pixel contained syn match BorderStyle /^\s*\(new_window\|new_float\|default_border\|default_floating_border\)\s\+\(none\|\(normal\|pixel\)\(\s\+\d\+\)\?\)\s\?$/ contains=BorderStyleKeyword,number " Hide borders and edges -syn keyword EdgeKeyword none vertical horizontal both contained -syn match Edge /^\s*hide_edge_borders\s\+\(none\|vertical\|horizontal\|both\)\s\?$/ contains=EdgeKeyword +syn keyword EdgeKeyword none vertical horizontal both smart smart_no_gaps contained +syn match Edge /^\s*hide_edge_borders\s\+\(none\|vertical\|horizontal\|both\|smart\|smart_no_gaps\)\s\?$/ contains=EdgeKeyword " Arbitrary commands for specific windows (for_window) syn keyword CommandKeyword for_window contained @@ -187,6 +191,8 @@ hi! def link OrientationKeyword Type hi! def link MouseWarpingType Type hi! def link FocusFollowsMouseType Type hi! def link GapStyleKeyword Type +hi! def link SmartGapKeyword Type +hi! def link SmartBorderKeyword Type hi! def link LayoutKeyword Type hi! def link BorderStyleKeyword Type hi! def link EdgeKeyword Type @@ -215,6 +221,8 @@ hi! def link FontKeyword Identifier hi! def link BindKeyword Identifier hi! def link Orientation Identifier hi! def link GapStyle Identifier +hi! def link SmartGap Identifier +hi! def link SmartBorder Identifier hi! def link Layout Identifier hi! def link BorderStyle Identifier hi! def link Edge Identifier @@ -239,7 +247,7 @@ hi! def link FocusOnActivationKeyword Identifier hi! def link DrawingMarksKeyword Identifier hi! def link BlockKeyword Identifier hi! def link Variable Statement -hi! def link ArbitraryCommand Ignore +hi! def link ArbitraryCommand Type let b:current_syntax = "i3config" diff --git a/syntax/javascript.vim b/syntax/javascript.vim index 7f12752..b0394ca 100644 --- a/syntax/javascript.vim +++ b/syntax/javascript.vim @@ -138,8 +138,8 @@ syntax keyword jsHtmlEvents onblur onclick oncontextmenu ondblclick onfocus syntax region jsBracket matchgroup=jsBrackets start=/\[/ end=/\]/ contains=@jsExpression,jsSpreadExpression extend fold syntax region jsParen matchgroup=jsParens start=/(/ end=/)/ contains=@jsExpression extend fold nextgroup=jsFlowDefinition syntax region jsParenDecorator contained matchgroup=jsParensDecorator start=/(/ end=/)/ contains=@jsAll extend fold -syntax region jsParenIfElse contained matchgroup=jsParensIfElse start=/(/ end=/)/ contains=@jsAll skipwhite skipempty nextgroup=jsCommentIfElse,jsIfElseBlock extend fold -syntax region jsParenRepeat contained matchgroup=jsParensRepeat start=/(/ end=/)/ contains=@jsAll skipwhite skipempty nextgroup=jsCommentRepeat,jsRepeatBlock extend fold +syntax region jsParenIfElse contained matchgroup=jsParensIfElse start=/(/ end=/)/ contains=@jsAll skipwhite skipempty nextgroup=jsCommentIfElse,jsIfElseBlock,jsReturn extend fold +syntax region jsParenRepeat contained matchgroup=jsParensRepeat start=/(/ end=/)/ contains=@jsAll skipwhite skipempty nextgroup=jsCommentRepeat,jsRepeatBlock,jsReturn extend fold syntax region jsParenSwitch contained matchgroup=jsParensSwitch start=/(/ end=/)/ contains=@jsAll skipwhite skipempty nextgroup=jsSwitchBlock extend fold syntax region jsParenCatch contained matchgroup=jsParensCatch start=/(/ end=/)/ skipwhite skipempty nextgroup=jsTryCatchBlock extend fold syntax region jsFuncArgs contained matchgroup=jsFuncParens start=/(/ end=/)/ contains=jsFuncArgCommas,jsComment,jsFuncArgExpression,jsDestructuringBlock,jsDestructuringArray,jsRestExpression,jsFlowArgumentDef skipwhite skipempty nextgroup=jsCommentFunction,jsFuncBlock,jsFlowReturn extend fold @@ -157,7 +157,7 @@ syntax region jsBlock matchgroup=jsBraces s syntax region jsModuleGroup contained matchgroup=jsModuleBraces start=/{/ end=/}/ contains=jsModuleKeyword,jsModuleComma,jsModuleAs,jsComment,jsFlowTypeKeyword skipwhite skipempty nextgroup=jsFrom fold syntax region jsSpreadExpression contained matchgroup=jsSpreadOperator start=/\.\.\./ end=/[,}\]]\@=/ contains=@jsExpression syntax region jsRestExpression contained matchgroup=jsRestOperator start=/\.\.\./ end=/[,)]\@=/ -syntax region jsTernaryIf matchgroup=jsTernaryIfOperator start=/?/ end=/\%(:\|}\@=\)/ contains=@jsExpression extend skipwhite skipempty nextgroup=@jsExpression +syntax region jsTernaryIf matchgroup=jsTernaryIfOperator start=/?:\@!/ end=/\%(:\|}\@=\)/ contains=@jsExpression extend skipwhite skipempty nextgroup=@jsExpression syntax match jsOperator /?\.\ze\_D/ syntax match jsGenerator contained /\*/ skipwhite skipempty nextgroup=jsFuncName,jsFuncArgs,jsFlowFunctionGroup diff --git a/syntax/julia.vim b/syntax/julia.vim index e599647..5f40db6 100644 --- a/syntax/julia.vim +++ b/syntax/julia.vim @@ -156,37 +156,41 @@ syntax region juliaParBlockInRange matchgroup=juliaParDelim contained start="(" syntax region juliaSqBraBlock matchgroup=juliaParDelim start="\[" end="\]" contains=@juliaExpressions,juliaParBlockInRange,juliaRangeEnd,juliaComprehensionFor,juliaSymbolS,juliaQuotedParBlockS,juliaQuotedQMarkParS syntax region juliaCurBraBlock matchgroup=juliaParDelim start="{" end="}" contains=@juliaExpressions -syntax match juliaKeyword display "\<\%(return\|local\|global\|import\%(all\)\?\|export\|using\|const\|where\)\>" +" This is really ugly. It would be better to mask most keywords when a dot is +" found, introducing some kind of dot-environment +let s:nodot = '\%(\.\)\@'.s:d(1).'1"' syntax match juliaInfixKeyword display "\%(=\s*\)\@\S\@!\%(\s*=\)\@!" -syntax match juliaRepKeyword display "\<\%(break\|continue\)\>" -syntax region juliaConditionalBlock matchgroup=juliaConditional start="\" end="\" contains=@juliaExpressions,juliaConditionalEIBlock,juliaConditionalEBlock fold -syntax region juliaConditionalEIBlock matchgroup=juliaConditional transparent contained start="\" end="\<\%(end\|else\|elseif\)\>"me=s-1 contains=@juliaExpressions,juliaConditionalEIBlock,juliaConditionalEBlock -syntax region juliaConditionalEBlock matchgroup=juliaConditional transparent contained start="\" end="\"me=s-1 contains=@juliaExpressions -syntax region juliaWhileBlock matchgroup=juliaRepeat start="\" end="\" contains=@juliaExpressions fold -syntax region juliaForBlock matchgroup=juliaRepeat start="\" end="\" contains=@juliaExpressions,juliaOuter fold -syntax region juliaBeginBlock matchgroup=juliaBlKeyword start="\" end="\" contains=@juliaExpressions fold -syntax region juliaFunctionBlock matchgroup=juliaBlKeyword start="\" end="\" contains=@juliaExpressions fold -syntax region juliaMacroBlock matchgroup=juliaBlKeyword start="\" end="\" contains=@juliaExpressions fold -syntax region juliaQuoteBlock matchgroup=juliaBlKeyword start="\" end="\" contains=@juliaExpressions fold +exec 'syntax match juliaRepKeyword display "'.s:nodot.'\<\%(break\|continue\)\>"' +exec 'syntax region juliaConditionalBlock matchgroup=juliaConditional start="'.s:nodot.'\" end="'.s:nodot.'\" contains=@juliaExpressions,juliaConditionalEIBlock,juliaConditionalEBlock fold' +exec 'syntax region juliaConditionalEIBlock matchgroup=juliaConditional transparent contained start="'.s:nodot.'\" end="'.s:nodot.'\<\%(end\|else\|elseif\)\>"me=s-1 contains=@juliaExpressions,juliaConditionalEIBlock,juliaConditionalEBlock' +exec 'syntax region juliaConditionalEBlock matchgroup=juliaConditional transparent contained start="'.s:nodot.'\" end="'.s:nodot.'\"me=s-1 contains=@juliaExpressions' +exec 'syntax region juliaWhileBlock matchgroup=juliaRepeat start="'.s:nodot.'\" end="'.s:nodot.'\" contains=@juliaExpressions fold' +exec 'syntax region juliaForBlock matchgroup=juliaRepeat start="'.s:nodot.'\" end="'.s:nodot.'\" contains=@juliaExpressions,juliaOuter fold' +exec 'syntax region juliaBeginBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\" end="'.s:nodot.'\" contains=@juliaExpressions fold' +exec 'syntax region juliaFunctionBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\" end="'.s:nodot.'\" contains=@juliaExpressions fold' +exec 'syntax region juliaMacroBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\" end="'.s:nodot.'\" contains=@juliaExpressions fold' +exec 'syntax region juliaQuoteBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\" end="'.s:nodot.'\" contains=@juliaExpressions fold' if b:julia_syntax_version <= 10 - syntax region juliaTypeBlock matchgroup=juliaBlKeyword06 start="\" end="\" contains=@juliaExpressions fold - syntax region juliaImmutableBlock matchgroup=juliaBlKeyword06 start="\" end="\" contains=@juliaExpressions fold + exec 'syntax region juliaTypeBlock matchgroup=juliaBlKeyword06 start="'.s:nodot.'\" end="'.s:nodot.'\" contains=@juliaExpressions fold' + exec 'syntax region juliaImmutableBlock matchgroup=juliaBlKeyword06 start="'.s:nodot.'\" end="'.s:nodot.'\" contains=@juliaExpressions fold' endif -syntax region juliaStructBlock matchgroup=juliaBlKeyword start="\" end="\" contains=@juliaExpressions fold -syntax region juliaMutableStructBlock matchgroup=juliaBlKeyword start="\" end="\" contains=@juliaExpressions fold -syntax region juliaLetBlock matchgroup=juliaBlKeyword start="\" end="\" contains=@juliaExpressions fold -syntax region juliaDoBlock matchgroup=juliaBlKeyword start="\" end="\" contains=@juliaExpressions fold +exec 'syntax region juliaStructBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\" end="'.s:nodot.'\" contains=@juliaExpressions fold' +exec 'syntax region juliaMutableStructBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\" end="'.s:nodot.'\" contains=@juliaExpressions fold' +exec 'syntax region juliaLetBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\" end="'.s:nodot.'\" contains=@juliaExpressions fold' +exec 'syntax region juliaDoBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\" end="'.s:nodot.'\" contains=@juliaExpressions fold' exec 'syntax region juliaModuleBlock matchgroup=juliaBlKeyword start="\%(\%(\.\s*\)\@'.s:d(6).'" end="\" contains=@juliaExpressions fold' -syntax region juliaExceptionBlock matchgroup=juliaException start="\" end="\" contains=@juliaExpressions,juliaCatchBlock,juliaFinallyBlock fold -syntax region juliaCatchBlock matchgroup=juliaException transparent contained start="\" end="\"me=s-1 contains=@juliaExpressions,juliaFinallyBlock -syntax region juliaFinallyBlock matchgroup=juliaException transparent contained start="\" end="\"me=s-1 contains=@juliaExpressions -syntax match juliaTypedef "\<\%(abstract\|typealias\|bitstype\)\>" +exec 'syntax region juliaExceptionBlock matchgroup=juliaException start="'.s:nodot.'\" end="'.s:nodot.'\" contains=@juliaExpressions,juliaCatchBlock,juliaFinallyBlock fold' +exec 'syntax region juliaCatchBlock matchgroup=juliaException transparent contained start="'.s:nodot.'\" end="'.s:nodot.'\"me=s-1 contains=@juliaExpressions,juliaFinallyBlock' +exec 'syntax region juliaFinallyBlock matchgroup=juliaException transparent contained start="'.s:nodot.'\" end="'.s:nodot.'\"me=s-1 contains=@juliaExpressions' +exec 'syntax match juliaTypedef "'.s:nodot.'\<\%(abstract\|typealias\|bitstype\)\>"' " AbstractBlock needs to come after to take precedence -syntax region juliaAbstractBlock matchgroup=juliaBlKeyword start="\" end="\" fold contains=@juliaExpressions -syntax region juliaPrimitiveBlock matchgroup=juliaBlKeyword start="\" end="\" fold contains=@juliaExpressions +exec 'syntax region juliaAbstractBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\" end="'.s:nodot.'\" fold contains=@juliaExpressions' +exec 'syntax region juliaPrimitiveBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\" end="'.s:nodot.'\" fold contains=@juliaExpressions' exec 'syntax region juliaComprehensionFor matchgroup=juliaComprehensionFor transparent contained start="\%([^[:space:],;:({[]\_s*\)\@'.s:d(80).'<=\" end="\ze[]);]" contains=@juliaExpressions,juliaComprehensionIf,juliaComprehensionFor' -syntax match juliaComprehensionIf contained "\" +exec 'syntax match juliaComprehensionIf contained "'.s:nodot.'\"' exec 'syntax match juliaOuter contained "\"' @@ -219,7 +223,7 @@ syntax match juliaBaseTypeRange display "\<\%(Dims\|RangeIndex\|\%(Ordinal\|St syntax match juliaBaseTypeRange06 display "\" syntax match juliaBaseTypeRange1011 display "\<\(Abstract\|Lin\)Range\>" syntax match juliaBaseTypeRegex display "\" -syntax match juliaBaseTypeFact display "\" +syntax match juliaBaseTypeFact display "\<\%(Factorization\|BunchKaufman\|\%(Cholesky\|QR\)\%(Pivoted\)\?\|\%(Generalized\)\?\%(Eigen\|SVD\|Schur\)\|Hessenberg\|LDLt\|LQ\|LU\)\>" syntax match juliaBaseTypeSort display "\<\%(Insertion\|\(Partial\)\?Quick\|Merge\)Sort\>" syntax match juliaBaseTypeRound display "\" syntax match juliaBaseTypeSpecial display "\<\%(LocalProcess\|ClusterManager\)\>" diff --git a/syntax/kotlin.vim b/syntax/kotlin.vim index 70803f5..a4019e5 100644 --- a/syntax/kotlin.vim +++ b/syntax/kotlin.vim @@ -3,7 +3,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'kotlin') == -1 " Vim syntax file " Language: Kotlin " Maintainer: Alexander Udalov -" Latest Revision: 23 November 2017 +" Latest Revision: 14 January 2019 if exists("b:current_syntax") finish @@ -36,6 +36,12 @@ syn match ktShebang "\v^#!.*$" syn match ktLineComment "\v//.*$" contains=ktTodo,@Spell syn region ktComment matchgroup=ktCommentMatchGroup start="/\*" end="\*/" contains=ktComment,ktTodo,@Spell +syn region ktDocComment start="/\*\*" end="\*/" contains=ktDocTag,ktTodo,@Spell +syn match ktDocTag "\v\@(author|constructor|receiver|return|since|suppress)>" contained +syn match ktDocTag "\v\@(exception|param|property|throws|see|sample)>\s*\S+" contains=ktDocTagParam contained +syn match ktDocTagParam "\v(\s|\[)\S+" contained +syn match ktComment "/\*\*/" + syn match ktSpecialCharError "\v\\." contained syn match ktSpecialChar "\v\\([tbnr'"$\\]|u\x{4})" contained syn region ktString start='"' skip='\\"' end='"' contains=ktSimpleInterpolation,ktComplexInterpolation,ktSpecialChar,ktSpecialCharError @@ -49,11 +55,11 @@ syn match ktAnnotation "\v(\w)@/ end=/$/ contains=mkdLink,mkdInlineURL,mkdLineBreak,@Spell -execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/\(\([^\\]\|^\)\\\)\@]*\\\@" end=""' . s:concealends -execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start="]*\\\@" end=""' . s:concealends +execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/\(\([^\\]\|^\)\\\)\@]*\\\@" end=""' . s:concealcode +execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start="]*\\\@" end=""' . s:concealcode syn region mkdFootnote start="\[^" end="\]" syn match mkdCode /^\s*\n\(\(\s\{8,}[^ ]\|\t\t\+[^\t]\).*\n\)\+/ syn match mkdCode /\%^\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/ @@ -147,7 +151,13 @@ if get(g:, 'vim_markdown_math', 0) syn region mkdMath start="\\\@=!\/]\?' syntax region mustacheInside start=/{{[^!][$#^/]\?/ end=/}}}\?/ keepend containedin=TOP,@htmlMustacheContainer -syntax match mustacheOperators '=\|\.\|/' contained containedin=mustacheInside,mustacheParam,@htmlMustacheContainer +syntax match mustacheOperators '=\|\.\|/' contained containedin=mustacheInside,mustacheParam syntax region mustacheHtmlValue start=/={{[^!][$#^/]\?/rs=s+1,hs=s+1 end=/}}/ oneline keepend contained containedin=htmlTag contains=mustacheInside syntax region mustachePartial start=/{{[<>]/lc=2 end=/}}/me=e-2 contained containedin=mustacheInside,@htmlMustacheContainer syntax region mustacheMarkerSet start=/{{=/lc=2 end=/=}}/me=e-2 contained containedin=mustacheInside,@htmlMustacheContainer diff --git a/syntax/pug.vim b/syntax/pug.vim index 31dcaec..ba68739 100644 --- a/syntax/pug.vim +++ b/syntax/pug.vim @@ -32,16 +32,17 @@ syn region pugJavascript matchgroup=pugJavascriptOutputChar start="[!&]\==\|\~" syn region pugJavascript matchgroup=pugJavascriptChar start="-" skip=",\s*$" end="$" contained contains=@htmlJavascript keepend syn cluster pugTop contains=pugBegin,pugComment,pugHtmlComment,pugJavascript syn match pugBegin "^\s*\%([<>]\|&[^=~ ]\)\@!" nextgroup=pugTag,pugClassChar,pugIdChar,pugPlainChar,pugJavascript,pugScriptConditional,pugScriptStatement,pugPipedText -syn match pugTag "+\?[[:alnum:]_-]\+\%(:\w\+\)\=" contained contains=htmlTagName,htmlSpecialTagName nextgroup=@pugComponent +syn match pugTag "+\?[[:alnum:]_-]\+\%(:\w\+\)\=" contained contains=htmlTagName,htmlSpecialTagName,pugJavascript nextgroup=@pugComponent syn cluster pugComponent contains=pugAttributes,pugIdChar,pugBlockExpansionChar,pugClassChar,pugPlainChar,pugJavascript,pugTagBlockChar,pugTagInlineText -syntax keyword pugCommentTodo contained TODO FIXME XXX TBD +syn keyword pugCommentTodo contained TODO FIXME XXX TBD syn match pugComment '\(\s\+\|^\)\/\/.*$' contains=pugCommentTodo,@Spell syn region pugCommentBlock start="\z(\s\+\|^\)\/\/.*$" end="^\%(\z1\s\|\s*$\)\@!" contains=pugCommentTodo,@Spell keepend syn region pugHtmlConditionalComment start="" contains=pugCommentTodo,@Spell syn region pugAngular2 start="(" end=")" contains=htmlEvent syn region pugJavascriptString start=+"+ skip=+\\\("\|$\)+ end=+"\|$+ contained syn region pugJavascriptString start=+'+ skip=+\\\('\|$\)+ end=+'\|$+ contained -syn region pugAttributes matchgroup=pugAttributesDelimiter start="(" end=")" contained contains=pugJavascriptString,pugHtmlArg,pugAngular2,htmlArg,htmlEvent,htmlCssDefinition nextgroup=@pugComponent +syn region pugJavascriptString start=+`+ skip=+\\\(`\|$\)+ end=+`\|$+ contains=javascriptInterpolation contained +syn region pugAttributes matchgroup=pugAttributesDelimiter start="(" end="\(.\zs)\)\|)" contained contains=pugJavascriptString,pugHtmlArg,pugAngular2,htmlArg,htmlEvent,htmlCssDefinition nextgroup=@pugComponent syn match pugClassChar "\." containedin=htmlTagName nextgroup=pugClass syn match pugBlockExpansionChar ":\s\+" contained nextgroup=pugTag,pugClassChar,pugIdChar syn match pugIdChar "#[[{]\@!" contained nextgroup=pugId @@ -71,9 +72,10 @@ syn region pugPlainFilter matchgroup=pugFilter start="^\z(\s*\):\%(sass\|less\| syn match pugScriptConditional "^\s*\<\%(if\|else\|else if\|elif\|unless\|while\|until\|case\|when\|default\)\>[?!]\@!" syn match pugScriptStatement "^\s*\<\%(each\|for\|block\|prepend\|append\|mixin\|extends\|include\)\>[?!]\@!" syn region pugScriptLoopRegion start="^\s*\(for \)" end="$" contains=pugScriptLoopKeywords -syn keyword pugScriptLoopKeywords for in contained +syn keyword pugScriptLoopKeywords for in -syn region pugJavascript start="^\z(\s*\)script\%(:\w\+\)\=" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlJavascript,pugJavascriptTag,pugCoffeescriptFilter keepend +syn region pugJavascript start="^\z(\s*\)script\%(:\w\+\)\=" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlJavascript,pugJavascriptTag,pugCoffeescriptFilter keepend +syn region javascriptInterpolation start=/${/ end=/}/ contained syn region pugCoffeescriptFilter matchgroup=pugFilter start="^\z(\s*\):coffee-\?script\s*$" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlCoffeescript contained syn region pugJavascriptTag contained start="^\z(\s*\)script\%(:\w\+\)\=" end="$" contains=pugBegin,pugTag @@ -104,6 +106,7 @@ hi def link pugComment Comment hi def link pugCommentBlock Comment hi def link pugHtmlConditionalComment pugComment hi def link pugJavascriptString String +hi def link javascriptInterpolation Delimiter let b:current_syntax = "pug" diff --git a/syntax/python.vim b/syntax/python.vim index e3ac9ca..251b0f7 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -46,6 +46,7 @@ if s:Enabled('g:python_highlight_all') if s:Enabled('g:python_highlight_builtins') call s:EnableByDefault('g:python_highlight_builtin_objs') call s:EnableByDefault('g:python_highlight_builtin_funcs') + call s:EnableByDefault('g:python_highlight_builtin_types') endif call s:EnableByDefault('g:python_highlight_exceptions') call s:EnableByDefault('g:python_highlight_string_formatting') @@ -94,7 +95,7 @@ else syn match pythonStatement '\' nextgroup=pythonFunction skipwhite syn match pythonStatement '\' syn match pythonStatement '\' - syn cluster pythonExpression contains=pythonStatement,pythonRepeat,pythonConditional,pythonOperator,pythonNumber,pythonHexNumber,pythonOctNumber,pythonBinNumber,pythonFloat,pythonString,pythonBytes,pythonBoolean,pythonBuiltinObj,pythonBuiltinFunc + syn cluster pythonExpression contains=pythonStatement,pythonRepeat,pythonConditional,pythonOperator,pythonNumber,pythonHexNumber,pythonOctNumber,pythonBinNumber,pythonFloat,pythonString,pythonBytes,pythonBoolean,pythonNone,pythonSingleton,pythonBuiltinObj,pythonBuiltinFunc,pythonBuiltinType endif @@ -328,18 +329,17 @@ else syn match pythonFloat '\.\d\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=\>' display syn match pythonFloat '\<\d\%([_0-9]*\d\)\=[eE][+-]\=\d\%([_0-9]*\d\)\=[jJ]\=\>' display - syn match pythonFloat '\<\d\%([_0-9]*\d\)\=\.\d\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=' display + syn match pythonFloat '\<\d\%([_0-9]*\d\)\=\.\d\=\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=' display endif " -" Builtin objects and types +" Builtin objects " if s:Enabled('g:python_highlight_builtin_objs') syn keyword pythonNone None syn keyword pythonBoolean True False - syn keyword pythonBuiltinObj Ellipsis NotImplemented - syn match pythonBuiltinObj '\v\.@' + syn keyword pythonSingleton Ellipsis NotImplemented syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__ syn keyword pythonBuiltinObj __loader__ __spec__ __path__ __cached__ endif @@ -357,7 +357,7 @@ if s:Enabled('g:python_highlight_builtin_funcs') let s:funcs_re .= '|print' endif else - let s:funcs_re .= '|ascii|exec|print' + let s:funcs_re .= '|ascii|breakpoint|exec|print' endif let s:funcs_re = 'syn match pythonBuiltinFunc ''\v\.@' @@ -370,12 +370,21 @@ if s:Enabled('g:python_highlight_builtin_funcs') unlet s:funcs_re endif +" +" Builtin types +" + +if s:Enabled('g:python_highlight_builtin_types') + syn match pythonBuiltinType '\v\.@' +endif + + " " Builtin exceptions and warnings " if s:Enabled('g:python_highlight_exceptions') - let s:exs_re = 'BaseException|Exception|ArithmeticError|LookupError|EnvironmentError|AssertionError|AttributeError|BufferError|EOFError|FloatingPointError|GeneratorExit|IOError|ImportError|IndexError|KeyError|KeyboardInterrupt|MemoryError|NameError|NotImplementedError|OSError|OverflowError|ReferenceError|RuntimeError|StopIteration|SyntaxError|IndentationError|TabError|SystemError|SystemExit|TypeError|UnboundLocalError|UnicodeError|UnicodeEncodeError|UnicodeDecodeError|UnicodeTranslateError|ValueError|VMSError|WindowsError|ZeroDivisionError|Warning|UserWarning|BytesWarning|DeprecationWarning|PendingDepricationWarning|SyntaxWarning|RuntimeWarning|FutureWarning|ImportWarning|UnicodeWarning' + let s:exs_re = 'BaseException|Exception|ArithmeticError|LookupError|EnvironmentError|AssertionError|AttributeError|BufferError|EOFError|FloatingPointError|GeneratorExit|IOError|ImportError|IndexError|KeyError|KeyboardInterrupt|MemoryError|NameError|NotImplementedError|OSError|OverflowError|ReferenceError|RuntimeError|StopIteration|SyntaxError|IndentationError|TabError|SystemError|SystemExit|TypeError|UnboundLocalError|UnicodeError|UnicodeEncodeError|UnicodeDecodeError|UnicodeTranslateError|ValueError|VMSError|WindowsError|ZeroDivisionError|Warning|UserWarning|BytesWarning|DeprecationWarning|PendingDeprecationWarning|SyntaxWarning|RuntimeWarning|FutureWarning|ImportWarning|UnicodeWarning' if s:Python2Syntax() let s:exs_re .= '|StandardError' @@ -416,7 +425,6 @@ if v:version >= 508 || !exists('did_python_syn_inits') HiLink pythonDecorator Define HiLink pythonDottedName Function - HiLink pythonDot Normal HiLink pythonComment Comment if !s:Enabled('g:python_highlight_file_headers_as_comments') @@ -472,9 +480,11 @@ if v:version >= 508 || !exists('did_python_syn_inits') HiLink pythonBoolean Boolean HiLink pythonNone Constant + HiLink pythonSingleton Constant - HiLink pythonBuiltinObj Structure + HiLink pythonBuiltinObj Identifier HiLink pythonBuiltinFunc Function + HiLink pythonBuiltinType Structure HiLink pythonExClass Structure HiLink pythonClassVar Identifier diff --git a/syntax/racket.vim b/syntax/racket.vim index 717e1df..4ab9b63 100644 --- a/syntax/racket.vim +++ b/syntax/racket.vim @@ -57,6 +57,14 @@ syn keyword racketSyntax define* define*-values define*-syntax define*-syntaxes syn keyword racketSyntax package? package-exported-identifiers package-original-identifiers syn keyword racketSyntax block #%stratified-body +" 8 Contracts +" 8.2 Function contracts +syn keyword racketSyntax -> ->* ->i ->d case-> dynamic->* unconstrained-domain-> + +" 8.6.1 Nested Contract Boundaries +syn keyword racketSyntax with-contract define/contract define-struct/contract +syn keyword racketSyntax invariant-assertion current-contract-region + " 9 Pattern Matching syn keyword racketSyntax match match* match/values define/match syn keyword racketSyntax match-lambda match-lambda* match-lambda** @@ -75,6 +83,9 @@ syn keyword racketSyntax reset-at shift-at prompt0 reset0 control0 shift0 syn keyword racketSyntax prompt0-at reset0-at control0-at shift0-at syn keyword racketSyntax set cupto +" 11.3.2 Parameters +syn keyword racketSyntax parameterize parameterize* + " 12.5 Writing syn keyword racketSyntax write display displayln print syn keyword racketSyntax fprintf printf eprintf format @@ -93,7 +104,8 @@ syn keyword racketSyntax make-custodian-box custodian-box-value " lambda sign syn match racketSyntax /\<[\u03bb]\>/ -" Functions + +" Functions ================================================================== syn keyword racketFunc boolean? not equal? eqv? eq? equal?/recur immutable? syn keyword racketFunc true false symbol=? boolean=? false? @@ -108,8 +120,8 @@ syn keyword racketFunc inexact->exact exact->inexact " 3.2.2.1 Arithmetic syn keyword racketFunc + - * / quotient remainder quotient/remainder modulo -syn keyword racketFunc add1 sub1 abs max min gcd lcm round floor ceiling -syn keyword racketFunc truncate numerator denominator rationalize +syn keyword racketFunc add1 sub1 abs max min gcd lcm round exact-round floor +syn keyword racketFunc ceiling truncate numerator denominator rationalize " 3.2.2.2 Number Comparison syn keyword racketFunc = < <= > >= @@ -374,6 +386,19 @@ syn keyword racketFunc class-field-accessor class-field-mutator "5.4.3 Generics syn keyword racketFunc generic send-generic make-generic +" 8.1 Data-strucure contracts +syn keyword racketFunc flat-contract-with-explanation flat-named-contract +" TODO where do any/c and none/c `value`s go? +syn keyword racketFunc or/c first-or/c and/c not/c =/c /c <=/c >=/c +syn keyword racketFunc between/c real-in integer-in char-in natural-number/c +syn keyword racketFunc string-len/c printable/c one-of/c symbols vectorof +syn keyword racketFunc vector-immutableof vector/c box/c box-immutable/c listof +syn keyword racketFunc non-empty-listof list*of cons/c cons/dc list/c *list/c +syn keyword racketFunc syntax/c struct/c struct/dc parameter/c +syn keyword racketFunc procedure-arity-includes/c hash/c hash/dc channel/c +syn keyword racketFunc prompt-tag/c continuation-mark-key/c evt/c promise/c +syn keyword racketFunc flat-contract flat-contract-predicate suggest/c + " 9.1 Multiple Values syn keyword racketFunc values call-with-values @@ -420,6 +445,11 @@ syn keyword racketFunc continuation? continuation-prompt-tag dynamic-wind " 10.4.1 Additional Control Operators syn keyword racketFunc call/prompt abort/cc call/comp abort fcontrol spawn splitter new-prompt +" 11.3.2 Parameters +syn keyword racketFunc make-parameter make-derived-parameter parameter? +syn keyword racketFunc parameter-procedure=? current-parameterization +syn keyword racketFunc call-with-parameterization parameterization? + " 14.1.1 Manipulating Paths syn keyword racketFunc path? path-string? path-for-some-system? string->path path->string path->bytes syn keyword racketFunc string->path-element bytes->path-element path-element->string path-element->bytes @@ -434,6 +464,9 @@ syn keyword racketFunc path-replace-suffix path-add-suffix syn keyword racketFunc explode-path file-name-from-path filename-extension find-relative-path normalize-path syn keyword racketFunc path-element? path-only simple-form-path some-simple-path->string string->some-system-path +" 15.6 Time +syn keyword racketFunc current-seconds current-inexact-milliseconds +syn keyword racketFunc seconds->date current-milliseconds syn match racketDelimiter !\<\.\>! diff --git a/syntax/rst.vim b/syntax/rst.vim index 9df2283..7d88963 100644 --- a/syntax/rst.vim +++ b/syntax/rst.vim @@ -5,7 +5,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rst') == -1 " Maintainer: Marshall Ward " Previous Maintainer: Nikolai Weibull " Website: https://github.com/marshallward/vim-restructuredtext -" Latest Revision: 2018-07-23 +" Latest Revision: 2018-12-29 if exists("b:current_syntax") finish @@ -23,7 +23,7 @@ syn cluster rstCruft contains=rstEmphasis,rstStrongEmphasis, \ rstInlineInternalTargets,rstFootnoteReference,rstHyperlinkReference syn region rstLiteralBlock matchgroup=rstDelimiter - \ start='::\_s*\n\ze\z(\s\+\)' skip='^$' end='^\z1\@!' + \ start='\(^\z(\s*\).*\)\@<=::\n\s*\n' skip='^\s*$' end='^\(\z1\s\+\)\@!' \ contains=@NoSpell syn region rstQuotedLiteralBlock matchgroup=rstDelimiter diff --git a/syntax/ruby.vim b/syntax/ruby.vim index 9f26998..28c341b 100644 --- a/syntax/ruby.vim +++ b/syntax/ruby.vim @@ -20,6 +20,11 @@ endif let s:cpo_sav = &cpo set cpo&vim +" eRuby Config {{{1 +if exists('main_syntax') && main_syntax == 'eruby' + let b:ruby_no_expensive = 1 +endif + " Folding Config {{{1 if has("folding") && exists("ruby_fold") setlocal foldmethod=syntax @@ -34,6 +39,10 @@ let s:foldable_groups = split( \ ) function! s:foldable(...) abort + if index(s:foldable_groups, 'NONE') > -1 + return 0 + endif + if index(s:foldable_groups, 'ALL') > -1 return 1 endif @@ -45,9 +54,21 @@ function! s:foldable(...) abort endfor return 0 -endfunction " }}} +endfunction -syn cluster rubyNotTop contains=@rubyExtendedStringSpecial,@rubyRegexpSpecial,@rubyDeclaration,rubyConditional,rubyExceptional,rubyMethodExceptional,rubyTodo,rubyModuleName,rubyClassName,rubySymbolDelimiter +function! s:run_syntax_fold(args) abort + let [_0, _1, groups, cmd; _] = matchlist(a:args, '\(["'']\)\(.\{-}\)\1\s\+\(.*\)') + if call('s:foldable', split(groups)) + let cmd .= ' fold' + endif + exe cmd +endfunction + +com! -nargs=* SynFold call s:run_syntax_fold() + +" }}} + +syn cluster rubyNotTop contains=@rubyCommentNotTop,@rubyStringNotTop,@rubyRegexpSpecial,@rubyDeclaration,@rubyExceptionHandler,rubyConditional,rubyModuleName,rubyClassName,rubySymbolDelimiter " Whitespace Errors {{{1 if exists("ruby_space_errors") @@ -61,373 +82,315 @@ endif " Operators {{{1 if exists("ruby_operators") - syn match rubyOperator "[~!^|*/%+-]\|&\.\@!\|\%(class\s*\)\@\|<=\|\%(<\|\>\|>=\|=\@1\|\*\*\|\.\.\.\|\.\.\|::" - syn match rubyOperator "->\|-=\|/=\|\*\*=\|\*=\|&&=\|&=\|&&\|||=\||=\|||\|%=\|+=\|!\~\|!=" - syn region rubyBracketOperator matchgroup=rubyOperator start="\%(\w[?!]\=\|[]})]\)\@2<=\[\s*" end="\s*]" contains=ALLBUT,@rubyNotTop + syn match rubyDotOperator "\.\|&\." containedin=rubyKeywordAsMethod + syn match rubyTernaryOperator "[[:alnum:]]\@1\@!" + syn match rubyComparisonOperator "<=>\|<=\|\%(<\|\=\|[-=]\@1" + syn match rubyBitwiseOperator "[~^|]\|&\.\@!\|\%(class\s*\)\@>" + syn match rubyBooleanOperator "[[:alnum:]]\@1\@!\|-=\|/=\|\*\*=\|\*=\|&&=\|&=\|||=\||=\|%=\|+=\|>>=\|<<=\|\^=" + syn match rubyEqualityOperator "===\|==\|!=\|!\~\|=\~" + syn match rubyScopeOperator "::" + syn region rubyBracketOperator matchgroup=rubyOperator start="\%(\w[?!]\=\|[]})]\)\@2<=\[\s*" end="\s*]" contains=ALLBUT,@rubyNotTop + + syn cluster rubyOperator contains=ruby.*Operator endif -" Expression Substitution and Backslash Notation {{{1 -syn match rubyStringEscape "\\\\\|\\[abefnrstv]\|\\\o\{1,3}\|\\x\x\{1,2}" contained display -syn match rubyStringEscape "\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)" contained display -syn match rubyQuoteEscape "\\[\\']" contained display - +" String Interpolation and Backslash Notation {{{1 syn region rubyInterpolation matchgroup=rubyInterpolationDelimiter start="#{" end="}" contained contains=ALLBUT,@rubyNotTop -syn match rubyInterpolation "#\%(\$\|@@\=\)\w\+" display contained contains=rubyInterpolationDelimiter,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable,rubyPredefinedVariable -syn match rubyInterpolationDelimiter "#\ze\%(\$\|@@\=\)\w\+" display contained -syn match rubyInterpolation "#\$\%(-\w\|\W\)" display contained contains=rubyInterpolationDelimiter,rubyPredefinedVariable,rubyInvalidVariable -syn match rubyInterpolationDelimiter "#\ze\$\%(-\w\|\W\)" display contained -syn region rubyNoInterpolation start="\\#{" end="}" contained -syn match rubyNoInterpolation "\\#{" display contained -syn match rubyNoInterpolation "\\#\%(\$\|@@\=\)\w\+" display contained -syn match rubyNoInterpolation "\\#\$\W" display contained +syn match rubyInterpolation "#\$\%(-\w\|[!$&"'*+,./0:;<>?@\`~_]\|\w\+\)" display contained contains=rubyInterpolationDelimiter,@rubyGlobalVariable +syn match rubyInterpolation "#@@\=\w\+" display contained contains=rubyInterpolationDelimiter,rubyInstanceVariable,rubyClassVariable +syn match rubyInterpolationDelimiter "#\ze[$@]" display contained -syn match rubyDelimiterEscape "\\[(<{\[)>}\]]" transparent display contained contains=NONE +syn match rubyStringEscape "\\\_." contained display +syn match rubyStringEscape "\\\o\{1,3}\|\\x\x\{1,2}" contained display +syn match rubyStringEscape "\\u\%(\x\{4}\|{\x\{1,6}\%(\s\+\x\{1,6}\)*}\)" contained display +syn match rubyStringEscape "\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)" contained display + +syn match rubyBackslashEscape "\\\\" contained display +syn match rubyQuoteEscape "\\'" contained display +syn match rubySpaceEscape "\\ " contained display + +syn match rubyParenthesesEscape "\\[()]" contained display +syn match rubyCurlyBracesEscape "\\[{}]" contained display +syn match rubyAngleBracketsEscape "\\[<>]" contained display +syn match rubySquareBracketsEscape "\\[[\]]" contained display syn region rubyNestedParentheses start="(" skip="\\\\\|\\)" matchgroup=rubyString end=")" transparent contained syn region rubyNestedCurlyBraces start="{" skip="\\\\\|\\}" matchgroup=rubyString end="}" transparent contained syn region rubyNestedAngleBrackets start="<" skip="\\\\\|\\>" matchgroup=rubyString end=">" transparent contained syn region rubyNestedSquareBrackets start="\[" skip="\\\\\|\\\]" matchgroup=rubyString end="\]" transparent contained +syn cluster rubySingleCharEscape contains=rubyBackslashEscape,rubyQuoteEscape,rubySpaceEscape,rubyParenthesesEscape,rubyCurlyBracesEscape,rubyAngleBracketsEscape,rubySquareBracketsEscape +syn cluster rubyNestedBrackets contains=rubyNested.\+ +syn cluster rubyStringSpecial contains=rubyInterpolation,rubyStringEscape +syn cluster rubyStringNotTop contains=@rubyStringSpecial,@rubyNestedBrackets,@rubySingleCharEscape + " Regular Expression Metacharacters {{{1 -" These are mostly Oniguruma ready -syn region rubyRegexpComment matchgroup=rubyRegexpSpecial start="(?#" skip="\\)" end=")" contained -syn region rubyRegexpParens matchgroup=rubyRegexpSpecial start="(\(?:\|?<\=[=!]\|?>\|?<[a-z_]\w*>\|?[imx]*-[imx]*:\=\|\%(?#\)\@!\)" skip="\\)" end=")" contained transparent contains=@rubyRegexpSpecial -syn region rubyRegexpBrackets matchgroup=rubyRegexpCharClass start="\[\^\=" skip="\\\]" end="\]" contained transparent contains=rubyStringEscape,rubyRegexpEscape,rubyRegexpCharClass oneline -syn match rubyRegexpCharClass "\\[DdHhSsWw]" contained display -syn match rubyRegexpCharClass "\[:\^\=\%(alnum\|alpha\|ascii\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|xdigit\):\]" contained -syn match rubyRegexpEscape "\\[].*?+^$|\\/(){}[]" contained -syn match rubyRegexpQuantifier "[*?+][?+]\=" contained display -syn match rubyRegexpQuantifier "{\d\+\%(,\d*\)\=}?\=" contained display -syn match rubyRegexpAnchor "[$^]\|\\[ABbGZz]" contained display -syn match rubyRegexpDot "\." contained display -syn match rubyRegexpSpecial "|" contained display -syn match rubyRegexpSpecial "\\[1-9]\d\=\d\@!" contained display -syn match rubyRegexpSpecial "\\k<\%([a-z_]\w*\|-\=\d\+\)\%([+-]\d\+\)\=>" contained display -syn match rubyRegexpSpecial "\\k'\%([a-z_]\w*\|-\=\d\+\)\%([+-]\d\+\)\='" contained display -syn match rubyRegexpSpecial "\\g<\%([a-z_]\w*\|-\=\d\+\)>" contained display -syn match rubyRegexpSpecial "\\g'\%([a-z_]\w*\|-\=\d\+\)'" contained display +syn region rubyRegexpComment matchgroup=rubyRegexpSpecial start="(?#" skip="\\\\\|\\)" end=")" contained +syn region rubyRegexpParens matchgroup=rubyRegexpSpecial start="(\(?:\|?<\=[=!]\|?>\|?<[a-z_]\w*>\|?[imx]*-[imx]*:\=\|\%(?#\)\@!\)" skip="\\\\\|\\)" end=")" contained transparent contains=@rubyRegexpSpecial +syn region rubyRegexpBrackets matchgroup=rubyRegexpCharClass start="\[\^\=" skip="\\\\\|\\\]" end="\]" contained transparent contains=rubyRegexpBrackets,rubyStringEscape,rubyRegexpEscape,rubyRegexpCharClass,rubyRegexpIntersection oneline +syn match rubyRegexpCharClass "\\[DdHhRSsWw]" contained display +syn match rubyRegexpCharClass "\[:\^\=\%(alnum\|alpha\|ascii\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|word\|xdigit\):\]" contained +syn match rubyRegexpCharClass "\\[pP]{^\=.\{-}}" contained display +syn match rubyRegexpEscape "\\[].*?+^$|\\/(){}[]" contained " see commit e477f10 +syn match rubyRegexpQuantifier "[*?+][?+]\=" contained display +syn match rubyRegexpQuantifier "{\d\+\%(,\d*\)\=}?\=" contained display +syn match rubyRegexpAnchor "[$^]\|\\[ABbGZz]" contained display +syn match rubyRegexpDot "\.\|\\X" contained display +syn match rubyRegexpIntersection "&&" contained display +syn match rubyRegexpSpecial "\\K" contained display +syn match rubyRegexpSpecial "|" contained display +syn match rubyRegexpSpecial "\\[1-9]\d\=\d\@!" contained display +syn match rubyRegexpSpecial "\\k<\%([a-z_]\w*\|-\=\d\+\)\%([+-]\d\+\)\=>" contained display +syn match rubyRegexpSpecial "\\k'\%([a-z_]\w*\|-\=\d\+\)\%([+-]\d\+\)\='" contained display +syn match rubyRegexpSpecial "\\g<\%([a-z_]\w*\|-\=\d\+\)>" contained display +syn match rubyRegexpSpecial "\\g'\%([a-z_]\w*\|-\=\d\+\)'" contained display -syn cluster rubyStringSpecial contains=rubyInterpolation,rubyNoInterpolation,rubyStringEscape -syn cluster rubyExtendedStringSpecial contains=@rubyStringSpecial,rubyNestedParentheses,rubyNestedCurlyBraces,rubyNestedAngleBrackets,rubyNestedSquareBrackets -syn cluster rubyRegexpSpecial contains=rubyInterpolation,rubyNoInterpolation,rubyStringEscape,rubyRegexpSpecial,rubyRegexpEscape,rubyRegexpBrackets,rubyRegexpCharClass,rubyRegexpDot,rubyRegexpQuantifier,rubyRegexpAnchor,rubyRegexpParens,rubyRegexpComment +syn cluster rubyRegexpSpecial contains=@rubyStringSpecial,rubyRegexpSpecial,rubyRegexpEscape,rubyRegexpBrackets,rubyRegexpCharClass,rubyRegexpDot,rubyRegexpQuantifier,rubyRegexpAnchor,rubyRegexpParens,rubyRegexpComment,rubyRegexpIntersection -" Numbers and ASCII Codes {{{1 -syn match rubyASCIICode "\%(\w\|[]})\"'/]\)\@1" 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 +" Numbers {{{1 +syn match rubyInteger "\%(\%(\w\|[]})\"']\s*\)\@" 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 {{{1 -syn match rubyLocalVariableOrMethod "\<[_[:lower:]][_[:alnum:]]*[?!=]\=" contains=NONE display transparent +syn match rubyLocalVariableOrMethod "\<[_[:lower:]][_[:alnum:]]*[?!]\=" contains=NONE display transparent syn match rubyBlockArgument "&[_[:lower:]][_[:alnum:]]" contains=NONE display transparent -syn match rubyClassName "\%(\%(^\|[^.]\)\.\s*\)\@\%(\s*(\)\@!" contained -syn match rubyModuleName "\%(\%(^\|[^.]\)\.\s*\)\@\%(\s*(\)\@!" contained -syn match rubyConstant "\%(\%(^\|[^.]\)\.\s*\)\@\%(\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 rubySymbolDelimiter ":" contained -syn match rubySymbol "[]})\"':]\@1\|<=\|<\|===\|[=!]=\|[=!]\~\|!@\|!\|>>\|>=\|>\||\|-@\|-\|/\|\[]=\|\[]\|\*\*\|\*\|&\|%\|+@\|+\|`\)" contains=rubySymbolDelimiter -syn match rubySymbol "[]})\"':]\@1_,;:!?/.'"@$*\&+0]\)" contains=rubySymbolDelimiter -syn match rubySymbol "[]})\"':]\@1\@!\)\=" contains=rubySymbolDelimiter +syn match rubyClassName "\%(\%(^\|[^.]\)\.\s*\)\@\%(\s*(\)\@!" contained +syn match rubyModuleName "\%(\%(^\|[^.]\)\.\s*\)\@\%(\s*(\)\@!" contained +syn match rubyConstant "\%(\%(^\|[^.]\)\.\s*\)\@\%(\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 rubySymbolDelimiter ":" contained +syn match rubySymbol "[]})\"':]\@1\|<=\|<\|===\|[=!]=\|[=!]\~\|!@\|!\|>>\|>=\|>\||\|-@\|-\|/\|\[]=\|\[]\|\*\*\|\*\|&\|%\|+@\|+\|`\)" contains=rubySymbolDelimiter +syn match rubySymbol "[]})\"':]\@1_,;:!?/.'"@$*\&+0]\)" contains=rubySymbolDelimiter +syn match rubySymbol "[]})\"':]\@1\@!\)\=" contains=rubySymbolDelimiter -if s:foldable(':') - syn region rubySymbol matchgroup=rubySymbolDelimiter start="[]})\"':]\@1\%(\s*(\)*\s*(\@=" +syn match rubyCapitalizedMethod "\%(\%(^\|[^.]\)\.\s*\)\@\%(\s*(\)\@=" syn match rubyBlockParameter "\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" contained syn region rubyBlockParameterList start="\%(\%(\\|{\)\_s*\)\@32<=|" end="|" oneline display contains=rubyBlockParameter -syn match rubyInvalidVariable "$[^ A-Za-z_-]" -syn match rubyPredefinedVariable #$[!$&"'*+,./0:;<=>?@\`~]# -syn match rubyPredefinedVariable "$\d\+" display -syn match rubyPredefinedVariable "$_\>" display -syn match rubyPredefinedVariable "$-[0FIKadilpvw]\>" display -syn match rubyPredefinedVariable "$\%(deferr\|defout\|stderr\|stdin\|stdout\)\>" display -syn match rubyPredefinedVariable "$\%(DEBUG\|FILENAME\|KCODE\|LOADED_FEATURES\|LOAD_PATH\|PROGRAM_NAME\|SAFE\|VERBOSE\)\>" display +if exists('ruby_global_variable_error') + syn match rubyGlobalVariableError "$[^A-Za-z_]" display + syn match rubyGlobalVariableError "$-[^0FIKWadilpvw]" display +endif + +syn match rubyPredefinedVariable #$[!$&"'*+,./0:;<>?@\`~]# +syn match rubyPredefinedVariable "$\d\+" display +syn match rubyPredefinedVariable "$_\>" display +syn match rubyPredefinedVariable "$-[0FIWadilpvw]\>" display +syn match rubyPredefinedVariable "$\%(stderr\|stdin\|stdout\)\>" display +syn match rubyPredefinedVariable "$\%(DEBUG\|FILENAME\|LOADED_FEATURES\|LOAD_PATH\|PROGRAM_NAME\|SAFE\|VERBOSE\)\>" display syn match rubyPredefinedConstant "\%(\%(^\|[^.]\)\.\s*\)\@\%(\s*(\)\@!" syn match rubyPredefinedConstant "\%(\%(^\|[^.]\)\.\s*\)\@\%(\s*(\)\@!" -" Normal Regular Expression {{{1 -if s:foldable('/') - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|when\|not\|then\|else\)\|[;\~=!|&(,{[<>?:*+-]\)\s*\)\@<=/" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial fold - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\h\k*\s\+\)\@<=/\%([ \t=]\|$\)\@!" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial fold -else - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|when\|not\|then\|else\)\|[;\~=!|&(,{[<>?:*+-]\)\s*\)\@<=/" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\h\k*\s\+\)\@<=/\%([ \t=]\|$\)\@!" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial -endif +" Deprecated/removed in 1.9 +syn match rubyPredefinedVariable "$=" +syn match rubyPredefinedVariable "$-K\>" display +syn match rubyPredefinedVariable "$\%(deferr\|defout\)\>" display +syn match rubyPredefinedVariable "$KCODE\>" display -" Generalized Regular Expression {{{1 -if s:foldable('%') - 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,rubyDelimiterEscape 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 -else - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r{" end="}[iomxneus]*" skip="\\\\\|\\}" contains=@rubyRegexpSpecial - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r<" end=">[iomxneus]*" skip="\\\\\|\\>" contains=@rubyRegexpSpecial,rubyNestedAngleBrackets,rubyDelimiterEscape - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\[" end="\][iomxneus]*" skip="\\\\\|\\\]" contains=@rubyRegexpSpecial - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r(" end=")[iomxneus]*" skip="\\\\\|\\)" contains=@rubyRegexpSpecial - syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z(\s\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial -endif +syn cluster rubyGlobalVariable contains=rubyGlobalVariable,rubyPredefinedVariable,rubyGlobalVariableError -" Normal String {{{1 +" Normal Regular Expressions {{{1 +SynFold '/' syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|when\|not\|then\|else\)\|[;\~=!|&(,{[<>?:*+-]\)\s*\)\@<=/" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial nextgroup=@rubyModifier skipwhite +SynFold '/' syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\h\k*\s\+\)\@<=/\%([ \t=]\|$\)\@!" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial nextgroup=@rubyModifier skipwhite + +" Generalized Regular Expressions {{{1 +SynFold '%' syn region rubyRegexp matchgroup=rubyPercentRegexpDelimiter start="%r\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial nextgroup=@rubyModifier skipwhite +SynFold '%' syn region rubyRegexp matchgroup=rubyPercentRegexpDelimiter start="%r{" end="}[iomxneus]*" skip="\\\\\|\\}" contains=@rubyRegexpSpecial +SynFold '%' syn region rubyRegexp matchgroup=rubyPercentRegexpDelimiter start="%r<" end=">[iomxneus]*" skip="\\\\\|\\>" contains=@rubyRegexpSpecial,rubyNestedAngleBrackets +SynFold '%' syn region rubyRegexp matchgroup=rubyPercentRegexpDelimiter start="%r\[" end="\][iomxneus]*" skip="\\\\\|\\\]" contains=@rubyRegexpSpecial +SynFold '%' syn region rubyRegexp matchgroup=rubyPercentRegexpDelimiter start="%r(" end=")[iomxneus]*" skip="\\\\\|\\)" contains=@rubyRegexpSpecial +SynFold '%' syn region rubyRegexp matchgroup=rubyPercentRegexpDelimiter start="%r\z(\s\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial + +" Characters {{{1 +syn match rubyCharacter "\%(\w\|[]})\"'/]\)\@1" skip="\\\\\|\\>" fold contains=rubyNestedAngleBrackets,rubyDelimiterEscape - syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\[" end="\]" skip="\\\\\|\\\]" fold contains=rubyNestedSquareBrackets,rubyDelimiterEscape - syn region rubyString matchgroup=rubyStringDelimiter start="%[qw](" end=")" skip="\\\\\|\\)" fold contains=rubyNestedParentheses,rubyDelimiterEscape - 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,rubyDelimiterEscape - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s<" end=">" skip="\\\\\|\\>" fold contains=rubyNestedAngleBrackets,rubyDelimiterEscape - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s\[" end="\]" skip="\\\\\|\\\]" fold contains=rubyNestedSquareBrackets,rubyDelimiterEscape - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s(" end=")" skip="\\\\\|\\)" fold contains=rubyNestedParentheses,rubyDelimiterEscape - syn region rubyString matchgroup=rubyStringDelimiter start="%s\z(\s\)" end="\z1" skip="\\\\\|\\\z1" fold -else - syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" - syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]{" end="}" skip="\\\\\|\\}" contains=rubyNestedCurlyBraces,rubyDelimiterEscape - syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]<" end=">" skip="\\\\\|\\>" contains=rubyNestedAngleBrackets,rubyDelimiterEscape - syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\[" end="\]" skip="\\\\\|\\\]" contains=rubyNestedSquareBrackets,rubyDelimiterEscape - syn region rubyString matchgroup=rubyStringDelimiter start="%[qw](" end=")" skip="\\\\\|\\)" contains=rubyNestedParentheses,rubyDelimiterEscape - syn region rubyString matchgroup=rubyStringDelimiter start="%q\z(\s\)" end="\z1" skip="\\\\\|\\\z1" - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s{" end="}" skip="\\\\\|\\}" contains=rubyNestedCurlyBraces,rubyDelimiterEscape - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s<" end=">" skip="\\\\\|\\>" contains=rubyNestedAngleBrackets,rubyDelimiterEscape - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s\[" end="\]" skip="\\\\\|\\\]" contains=rubyNestedSquareBrackets,rubyDelimiterEscape - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s(" end=")" skip="\\\\\|\\)" contains=rubyNestedParentheses,rubyDelimiterEscape - syn region rubyString matchgroup=rubyStringDelimiter start="%s\z(\s\)" end="\z1" skip="\\\\\|\\\z1" -endif +" Generalized Single Quoted Strings, Symbols, Array of Strings and Array of Symbols {{{1 -" Generalized Double Quoted String and Array of Strings and Shell Command Output {{{1 +" Non-bracket punctuation delimiters {{{2 +let s:names = { '~': 'Tilde', '`': 'BackQuote', '!': 'Bang', '@': 'At', '#': 'Hash', '$': 'Dollar', '%': 'Percent', '^': 'Caret', + \ '&': 'Ampersand', '*': 'Asterix', '_': 'Underscore', '-': 'Dash', '+': 'Plus', '=': 'Equals', '|': 'Bar', + \ '\': 'Backslash', ':': 'Colon', ';': 'Semicolon', '"': 'DoubleQuote', "'": 'Quote', ',': 'Comma', '.': 'Period', + \ '?': 'QuestionMark', '/': 'ForwardSlash' } + +for s:delimiter in keys(s:names) + let s:group = 'ruby' . s:names[s:delimiter] . 'Escape' + + if s:delimiter =~ '[\"]' + let s:delimiter = '\' . s:delimiter + endif + + exe 'syn match ' . s:group . ' "\V\\' . s:delimiter . '" contained display' + exe 'syn cluster rubySingleCharEscape add=' . s:group + exe 'SynFold ''%'' syn region rubyString matchgroup=rubyPercentStringDelimiter start="\V%q' . s:delimiter . '" end="\V' . s:delimiter . '" skip="\V\\\\\|\\' . s:delimiter . '" contains=rubyBackslashEscape,' . s:group . ' nextgroup=@rubyModifier skipwhite' + exe 'SynFold ''%'' syn region rubyString matchgroup=rubyPercentStringDelimiter start="\V%w' . s:delimiter . '" end="\V' . s:delimiter . '" skip="\V\\\\\|\\' . s:delimiter . '" contains=rubyBackslashEscape,rubySpaceEscape,' . s:group . ' nextgroup=@rubyModifier skipwhite' + exe 'SynFold ''%'' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="\V%s' . s:delimiter . '" end="\V' . s:delimiter . '" skip="\V\\\\\|\\' . s:delimiter . '" contains=rubyBackslashEscape,' . s:group . ' nextgroup=@rubyModifier skipwhite' + exe 'SynFold ''%'' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="\V%i' . s:delimiter . '" end="\V' . s:delimiter . '" skip="\V\\\\\|\\' . s:delimiter . '" contains=rubyBackslashEscape,rubySpaceEscape,' . s:group . ' nextgroup=@rubyModifier skipwhite' + exe 'hi def link ' . s:group . ' rubyStringEscape' +endfor + +unlet s:delimiter s:group s:names +" }}}2 + +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%q{" end="}" skip="\\\\\|\\}" contains=rubyBackslashEscape,rubyCurlyBracesEscape,rubyNestedCurlyBraces +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%q<" end=">" skip="\\\\\|\\>" contains=rubyBackslashEscape,rubyAngleBracketsEscape,rubyNestedAngleBrackets +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%q\[" end="\]" skip="\\\\\|\\\]" contains=rubyBackslashEscape,rubySquareBracketsEscape,rubyNestedSquareBrackets +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%q(" end=")" skip="\\\\\|\\)" contains=rubyBackslashEscape,rubyParenthesesEscape,rubyNestedParentheses +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%q\z(\s\)" end="\z1" skip="\\\\\|\\\z1" contains=rubyBackslashEscape,rubySpaceEscape + +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%w{" end="}" skip="\\\\\|\\}" contains=rubyBackslashEscape,rubySpaceEscape,rubyCurlyBracesEscape,rubyNestedCurlyBraces +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%w<" end=">" skip="\\\\\|\\>" contains=rubyBackslashEscape,rubySpaceEscape,rubyAngleBracketsEscape,rubyNestedAngleBrackets +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%w\[" end="\]" skip="\\\\\|\\\]" contains=rubyBackslashEscape,rubySpaceEscape,rubySquareBracketsEscape,rubyNestedSquareBrackets +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%w(" end=")" skip="\\\\\|\\)" contains=rubyBackslashEscape,rubySpaceEscape,rubyParenthesesEscape,rubyNestedParentheses + +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%s{" end="}" skip="\\\\\|\\}" contains=rubyBackslashEscape,rubyCurlyBracesEscape,rubyNestedCurlyBraces +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%s<" end=">" skip="\\\\\|\\>" contains=rubyBackslashEscape,rubyAngleBracketsEscape,rubyNestedAngleBrackets +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%s\[" end="\]" skip="\\\\\|\\\]" contains=rubyBackslashEscape,rubySquareBracketsEscape,rubyNestedSquareBrackets +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%s(" end=")" skip="\\\\\|\\)" contains=rubyBackslashEscape,rubyParenthesesEscape,rubyNestedParentheses +SynFold '%' syn region rubyString matchgroup=rubyPercentSymbolDelimiter start="%s\z(\s\)" end="\z1" skip="\\\\\|\\\z1" contains=rubyBackslashEscape,rubySpaceEscape + +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%i{" end="}" skip="\\\\\|\\}" contains=rubyBackslashEscape,rubySpaceEscape,rubyCurlyBracesEscape,rubyNestedCurlyBraces +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%i<" end=">" skip="\\\\\|\\>" contains=rubyBackslashEscape,rubySpaceEscape,rubyAngleBracketsEscape,rubyNestedAngleBrackets +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%i\[" end="\]" skip="\\\\\|\\\]" contains=rubyBackslashEscape,rubySpaceEscape,rubySquareBracketsEscape,rubyNestedSquareBrackets +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%i(" end=")" skip="\\\\\|\\)" contains=rubyBackslashEscape,rubySpaceEscape,rubyParenthesesEscape,rubyNestedParentheses + +" Generalized Double Quoted Strings, Symbols, Array of Strings, Array of Symbols and Shell Command Output {{{1 " Note: %= is not matched here as the beginning of a double quoted string -if s:foldable('%') - syn region rubyString matchgroup=rubyStringDelimiter start="%\z([~`!@#$%^&*_\-+|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold - syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold - syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\={" end="}" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimiterEscape fold - syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=<" end=">" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimiterEscape fold - syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimiterEscape fold - syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimiterEscape fold - syn region rubyString matchgroup=rubyStringDelimiter start="%[Qx]\z(\s\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold -else - syn region rubyString matchgroup=rubyStringDelimiter start="%\z([~`!@#$%^&*_\-+|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial - syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial - syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\={" end="}" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimiterEscape - syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=<" end=">" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimiterEscape - syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimiterEscape - syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimiterEscape - syn region rubyString matchgroup=rubyStringDelimiter start="%[Qx]\z(\s\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial -endif +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%\z([~`!@#$%^&*_\-+|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial nextgroup=@rubyModifier skipwhite +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%[QWx]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%[QWx]\={" end="}" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%[QWx]\=<" end=">" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%[QWx]\=\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%[QWx]\=(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses +SynFold '%' syn region rubyString matchgroup=rubyPercentStringDelimiter start="%[Qx]\z(\s\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial -" Array of Symbols {{{1 -if s:foldable('%') - " Array of Symbols - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i{" end="}" skip="\\\\\|\\}" fold contains=rubyNestedCurlyBraces,rubyDelimiterEscape - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i<" end=">" skip="\\\\\|\\>" fold contains=rubyNestedAngleBrackets,rubyDelimiterEscape - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i\[" end="\]" skip="\\\\\|\\\]" fold contains=rubyNestedSquareBrackets,rubyDelimiterEscape - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i(" end=")" skip="\\\\\|\\)" fold contains=rubyNestedParentheses,rubyDelimiterEscape +" Array of interpolated Symbols +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%I\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial nextgroup=@rubyModifier skipwhite +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%I{" end="}" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%I<" end=">" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%I\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets +SynFold '%' syn region rubySymbol matchgroup=rubyPercentSymbolDelimiter start="%I(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses - " Array of interpolated Symbols - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I{" end="}" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimiterEscape fold - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I<" end=">" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimiterEscape fold - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimiterEscape fold - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimiterEscape fold -else - " Array of Symbols - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i{" end="}" skip="\\\\\|\\}" contains=rubyNestedCurlyBraces,rubyDelimiterEscape - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i<" end=">" skip="\\\\\|\\>" contains=rubyNestedAngleBrackets,rubyDelimiterEscape - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i\[" end="\]" skip="\\\\\|\\\]" contains=rubyNestedSquareBrackets,rubyDelimiterEscape - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i(" end=")" skip="\\\\\|\\)" contains=rubyNestedParentheses,rubyDelimiterEscape +" Here Documents {{{1 +syn region rubyHeredocStart matchgroup=rubyHeredocDelimiter start=+\%(\%(class\|::\|\.\@1" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimiterEscape - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimiterEscape - syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimiterEscape -endif +SynFold '<<' syn region rubyString start=+\%(\%(class\|::\|\.\@1>\|[<>]=\=\|<=>\|===\|[=!]=\|[=!]\~\|!\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration +syn match rubyAliasDeclaration "[^[:space:];#.()]\+" contained contains=rubySymbol,@rubyGlobalVariable nextgroup=rubyAliasDeclaration2 skipwhite +syn match rubyAliasDeclaration2 "[^[:space:];#.()]\+" contained contains=rubySymbol,@rubyGlobalVariable +syn match rubyMethodDeclaration "[^[:space:];#(]\+" contained contains=rubyConstant,rubyBoolean,rubyPseudoVariable,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable +syn match rubyClassDeclaration "[^[:space:];#<]\+" contained contains=rubyClassName,rubyOperator +syn match rubyModuleDeclaration "[^[:space:];#<]\+" contained contains=rubyModuleName,rubyOperator -syn cluster rubyDeclaration contains=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration,rubyModuleDeclaration,rubyClassDeclaration,rubyFunction,rubyBlockParameter +syn match rubyMethodName "\<[_[:alpha:]][_[:alnum:]]*[?!=]\=[[:alnum:]_.:?!=]\@!" contained containedin=rubyMethodDeclaration +syn match rubyMethodName "\%(\s\|^\)\@1<=[_[:alpha:]][_[:alnum:]]*[?!=]\=\%(\s\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2 +syn match rubyMethodName "\%([[:space:].]\|^\)\@1<=\%(\[\]=\=\|\*\*\|[-+!~]@\=\|[*/%|&^~]\|<<\|>>\|[<>]=\=\|<=>\|===\|[=!]=\|[=!]\~\|!\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration + +syn cluster rubyDeclaration contains=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration,rubyModuleDeclaration,rubyClassDeclaration,rubyMethodName,rubyBlockParameter " Keywords {{{1 " Note: the following keywords have already been defined: " begin case class def do end for if module unless until while -syn match rubyControl "\<\%(and\|break\|in\|next\|not\|or\|redo\|rescue\|retry\|return\)\>[?!]\@!" -syn match rubyOperator "\[?!]\@!" -syn match rubyBoolean "\<\%(true\|false\)\>[?!]\@!" -syn match rubyPseudoVariable "\<\%(nil\|self\|__ENCODING__\|__dir__\|__FILE__\|__LINE__\|__callee__\|__method__\)\>[?!]\@!" " TODO: reorganise -syn match rubyBeginEnd "\<\%(BEGIN\|END\)\>[?!]\@!" +syn match rubyControl "\<\%(and\|break\|in\|next\|not\|or\|redo\|retry\|return\)\>[?!]\@!" +syn match rubyOperator "\[?!]\@!" +syn match rubyBoolean "\<\%(true\|false\)\>[?!]\@!" +syn match rubyPseudoVariable "\<\%(nil\|self\|__ENCODING__\|__dir__\|__FILE__\|__LINE__\|__callee__\|__method__\)\>[?!]\@!" " TODO: reorganise +syn match rubyBeginEnd "\<\%(BEGIN\|END\)\>[?!]\@!" " Expensive Mode {{{1 " Match 'end' with the appropriate opening keyword for syntax based folding " and special highlighting of module/class/method definitions if !exists("b:ruby_no_expensive") && !exists("ruby_no_expensive") - syn match rubyDefine "\" nextgroup=rubyAliasDeclaration skipwhite skipnl - syn match rubyDefine "\" nextgroup=rubyMethodDeclaration skipwhite skipnl - syn match rubyDefine "\" nextgroup=rubyFunction skipwhite skipnl - syn match rubyClass "\" nextgroup=rubyClassDeclaration skipwhite skipnl - syn match rubyModule "\" nextgroup=rubyModuleDeclaration skipwhite skipnl + syn match rubyDefine "\" nextgroup=rubyAliasDeclaration skipwhite skipnl + syn match rubyDefine "\" nextgroup=rubyMethodDeclaration skipwhite skipnl + syn match rubyDefine "\" nextgroup=rubyMethodName skipwhite skipnl + syn match rubyClass "\" nextgroup=rubyClassDeclaration skipwhite skipnl + syn match rubyModule "\" nextgroup=rubyModuleDeclaration skipwhite skipnl - if s:foldable('def') - syn region rubyMethodBlock start="\" matchgroup=rubyDefine end="\%(\" contains=ALLBUT,@rubyNotTop fold - else - syn region rubyMethodBlock start="\" matchgroup=rubyDefine end="\%(\" contains=ALLBUT,@rubyNotTop - endif - - if s:foldable('class') - syn region rubyBlock start="\" matchgroup=rubyClass end="\" contains=ALLBUT,@rubyNotTop fold - else - syn region rubyBlock start="\" matchgroup=rubyClass end="\" contains=ALLBUT,@rubyNotTop - endif - - if s:foldable('module') - syn region rubyBlock start="\" matchgroup=rubyModule end="\" contains=ALLBUT,@rubyNotTop fold - else - syn region rubyBlock start="\" matchgroup=rubyModule end="\" contains=ALLBUT,@rubyNotTop - endif + SynFold 'def' syn region rubyMethodBlock start="\" matchgroup=rubyDefine end="\%(\" contains=ALLBUT,@rubyNotTop + SynFold 'class' syn region rubyClassBlock start="\" matchgroup=rubyClass end="\" contains=ALLBUT,@rubyNotTop + SynFold 'module' syn region rubyModuleBlock start="\" matchgroup=rubyModule end="\" contains=ALLBUT,@rubyNotTop " modifiers - syn match rubyLineContinuation "\\$" nextgroup=rubyConditionalModifier,rubyRepeatModifier skipwhite skipnl + syn match rubyLineContinuation "\\$" nextgroup=@rubyModifier skipwhite skipnl syn match rubyConditionalModifier "\<\%(if\|unless\)\>" syn match rubyRepeatModifier "\<\%(while\|until\)\>" + syn match rubyRescueModifier "\" - if s:foldable('do') - syn region rubyDoBlock matchgroup=rubyControl start="\" end="\" contains=ALLBUT,@rubyNotTop fold - else - syn region rubyDoBlock matchgroup=rubyControl start="\" end="\" contains=ALLBUT,@rubyNotTop - endif + syn cluster rubyModifier contains=rubyConditionalModifier,rubyRepeatModifier,rubyRescueModifier + + SynFold 'do' syn region rubyDoBlock matchgroup=rubyControl start="\" end="\" contains=ALLBUT,@rubyNotTop " curly bracket block or hash literal - if s:foldable('{') - syn region rubyCurlyBlock matchgroup=rubyCurlyBlockDelimiter start="{" end="}" contains=ALLBUT,@rubyNotTop fold - else - syn region rubyCurlyBlock matchgroup=rubyCurlyBlockDelimiter start="{" end="}" contains=ALLBUT,@rubyNotTop - endif - - if s:foldable('[') - syn region rubyArrayLiteral matchgroup=rubyArrayDelimiter start="\%(\w\|[\]})]\)\@" end="\" contains=ALLBUT,@rubyNotTop fold - else - syn region rubyBlockExpression matchgroup=rubyControl start="\" end="\" contains=ALLBUT,@rubyNotTop - endif + SynFold 'begin' syn region rubyBlockExpression matchgroup=rubyControl start="\" end="\" contains=ALLBUT,@rubyNotTop + SynFold 'case' syn region rubyCaseExpression matchgroup=rubyConditional start="\" end="\" contains=ALLBUT,@rubyNotTop - if s:foldable('case') - syn region rubyCaseExpression matchgroup=rubyConditional start="\" end="\" contains=ALLBUT,@rubyNotTop fold - else - syn region rubyCaseExpression matchgroup=rubyConditional start="\" end="\" contains=ALLBUT,@rubyNotTop - endif - - if s:foldable('if') - syn region rubyConditionalExpression matchgroup=rubyConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*%&^|+=-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@" end="\%(\%(\%(\.\@1" contains=ALLBUT,@rubyNotTop fold - else - syn region rubyConditionalExpression matchgroup=rubyConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*%&^|+=-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@" end="\%(\%(\%(\.\@1" contains=ALLBUT,@rubyNotTop - endif + SynFold 'if' syn region rubyConditionalExpression matchgroup=rubyConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\" end="\%(\%(\%(\.\@1" contains=ALLBUT,@rubyNotTop syn match rubyConditional "\<\%(then\|else\|when\)\>[?!]\@!" contained containedin=rubyCaseExpression syn match rubyConditional "\<\%(then\|else\|elsif\)\>[?!]\@!" contained containedin=rubyConditionalExpression - syn match rubyExceptional "\<\%(\%(\%(;\|^\)\s*\)\@<=rescue\|else\|ensure\)\>[?!]\@!" contained containedin=rubyBlockExpression - syn match rubyMethodExceptional "\<\%(\%(\%(;\|^\)\s*\)\@<=rescue\|else\|ensure\)\>[?!]\@!" contained containedin=rubyMethodBlock + syn match rubyExceptionHandler "\<\%(\%(\%(;\|^\)\s*\)\@<=rescue\|else\|ensure\)\>[?!]\@!" contained containedin=rubyBlockExpression,rubyDoBlock + syn match rubyExceptionHandler1 "\<\%(\%(\%(;\|^\)\s*\)\@<=rescue\|else\|ensure\)\>[?!]\@!" contained containedin=rubyModuleBlock,rubyClassBlock,rubyMethodBlock + syn cluster rubyExceptionHandler contains=rubyExceptionHandler,rubyExceptionHandler1 " statements with optional 'do' - syn region rubyOptionalDoLine matchgroup=rubyRepeat start="\[?!]\@!" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@" matchgroup=rubyOptionalDo end="\%(\\)" end="\ze\%(;\|$\)" oneline contains=ALLBUT,@rubyNotTop + syn region rubyOptionalDoLine matchgroup=rubyRepeat start="\[?!]\@!" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\%(\<\h\w*\)\@" matchgroup=rubyOptionalDo end="\" end="\ze\%(;\|$\)" oneline contains=ALLBUT,@rubyNotTop - if s:foldable('for') - syn region rubyRepeatExpression start="\[?!]\@!" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@" matchgroup=rubyRepeat end="\" contains=ALLBUT,@rubyNotTop nextgroup=rubyOptionalDoLine fold - else - syn region rubyRepeatExpression start="\[?!]\@!" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@" matchgroup=rubyRepeat end="\" contains=ALLBUT,@rubyNotTop nextgroup=rubyOptionalDoLine - endif + SynFold 'for' syn region rubyRepeatExpression start="\[?!]\@!" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\%(\<\h\w*\)\@" matchgroup=rubyRepeat end="\" contains=ALLBUT,@rubyNotTop nextgroup=rubyOptionalDoLine if !exists("ruby_minlines") let ruby_minlines = 500 endif - exec "syn sync minlines=" . ruby_minlines + exe "syn sync minlines=" . ruby_minlines else syn match rubyControl "\[?!]\@!" nextgroup=rubyMethodDeclaration skipwhite skipnl syn match rubyControl "\[?!]\@!" nextgroup=rubyClassDeclaration skipwhite skipnl syn match rubyControl "\[?!]\@!" nextgroup=rubyModuleDeclaration skipwhite skipnl - syn match rubyControl "\<\%(case\|begin\|do\|for\|if\|unless\|while\|until\|else\|elsif\|ensure\|then\|when\|end\)\>[?!]\@!" + syn match rubyControl "\<\%(case\|begin\|do\|for\|if\|unless\|while\|until\|else\|elsif\|rescue\|ensure\|then\|when\|end\)\>[?!]\@!" syn match rubyKeyword "\<\%(alias\|undef\)\>[?!]\@!" endif @@ -449,53 +412,62 @@ if !exists("ruby_no_special_methods") endif " Comments and Documentation {{{1 -syn match rubySharpBang "\%^#!.*" display -syn keyword rubyTodo FIXME NOTE TODO OPTIMIZE HACK REVIEW XXX todo contained -syn match rubyComment "#.*" contains=rubySharpBang,rubySpaceError,rubyTodo,@Spell +syn match rubySharpBang "\%^#!.*" display +syn keyword rubyTodo FIXME NOTE TODO OPTIMIZE HACK REVIEW XXX todo contained +syn match rubyEncoding "[[:alnum:]-]\+" contained display +syn match rubyMagicComment "\c\%<3l#\s*\zs\%(coding\|encoding\):" contained nextgroup=rubyEncoding skipwhite +syn match rubyMagicComment "\c\%<10l#\s*\zs\%(frozen_string_literal\|warn_indent\|warn_past_scope\):" contained nextgroup=rubyBoolean skipwhite +syn match rubyComment "#.*" contains=@rubyCommentSpecial,rubySpaceError,@Spell + +syn cluster rubyCommentSpecial contains=rubySharpBang,rubyTodo,rubyMagicComment +syn cluster rubyCommentNotTop contains=@rubyCommentSpecial,rubyEncoding + if !exists("ruby_no_comment_fold") && s:foldable('#') syn region rubyMultilineComment start="^\s*#.*\n\%(^\s*#\)\@=" end="^\s*#.*\n\%(^\s*#\)\@!" contains=rubyComment transparent fold keepend - syn region rubyDocumentation start="^=begin\ze\%(\s.*\)\=$" end="^=end\%(\s.*\)\=$" contains=rubySpaceError,rubyTodo,@Spell fold + syn region rubyDocumentation start="^=begin\ze\%(\s.*\)\=$" end="^=end\%(\s.*\)\=$" contains=rubySpaceError,rubyTodo,@Spell fold else - syn region rubyDocumentation start="^=begin\s*$" end="^=end\s*$" contains=rubySpaceError,rubyTodo,@Spell + syn region rubyDocumentation start="^=begin\s*$" end="^=end\s*$" contains=rubySpaceError,rubyTodo,@Spell endif +" {{{1 Useless line continuations +syn match rubyUselessLineContinuation "\%([.:,;{([<>~\*%&^|+=-]\|\w\@1\)" transparent contains=NONE syn match rubyKeywordAsMethod "\(defined?\|exit!\)\@!\<[_[:lower:]][_[:alnum:]]*[?!]" transparent contains=NONE " More Symbols {{{1 -syn match rubySymbol "\%([{(,]\_s*\)\zs\l\w*[!?]\=::\@!"he=e-1 -syn match rubySymbol "[]})\"':]\@1 -" Last Change: December 19, 2018 +" Last Change: January 31, 2019 " Inspired By: Vim syntax file by Dr. Charles E. Campbell, Jr. if exists('b:current_syntax') @@ -132,11 +132,11 @@ syntax keyword vifmOption contained aproposprg autochpos caseoptions cdpath cd \ lsoptions lsview mediaprg milleroptions millerview mintimeoutlen number nu \ numberwidth nuw previewprg quickview relativenumber rnu rulerformat ruf \ runexec scrollbind scb scrolloff so sort sortgroups sortorder sortnumbers - \ shell sh shortmess shm showtabline stal sizefmt slowfs smartcase scs - \ statusline stl suggestoptions syncregs syscalls tabscope tabstop timefmt - \ timeoutlen title tm trash trashdir ts tuioptions to undolevels ul vicmd - \ viewcolumns vifminfo vimhelp vixcmd wildmenu wmnu wildstyle wordchars wrap - \ wrapscan ws + \ shell sh shellflagcmd shcf shortmess shm showtabline stal sizefmt slowfs + \ smartcase scs statusline stl suggestoptions syncregs syscalls tabscope + \ tabstop timefmt timeoutlen title tm trash trashdir ts tuioptions to + \ undolevels ul vicmd viewcolumns vifminfo vimhelp vixcmd wildmenu wmnu + \ wildstyle wordchars wrap wrapscan ws " Disabled boolean options syntax keyword vifmOption contained noautochpos nocf nochaselinks nodotfiles