diff options
| author | Adam Stankiewicz <sheerun@sher.pl> | 2019-11-12 21:56:06 +0100 | 
|---|---|---|
| committer | Adam Stankiewicz <sheerun@sher.pl> | 2019-11-12 21:56:06 +0100 | 
| commit | 0c79dd3e73e8e09b73d4a5d20bf470a3f6f715f2 (patch) | |
| tree | 5b5e45e53e9ecafa6c182c8ce7e0266e34388e4d | |
| parent | 4e95df7c7e12cb76e781f2dacf1c07f8984cce58 (diff) | |
| download | vim-polyglot-0c79dd3e73e8e09b73d4a5d20bf470a3f6f715f2.tar.gz vim-polyglot-0c79dd3e73e8e09b73d4a5d20bf470a3f6f715f2.zip | |
Update
Diffstat (limited to '')
| -rw-r--r-- | after/indent/javascript.vim | 2 | ||||
| -rw-r--r-- | after/syntax/javascript.vim | 21 | ||||
| -rw-r--r-- | after/syntax/jsx_pretty.vim | 109 | ||||
| -rw-r--r-- | autoload/go/config.vim | 28 | ||||
| -rw-r--r-- | autoload/jsx_pretty/indent.vim | 733 | ||||
| -rw-r--r-- | ftdetect/polyglot.vim | 9 | ||||
| -rw-r--r-- | ftplugin/ruby.vim | 10 | ||||
| -rw-r--r-- | syntax/basic/type.vim | 7 | ||||
| -rw-r--r-- | syntax/common.vim | 1 | ||||
| -rw-r--r-- | syntax/flow.vim | 6 | ||||
| -rw-r--r-- | syntax/go.vim | 15 | ||||
| -rw-r--r-- | syntax/javascript.vim | 4 | ||||
| -rw-r--r-- | syntax/meson.vim | 2 | ||||
| -rw-r--r-- | syntax/ocaml.vim | 13 | ||||
| -rw-r--r-- | syntax/opam.vim | 2 | ||||
| -rw-r--r-- | syntax/plantuml.vim | 18 | ||||
| -rw-r--r-- | syntax/terraform.vim | 38 | ||||
| -rw-r--r-- | syntax/zig.vim | 4 | 
18 files changed, 750 insertions, 272 deletions
| diff --git a/after/indent/javascript.vim b/after/indent/javascript.vim index ffbbc97a..73e01595 100644 --- a/after/indent/javascript.vim +++ b/after/indent/javascript.vim @@ -21,7 +21,7 @@ if exists('s:did_indent')  endif  setlocal indentexpr=GetJsxIndent() -setlocal indentkeys=0{,0},0),0],0\,,!^F,o,O,e,*<Return>,<>>,<<>,/ +setlocal indentkeys=0{,0},0),0],0\,,!^F,o,O,e,<>>,=*/  function! GetJsxIndent()    return jsx_pretty#indent#get(function('GetJavascriptIndent')) diff --git a/after/syntax/javascript.vim b/after/syntax/javascript.vim index ab027d41..1ebcf38c 100644 --- a/after/syntax/javascript.vim +++ b/after/syntax/javascript.vim @@ -22,34 +22,31 @@ if exists('s:current_syntax')    let b:current_syntax = s:current_syntax  endif -if hlexists("jsNoise")    " pangloss/vim-javascript +if hlexists("jsDebugger") || hlexists("jsNoise")    " yuezk/vim-js or pangloss/vim-javascript    syntax cluster jsExpression add=jsxRegion  elseif hlexists("javascriptOpSymbols")    " othree/yajs.vim    " refine the javascript line comment    syntax region javascriptLineComment start=+//+ end=/$/ contains=@Spell,javascriptCommentTodo extend keepend    syntax cluster javascriptValue add=jsxRegion    syntax cluster javascriptNoReserved add=jsxElement,jsxTag - -  " add support to arrow function which returns a tagged template string, e.g. -  " () => html`<div></div>` -  syntax cluster afterArrowFunc add=javascriptTagRef  else    " build-in javascript syntax    " refine the javascript line comment    syntax region javaScriptLineComment start=+//+ end=/$/ contains=@Spell,javascriptCommentTodo extend keepend + +  " refine the template string syntax +  syntax region javaScriptEmbed matchgroup=javaScriptEmbedBraces start=+\${+ end=+}+ contained contains=@javaScriptEmbededExpr +    " add a javaScriptBlock group for build-in syntax -  syntax region javaScriptBlockBuildIn -        \ contained +  syntax region javaScriptBlock          \ matchgroup=javaScriptBraces          \ start="{"          \ end="}" +        \ contained          \ extend -        \ contains=javaScriptBlockBuildIn,@javaScriptEmbededExpr,javaScript.* +        \ contains=javaScriptBlock,@javaScriptEmbededExpr,javaScript.*          \ fold -  syntax cluster javaScriptEmbededExpr add=jsxRegion -  " refine the template string syntax -  syntax region javaScriptStringT start=+`+ skip=+\\\\\|\\`+ end=+`+ contains=javaScriptSpecial,javaScriptEmbed,@htmlPreproc extend -  syntax region javaScriptEmbed matchgroup=javaScriptEmbedBraces start=+\${+ end=+}+ contained contains=@javaScriptEmbededExpr,javaScript.* +  syntax cluster javaScriptEmbededExpr add=jsxRegion,javaScript.*  endif  runtime syntax/jsx_pretty.vim diff --git a/after/syntax/jsx_pretty.vim b/after/syntax/jsx_pretty.vim index 3c13b41f..1f1c2567 100644 --- a/after/syntax/jsx_pretty.vim +++ b/after/syntax/jsx_pretty.vim @@ -2,6 +2,12 @@ if !exists('g:polyglot_disabled') || !(index(g:polyglot_disabled, 'typescript')  let s:highlight_close_tag = get(g:, 'vim_jsx_pretty_highlight_close_tag', 0) +" detect jsx region +syntax region jsxRegion +      \ start=+\%(\%(\_[([,?:=+\-*/>{}]\|<\s\+\|&&\|||\|=>\|\<return\|\<default\|\<await\|\<yield\)\_s*\)\@<=<\_s*\%(>\|\z(\%(script\|T\s*>\s*(\)\@!\<[_$A-Za-z][-:._$A-Za-z0-9]*\>\)\%(\_s*\%([-+*)\]}&|?,]\|/\%([/*]\|\_s*>\)\@!\)\)\@!\)+ +      \ end=++ +      \ contains=jsxElement +  " <tag id="sample">  " ~~~~~~~~~~~~~~~~~  " and self close tag @@ -12,11 +18,14 @@ syntax region jsxTag        \ matchgroup=jsxOpenPunct        \ end=+>+        \ matchgroup=NONE -      \ end=+\(/\_s*>\)\@=+ +      \ end=+\%(/\_s*>\)\@=+        \ contained -      \ contains=jsxOpenTag,jsxEscapeJs,jsxAttrib,jsComment,@javascriptComments,javaScriptLineComment,javaScriptComment,typescriptLineComment,typescriptComment,jsxSpreadOperator +      \ contains=jsxOpenTag,jsxAttrib,jsxEscapeJs,jsxSpreadOperator,jsComment,@javascriptComments,javaScriptLineComment,javaScriptComment,typescriptLineComment,typescriptComment        \ keepend        \ extend +      \ skipwhite +      \ skipempty +      \ nextgroup=jsxCloseString  " <tag></tag>  " ~~~~~~~~~~~ @@ -27,30 +36,15 @@ syntax region jsxTag  " <tag />  " ~~~~~~~  syntax region jsxElement -      \ start=+<\_s*\(>\|\${\|\z(\<[-:_\.\$0-9A-Za-z]\+\>\)\)+ +      \ start=+<\_s*\%(>\|\${\|\z(\<[-:._$A-Za-z0-9]\+\>\)\)+        \ end=+/\_s*>+        \ end=+<\_s*/\_s*\z1\_s*>+ -      \ contains=jsxElement,jsxEscapeJs,jsxTag,jsxComment,jsxCloseString,jsxCloseTag,@Spell +      \ contains=jsxElement,jsxTag,jsxEscapeJs,jsxComment,jsxCloseTag,@Spell        \ keepend        \ extend        \ contained        \ fold -" detect jsx region -syntax region jsxRegion -      \ start=+\(\(\_[([,?:=+\-*/>{}]\|<\s\+\|&&\|||\|=>\|\<return\|\<default\|\<await\|\<yield\)\_s*\)\@<=<\_s*\(>\|\z(\(script\|T\s*>\s*(\)\@!\<[_\$A-Za-z][-:_\.\$0-9A-Za-z]*\>\)\(\_s*\([-+*)\]}&|?,]\|/\([/*]\|\_s*>\)\@!\)\)\@!\)+ -      \ end=++ -      \ contains=jsxElement - -" <tag key={this.props.key}> -"          ~~~~~~~~~~~~~~~~ -syntax region jsxEscapeJs -      \ start=+{+ -      \ end=++ -      \ extend -      \ contained -      \ contains=jsBlock,javascriptBlock,javaScriptBlockBuildIn,typescriptBlock -  " <tag key={this.props.key}>  " ~~~~  " and fragment start tag @@ -66,19 +60,31 @@ exe 'syntax region jsxOpenTag        \ contains=jsxTagName        \ nextgroup=jsxAttrib        \ skipwhite -      \ skipempty ' .(s:highlight_close_tag ? 'transparent' : '') +      \ skipempty +      \ ' .(s:highlight_close_tag ? 'transparent' : '') + + +" <tag key={this.props.key}> +"          ~~~~~~~~~~~~~~~~ +syntax region jsxEscapeJs +      \ matchgroup=jsxBraces +      \ start=+{+ +      \ end=+}+ +      \ contained +      \ extend +      \ contains=@jsExpression,jsSpreadExpression,@javascriptExpression,javascriptSpreadOp,@javaScriptEmbededExpr,@typescriptExpression,typescriptObjectSpread  " <foo.bar>  "     ~ -syntax match jsxDot +\.+ contained display +syntax match jsxDot +\.+ contained  " <foo:bar>  "     ~ -syntax match jsxNamespace +:+ contained display +syntax match jsxNamespace +:+ contained  " <tag id="sample">  "        ~ -syntax match jsxEqual +=+ contained display nextgroup=jsxString,jsxEscapeJs,jsxRegion skipwhite +syntax match jsxEqual +=+ contained skipwhite skipempty nextgroup=jsxString,jsxEscapeJs,jsxRegion  " <tag />  "      ~~ @@ -99,13 +105,12 @@ syntax region jsxCloseTag  " <tag key={this.props.key}>  "      ~~~  syntax match jsxAttrib -      \ +\<[-A-Za-z_][-:_\$0-9A-Za-z]*\>+ +      \ +\<[_$A-Za-z][-:_$A-Za-z0-9]*\>+        \ contained        \ nextgroup=jsxEqual        \ skipwhite        \ skipempty -      \ contains=jsxAttribKeyword -      \ display +      \ contains=jsxAttribKeyword,jsxNamespace  " <MyComponent ...>  "  ~~~~~~~~~~~ @@ -113,67 +118,71 @@ syntax match jsxAttrib  " <someCamel ...>  "      ~~~~~  exe 'syntax match jsxComponentName -      \ +\<[A-Z][\$0-9A-Za-z]\+\>+ +      \ +\<[_$]\?[A-Z][-_$A-Za-z0-9]*\>+        \ contained -      \ display ' .(s:highlight_close_tag ? 'transparent' : '') +      \ ' .(s:highlight_close_tag ? 'transparent' : '')  " <tag key={this.props.key}>  "  ~~~  exe 'syntax match jsxTagName -      \ +\<[-:_\.\$0-9A-Za-z]\+\>+ +      \ +\<[-:._$A-Za-z0-9]\+\>+        \ contained        \ contains=jsxComponentName,jsxDot,jsxNamespace        \ nextgroup=jsxAttrib        \ skipempty        \ skipwhite -      \ display ' .(s:highlight_close_tag ? 'transparent' : '') +      \ ' .(s:highlight_close_tag ? 'transparent' : '')  " <tag id="sample">  "         ~~~~~~~~  " and  " <tag id='sample'>  "         ~~~~~~~~ -syntax region jsxString start=+\z(["']\)+  skip=+\\\%(\z1\|$\)+  end=+\z1+ contained contains=@Spell display +syntax region jsxString start=+\z(["']\)+  skip=+\\\\\|\\\z1\|\\\n+  end=+\z1+ contained contains=@Spell -let s:tags = get(g:, 'vim_jsx_pretty_template_tags', ['html', 'raw']) +let s:tags = get(g:, 'vim_jsx_pretty_template_tags', ['html', 'jsx'])  let s:enable_tagged_jsx = !empty(s:tags)  " add support to JSX inside the tagged template string  " https://github.com/developit/htm  if s:enable_tagged_jsx -  exe 'syntax region jsxTaggedRegion -        \ start=+\%('. join(s:tags, '\|') .'\)\@<=`+ms=s+1 -        \ end=+`+me=e-1 +  exe 'syntax match jsxRegion +\%(' . join(s:tags, '\|') . '\)\%(\_s*`\)\@=+ contains=jsTemplateStringTag,jsTaggedTemplate,javascriptTagRef skipwhite skipempty nextgroup=jsxTaggedRegion' + +  syntax region jsxTaggedRegion +        \ matchgroup=jsxBackticks +        \ start=+`+ +        \ end=+`+          \ extend          \ contained -        \ containedin=jsTemplateString,javascriptTemplate,javaScriptStringT,typescriptStringB -        \ contains=jsxElement' +        \ contains=jsxElement,jsxEscapeJs +        \ transparent    syntax region jsxEscapeJs +        \ matchgroup=jsxBraces          \ start=+\${+ -        \ end=++ +        \ end=+}+          \ extend          \ contained -        \ contains=jsTemplateExpression,javascriptTemplateSubstitution,javaScriptEmbed,typescriptInterpolation +        \ contains=@jsExpression,jsSpreadExpression,@javascriptExpression,javascriptSpreadOp,@javaScriptEmbededExpr,@typescriptExpression,typescriptObjectSpread    syntax region jsxOpenTag          \ matchgroup=jsxOpenPunct          \ start=+<\%(\${\)\@=+          \ matchgroup=NONE -        \ end=++ +        \ end=+}\@1<=+          \ contained          \ contains=jsxEscapeJs -        \ nextgroup=jsxAttrib,jsxSpreadOperator          \ skipwhite          \ skipempty +        \ nextgroup=jsxAttrib,jsxSpreadOperator -  syntax keyword jsxAttribKeyword class contained display +  syntax keyword jsxAttribKeyword class contained -  syntax match jsxSpreadOperator +\.\.\.+ contained display nextgroup=jsxEscapeJs skipwhite +  syntax match jsxSpreadOperator +\.\.\.+ contained nextgroup=jsxEscapeJs skipwhite -  syntax match jsxCloseTag +<//>+ display +  syntax match jsxCloseTag +<//>+ contained -  syntax match jsxComment +<!--\_.\{-}-->+ display +  syntax match jsxComment +<!--\_.\{-}-->+  endif  " Highlight the tag name @@ -183,10 +192,14 @@ highlight def link jsxComponentName Function  highlight def link jsxAttrib Type  highlight def link jsxAttribKeyword jsxAttrib -highlight def link jsxEqual Operator  highlight def link jsxString String +highlight def link jsxComment Comment +  highlight def link jsxDot Operator  highlight def link jsxNamespace Operator +highlight def link jsxEqual Operator +highlight def link jsxSpreadOperator Operator +highlight def link jsxBraces Special  if s:highlight_close_tag    highlight def link jsxCloseString Identifier @@ -201,9 +214,6 @@ highlight def link jsxPunct jsxCloseString  highlight def link jsxClosePunct jsxPunct  highlight def link jsxCloseTag jsxCloseString -highlight def link jsxComment Comment -highlight def link jsxSpreadOperator Operator -  let s:vim_jsx_pretty_colorful_config = get(g:, 'vim_jsx_pretty_colorful_config', 0)  if s:vim_jsx_pretty_colorful_config == 1 @@ -212,5 +222,4 @@ if s:vim_jsx_pretty_colorful_config == 1    highlight def link jsFuncArgs Type  endif -  endif diff --git a/autoload/go/config.vim b/autoload/go/config.vim index ee9a0bb9..f4ec3ccf 100644 --- a/autoload/go/config.vim +++ b/autoload/go/config.vim @@ -463,6 +463,14 @@ function! go#config#HighlightVariableDeclarations() abort    return get(g:, 'go_highlight_variable_declarations', 0)  endfunction +function! go#config#HighlightDiagnosticErrors() abort +  return get(g:, 'go_highlight_diagnostic_errors', 1) +endfunction + +function! go#config#HighlightDiagnosticWarnings() abort +  return get(g:, 'go_highlight_diagnostic_warnings', 1) +endfunction +  function! go#config#HighlightDebug() abort    return get(g:, 'go_highlight_debug', 1)  endfunction @@ -487,6 +495,26 @@ function! go#config#Updatetime() abort    return go_updatetime == 0 ? &updatetime : go_updatetime  endfunction +function! go#config#ReferrersMode() abort +  return get(g:, 'go_referrers_mode', 'gopls') +endfunction + +function! go#config#GoplsCompleteUnimported() abort +  return get(g:, 'go_gopls_complete_unimported', 0) +endfunction + +function! go#config#GoplsDeepCompletion() abort +  return get(g:, 'go_gopls_deep_completion', 1) +endfunction + +function! go#config#GoplsFuzzyMatching() abort +  return get(g:, 'go_gopls_fuzzy_matching', 1) +endfunction + +function! go#config#GoplsUsePlaceholders() abort +  return get(g:, 'go_gopls_use_placeholders', 0) +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/jsx_pretty/indent.vim b/autoload/jsx_pretty/indent.vim index 15e177e0..03bdf29b 100644 --- a/autoload/jsx_pretty/indent.vim +++ b/autoload/jsx_pretty/indent.vim @@ -10,209 +10,604 @@ else    endfunction  endif -" Get the syntax group of start of line -function! s:syn_sol(lnum) -  let line = getline(a:lnum) -  let sol = matchstr(line, '^\s*') -  return map(synstack(a:lnum, len(sol) + 1), 'synIDattr(v:val, "name")') +" Regexp for the start tag +let s:start_tag = '<\_s*\%(>\|\${\|\%(\<[-:._$A-Za-z0-9]\+\>\)\)' +" Regexp for the end tag +let s:end_tag = '\%(<\_s*/\_s*\%(\<[-:._$A-Za-z0-9]\+\>\)\_s*>\|/\_s*>\)' + +" Get the syntax stack at the given position +function s:syntax_stack_at(lnum, col) +  return map(synstack(a:lnum, a:col), 'synIDattr(v:val, "name")')  endfunction -" Get the syntax group of end of line -function! s:syn_eol(lnum) -  let lnum = prevnonblank(a:lnum) -  let col = strlen(getline(lnum)) -  return map(synstack(lnum, col), 'synIDattr(v:val, "name")') +" Get the syntax at the given position +function s:syntax_at(lnum, col) +  return synIDattr(synID(a:lnum, a:col, 1), 'name')  endfunction -function! s:prev_indent(lnum) -  let lnum = prevnonblank(a:lnum - 1) -  return indent(lnum) +" Get the start col of the non-space charactor +function s:start_col(lnum) +  return len(matchstr(getline(a:lnum), '^\s*')) + 1  endfunction -function! s:prev_line(lnum) -  let lnum = prevnonblank(a:lnum - 1) -  return substitute(getline(lnum), '^\s*\|\s*$', '', 'g') +" Get the end col of the non-space charactor +function s:end_col(lnum) +  return len(substitute(getline(a:lnum), '\s*$', '', 'g'))  endfunction -function! s:syn_attr_jsx(synattr) -  return a:synattr =~? "^jsx" +" Get the start syntax of a given line number +function s:start_syntax(lnum) +  return s:syntax_at(a:lnum, s:start_col(a:lnum))  endfunction -function! s:syn_xmlish(syns) -  return s:syn_attr_jsx(get(a:syns, -1)) +" Get the end syntax of a given line number +function s:end_syntax(lnum) +  let end_col = len(substitute(getline(a:lnum), '\s*$', '', 'g')) +  return s:syntax_at(a:lnum, end_col)  endfunction -function! s:syn_jsx_element(syns) -  return get(a:syns, -1) =~? 'jsxElement' +" The skip function for searchpair +function s:skip_if_not(current_lnum, ...) +  " Skip the match in current line +  if line('.') == a:current_lnum +    return 1 +  endif + +  let syntax = s:syntax_at(line('.'), col('.')) +  return syntax !~? join(a:000, '\|')  endfunction -function! s:syn_js_comment(syns) -  return get(a:syns, -1) =~? 'Comment$' +" Whether the specified stytax group is an jsx-related syntax +function s:is_jsx(syntax_name) +  return a:syntax_name =~ '^jsx' && a:syntax_name !=? 'jsxEscapeJs'  endfunction -function! s:syn_jsx_escapejs(syns) -  return get(a:syns, -1) =~? '\(\(js\(Template\)\?\|javaScript\(Embed\)\?\|typescript\)Braces\|javascriptTemplateSB\|typescriptInterpolationDelimiter\)' && -        \ (get(a:syns, -2) =~? 'jsxEscapeJs' || -        \ get(a:syns, -3) =~? 'jsxEscapeJs') +" Whether the specified line is start with jsx-related syntax +function s:start_with_jsx(lnum) +  let start_syntax = s:start_syntax(a:lnum) +  return s:is_jsx(start_syntax)  endfunction -function! s:syn_jsx_attrib(syns) -  return len(filter(copy(a:syns), 'v:val =~? "jsxAttrib"')) +" Whether the specified line is end with jsx-related syntax +function s:end_with_jsx(lnum) +  let end_syntax = s:end_syntax(a:lnum) +  return s:is_jsx(end_syntax)  endfunction -let s:start_tag = '<\s*\([-:_\.\$0-9A-Za-z]\+\|>\)' -" match `/end_tag>` and `//>` -let s:end_tag = '/\%(\s*[-:_\.\$0-9A-Za-z]*\s*\|/\)>' -let s:opfirst = '^' . get(g:,'javascript_opfirst', -      \ '\C\%([<>=,.?^%|/&]\|\([-:+]\)\1\@!\|\*\+\|!=\|in\%(stanceof\)\=\>\)') +" Whether the specified line is comment related syntax +function s:is_comment(syntax) +  return a:syntax =~? 'comment' +endfunction -function! jsx_pretty#indent#get(js_indent) -  let lnum = v:lnum -  let line = substitute(getline(lnum), '^\s*\|\s*$', '', 'g') -  let current_syn = s:syn_sol(lnum) -  let current_syn_eol = s:syn_eol(lnum) -  let prev_line_num = prevnonblank(lnum - 1) -  let prev_syn_sol = s:syn_sol(prev_line_num) -  let prev_syn_eol = s:syn_eol(prev_line_num) -  let prev_line = s:prev_line(lnum) -  let prev_ind = s:prev_indent(lnum) - -  if s:syn_xmlish(current_syn) - -    if !s:syn_xmlish(prev_syn_sol) -          \ && !s:syn_jsx_escapejs(prev_syn_sol) -          \ && !s:syn_jsx_escapejs(prev_syn_eol) -          \ && !s:syn_js_comment(prev_syn_sol) -      if line =~ '^/\s*>' || line =~ '^<\s*' . s:end_tag -        return prev_ind -      else -        return prev_ind + s:sw() +" Whether the specified line is embedded comment in jsxTag +function s:is_embedded_comment(lnum) +  let start_col = s:start_col(a:lnum) +  let syntax_stack = s:syntax_stack_at(a:lnum, start_col) +  let last = get(syntax_stack, -1) +  let last_2nd = get(syntax_stack, -2) + +  " Patch code for pangloss/vim-javascript +  " <div +  "   /* hello */ <-- syntax stack is [..., jsxTag, jsComment, jsComment] +  " > +  if last_2nd =~ 'comment' +    let last_2nd = get(syntax_stack, -3) +  endif + +  return last =~? 'comment' && last_2nd =~? 'jsxTag' && +        \ trim(getline(a:lnum)) =~ '\%(^/[*/]\)\|\%(\*/$\)' +endfunction + +" Whether the specified stytax group is the opening tag +function s:is_opening_tag(syntax) +  return a:syntax =~? 'jsxOpenPunct' +endfunction + +" Whether the specified stytax group is the closing tag +function s:is_closing_tag(syntax) +  return a:syntax =~? 'jsxClose' +endfunction + +" Whether the specified stytax group is the jsxAttrib +function s:is_jsx_attr(syntax) +  return a:syntax =~? 'jsxAttrib' +endfunction + +" Whether the specified syntax group is the jsxElement +function s:is_jsx_element(syntax) +  return a:syntax =~? 'jsxElement' +endfunction + +" Whether the specified syntax group is the jsxTag +function s:is_jsx_tag(syntax) +  return a:syntax =~? 'jsxTag' +endfunction + +" Whether the specified syntax group is the jsxBraces +function s:is_jsx_brace(syntax) +  return a:syntax =~? 'jsxBraces' +endfunction + +" Whether the specified syntax group is the jsxComment +function s:is_jsx_comment(syntax) +  return a:syntax =~? 'jsxComment' +endfunction + +" Whether the specified syntax group is the jsxComment +function s:is_jsx_backticks(syntax) +  return a:syntax =~? 'jsxBackticks' +endfunction + +" Get the prvious line number +function s:prev_lnum(lnum) +  return prevnonblank(a:lnum - 1) +endfunction + +" Given a lnum and get the information of its previous line +function s:prev_info(lnum) +  let prev_lnum = s:prev_lnum(a:lnum) +  let prev_start_syntax = s:start_syntax(prev_lnum) +  let prev_end_syntax = s:end_syntax(prev_lnum) + +  return [prev_lnum, prev_start_syntax, prev_end_syntax] +endfunction + +" Get the length difference between syntax stack a and b +function s:syntax_stack_length_compare(lnum_a, col_a, lnum_b, col_b) +  let stack_a = s:syntax_stack_at(a:lnum_a, a:col_a) +  let stack_b = s:syntax_stack_at(a:lnum_b, a:col_b) + +  return len(stack_a) - len(stack_b) +endfunction + +" Determine whether child is a element of parent +function s:is_element_of(parent_lnum, child_lnum) +  let parent_stack = s:syntax_stack_at(a:parent_lnum, s:start_col(a:parent_lnum)) +  let child_stack = s:syntax_stack_at(a:child_lnum, s:start_col(a:child_lnum)) + +  let element_index = len(child_stack) - index(reverse(child_stack), 'jsxElement') +  let rest = parent_stack[element_index:] + +  return index(rest, 'jsxElement') == -1 +endfunction + +" Compute the indention of the opening tag +function s:jsx_indent_opening_tag(lnum) +  let [prev_lnum, prev_start_syntax, prev_end_syntax] = s:prev_info(a:lnum) + +  " If current line is start with > +  if trim(getline(a:lnum)) =~ '^>' +    let pair_line = searchpair('<', '', '>', 'bW', 's:skip_if_not(a:lnum, "jsxOpenPunct", "jsxClose")') +    return indent(pair_line) +  endif + +  " If both the start and the end of the previous line are not jsx-related syntax +  " return ( +  "   <div></div> <-- +  " ) +  if !s:end_with_jsx(prev_lnum) && !s:start_with_jsx(prev_lnum) +    " return -1, so that it will use the default js indent function +    return -1 +  endif + +  " If the end of the previous line is not jsx-related syntax +  " [ +  "   <div></div>, +  "   <div></div> <-- +  " ] +  " should not affect +  " <div +  "   render={() => ( +  "     <div> <-- +  "     </div> +  "   )} +  " > +  " </div> +  " <div> +  "   {items.map(() => ( +  "     <Item /> <-- +  "   ))} +  " </div> +  if !s:end_with_jsx(prev_lnum) &&  +        \ !s:is_jsx_attr(prev_start_syntax) && +        \ !s:is_jsx_brace(prev_start_syntax) +    return indent(prev_lnum) +  endif + +  " If the start of the previous line is not jsx-related syntax +  " return <div> +  "   <div></div> <-- +  " </div> +  if !s:start_with_jsx(prev_lnum) +      return indent(prev_lnum) + s:sw() +    endif +  endif + +  " <div> +  "   <span> +  "   </span> +  "   <div> <-- +  "   </div> +  " </div> +  if s:is_closing_tag(prev_start_syntax) +    return indent(prev_lnum) +  endif + +  " If the previous line is end with a closing tag +  " <div> +  "   <br /> +  "   <div></div> <-- +  " </div> +  " should not affect case like +  " <div><br /> +  "   <span> <-- +  " </div> +  if s:is_closing_tag(prev_end_syntax) && +        \ s:syntax_stack_length_compare( +        \   prev_lnum, s:start_col(prev_lnum), prev_lnum, s:end_col(prev_lnum)) == 2 +    return indent(prev_lnum) +  endif + +  " If the start of the previous line is the jsxElement +  " <div> +  "   hello +  "   <div></div> <-- +  " </div> +  if s:is_jsx_element(prev_start_syntax) || +        \ s:is_jsx_comment(prev_start_syntax) +    return indent(prev_lnum) +  endif + +  " If the start of the prvious line is the jsxBraces { +  " <div> +  "   {foo} +  "   <div></div> <-- +  " </div> +  " should not affect case like +  " <div> +  "   { +  "     <div></div> <-- +  "   } +  " </div> +  if s:is_jsx_brace(prev_start_syntax) && +        \ trim(getline(prev_lnum)) =~ '^[$]\?{' && +        \ s:syntax_stack_length_compare( +        \ prev_lnum, s:start_col(prev_lnum), a:lnum, s:start_col(a:lnum)) == -2 +    return indent(prev_lnum) +  endif + +  " If the start of the prvious line is the jsxBraces } +  " <div> +  "   { +  "     foo +  "   } +  "   <div></div> <-- +  " </div> +  if s:is_jsx_brace(prev_start_syntax) && +        \ trim(getline(prev_lnum)) =~ '}' && +        \ s:syntax_stack_length_compare( +        \ prev_lnum, s:start_col(prev_lnum), a:lnum, s:start_col(a:lnum)) == -3 +    return indent(prev_lnum) +  endif + +  " Otherwise, indent s:sw() spaces +  return indent(prev_lnum) + s:sw() +endfunction + +" Compute the indention of the closing tag +function s:jsx_indent_closing_tag(lnum) +  let pair_line = searchpair(s:start_tag, '', s:end_tag, 'bW', 's:skip_if_not(a:lnum, "jsxOpenPunct", "jsxClose")') +  return pair_line ? indent(pair_line) : indent(a:lnum) +endfunction + +" Compute the indention of the jsxAttrib +function s:jsx_indent_attr(lnum) +  let [prev_lnum, prev_start_syntax, prev_end_syntax] = s:prev_info(a:lnum) + +  " If the start of the previous line is not jsx-related syntax +  " return <div +  "   attr="hello" <-- +  " > +  " should not affect +  " <div +  "   // comment here +  "   attr="hello" +  " > +  " </div> +  if !s:start_with_jsx(prev_lnum) && +        \ !s:is_comment(prev_start_syntax) +    return indent(prev_lnum) + s:sw() +  endif + +  " If the start of the previous line is the opening tag +  " <div +  "   title="title" <-- +  " > +  if s:is_opening_tag(prev_start_syntax) +    return indent(prev_lnum) + s:sw() +  endif + +  " Otherwise, align the attribute with its previous line +  return indent(prev_lnum) +endfunction + +" Compute the indentation of the jsxElement +function s:jsx_indent_element(lnum) +  let [prev_lnum, prev_start_syntax, prev_end_syntax] = s:prev_info(a:lnum) + +  " Fix test case like +  " <div|> <-- press enter +  " should indent as +  " <div +  " > <-- +  if trim(getline(a:lnum)) =~ '^>' && !s:is_opening_tag(prev_end_syntax) +    return indent(prev_lnum) +  endif + +  " If the start of the previous line is start with > +  " <div +  "   attr="foo" +  " > +  "   text <-- +  " </div> +  if s:is_opening_tag(prev_start_syntax) && +        \ trim(getline(prev_lnum)) =~ '^>$' +    return indent(prev_lnum) + s:sw() +  endif + +  " <div> +  "   text <-- +  " </div> +  " should not affect case like +  " <div> +  "   <br /> +  "   hello <-- +  " </div> +  if s:is_opening_tag(prev_start_syntax) && +        \ s:is_element_of(prev_lnum, a:lnum) +    return indent(prev_lnum) + s:sw() +  endif + +  " return <div> +  "   text <-- +  " </div> +  if !s:start_with_jsx(prev_lnum) +    return indent(prev_lnum) + s:sw() +  endif + +  " Otherwise, align with the previous line +  " <div> +  "   {foo} +  "   text <-- +  " </div> +  return indent(prev_lnum) +endfunction + +" Compute the indentation of jsxBraces +function s:jsx_indent_brace(lnum) +  let [prev_lnum, prev_start_syntax, prev_end_syntax] = s:prev_info(a:lnum) +   +  " If the start of the previous line is start with > +  " <div +  "   attr="foo" +  " > +  "   {foo} <-- +  " </div> +  if s:is_opening_tag(prev_start_syntax) && +        \ trim(getline(prev_lnum)) =~ '^>$' +    return indent(prev_lnum) + s:sw() +  endif + +  " <div> +  "   {foo} <-- +  " </div> +  " should not affect case like +  " <div> +  "   <br /> +  "   {foo} <-- +  "   text +  "   {foo} <-- +  " </div> +  if s:is_opening_tag(prev_start_syntax) && +        \ s:syntax_stack_length_compare( +        \ prev_lnum, s:start_col(prev_lnum), a:lnum, s:start_col(a:lnum)) == 1 +    return indent(prev_lnum) + s:sw() +  endif + +  " If current line is the close brace } +  if trim(getline(a:lnum)) =~ '^}' +    let pair_line = searchpair('{', '', '}', 'bW', 's:skip_if_not(a:lnum, "jsxBraces")') +    return indent(pair_line) +  endif + +  " return <div> +  "   {foo} <-- +  " </div> +  " should not affect +  " <div +  "   // js comment +  "   {...props} <-- +  " > +  " </div> +  if !s:start_with_jsx(prev_lnum) && +        \ !s:is_comment(prev_start_syntax) +    return indent(prev_lnum) + s:sw() +  endif +   +  return indent(prev_lnum) +endfunction + +" Compute the indentation of the comment +function s:jsx_indent_comment(lnum) +  let [prev_lnum, prev_start_syntax, prev_end_syntax] = s:prev_info(a:lnum) + +  " If current line is jsxComment +  if s:is_jsx_comment(s:start_syntax(a:lnum)) +    let line = trim(getline(a:lnum)) +    if line =~ '^<!--' +      " Patch code for yajs.vim +      " ${logs.map(log => html` +      "   <${Log} class="log" ...${log} /> +      " `)} <-- The backtick here is Highlighted as javascriptTemplate +      " <!-- <-- Correct the indentation here +      if !s:start_with_jsx(prev_lnum) && s:end_with_jsx(prev_lnum) +        return indent(prev_lnum)        endif -    elseif !s:syn_xmlish(prev_syn_sol) && !s:syn_js_comment(prev_syn_sol) && s:syn_jsx_attrib(current_syn) -      " For #79 -      return prev_ind + s:sw() -    " { -    "   <div></div> -    " ##} <-- -    elseif s:syn_jsx_element(current_syn) && line =~ '}$' -      let pair_line = searchpair('{', '', '}', 'b') + +      " Return the element indent for the opening comment +      return s:jsx_indent_element(a:lnum) +    elseif line =~ '^-->' +      " Return the paired indent for the closing comment +      let pair_line = searchpair('<!--', '', '-->', 'bW')        return indent(pair_line) -    elseif line =~ '^-->$' -      if prev_line =~ '^<!--' -        return prev_ind -      else -        return prev_ind - s:sw() -      endif -    elseif prev_line =~ '-->$' -      return prev_ind -    " close tag </tag> or /> including </> -    elseif prev_line =~ s:end_tag . '$' -      if line =~ '^<\s*' . s:end_tag -        return prev_ind - s:sw() -      elseif s:syn_jsx_attrib(prev_syn_sol) -        return prev_ind - s:sw() -      else -        return prev_ind -      endif -    elseif line =~ '^\(>\|/\s*>\)' -      if prev_line =~ '^<' -        return prev_ind -      else -        return prev_ind - s:sw() -      endif -    elseif prev_line =~ '^\(<\|>\)' && -          \ (s:syn_xmlish(prev_syn_eol) || s:syn_js_comment(prev_syn_eol)) -      if line =~ '^<\s*' . s:end_tag -        return prev_ind -      else -        return prev_ind + s:sw() -      endif -    elseif line =~ '^<\s*' . s:end_tag -      if !s:syn_xmlish(prev_syn_sol)  -        if s:syn_jsx_escapejs(prev_syn_eol) -              \ || s:syn_jsx_escapejs(prev_syn_sol) -          return prev_ind - s:sw() -        else -          return prev_ind -        endif -      elseif prev_line =~ '^\<return' -        return prev_ind -      else -        return prev_ind - s:sw() -      endif -    elseif !s:syn_xmlish(prev_syn_eol) -      if prev_line =~ '\(&&\|||\|=>\|[([{]\|`\)$' -        " <div> -        "   { -        "   } -        " </div> -        if line =~ '^[)\]}]' -          return prev_ind -        else -          return prev_ind + s:sw() -        endif -      else -        return prev_ind -      endif      else -      return prev_ind -    endif -  elseif s:syn_jsx_escapejs(current_syn) -    if line =~ '^}' -      let char = getline('.')[col('.') - 1] -      " When pressing enter after the }, keep the indent -      if char != '}' && search('}', 'b', lnum) -        return indent(lnum) -      else -        let pair_line = searchpair('{', '', '}', 'bW') -        return indent(pair_line) -      endif -    elseif line =~ '^{' || line =~ '^\${' -      if s:syn_jsx_escapejs(prev_syn_eol) -            \ || s:syn_jsx_attrib(prev_syn_sol) -        return prev_ind -      elseif s:syn_xmlish(prev_syn_eol) && (prev_line =~ s:end_tag || prev_line =~ '-->$') -        return prev_ind +      if trim(getline(prev_lnum)) =~ '^<!--' +        " <!-- +        "   comment <-- +        " --> +        return indent(prev_lnum) + s:sw()        else -        return prev_ind + s:sw() +        " <!-- +        "   comment +        "   comment <-- +        " --> +        return indent(prev_lnum)        endif      endif -  elseif line =~ '^`' && s:syn_jsx_escapejs(current_syn_eol) -    " For `} of template syntax -    let pair_line = searchpair('{', '', '}', 'bW') -    return indent(pair_line) -  elseif line =~ '^/[/*]' " js comment in jsx tag -    if get(prev_syn_sol, -1) =~ 'Punct' -      return prev_ind + s:sw() -    elseif synIDattr(synID(lnum - 1, 1, 1), 'name') =~ 'jsxTag' -      return prev_ind -    else -      return a:js_indent() +  endif + +  " For comment inside the jsxTag +  if s:is_opening_tag(prev_start_syntax) +    return indent(prev_lnum) + s:sw() +  endif + +  if trim(getline(a:lnum)) =~ '\*/$' +    let pair_line = searchpair('/\*', '', '\*/', 'bW', 's:skip_if_not(a:lnum)') +    return indent(pair_line) + 1 +  endif +   +  return indent(prev_lnum) +endfunction + +function s:jsx_indent_backticks(lnum) +  let tags = get(g:, 'vim_jsx_pretty_template_tags', ['html', 'jsx']) +  let start_tag = '\%(' . join(tags, '\|') . '\)`' +  let end_tag = '\%(' . join(tags, '\|') . '\)\@<!`' +  let pair_line = searchpair(start_tag, '', end_tag, 'bW', 's:skip_if_not(a:lnum)') + +  return indent(pair_line) +endfunction + +" Compute the indentation for the jsx-related element +function s:jsx_indent(lnum) +  let start_syntax = s:start_syntax(a:lnum) + +  if s:is_opening_tag(start_syntax) +    return s:jsx_indent_opening_tag(a:lnum) +  elseif s:is_closing_tag(start_syntax) +    return s:jsx_indent_closing_tag(a:lnum) +  elseif s:is_jsx_attr(start_syntax) +    return s:jsx_indent_attr(a:lnum) +  elseif s:is_jsx_element(start_syntax) +    return s:jsx_indent_element(a:lnum) +  elseif s:is_jsx_brace(start_syntax) +    return s:jsx_indent_brace(a:lnum) +  elseif s:is_jsx_comment(start_syntax) +    return s:jsx_indent_comment(a:lnum) +  elseif s:is_jsx_backticks(start_syntax) +    return s:jsx_indent_backticks(a:lnum) +  endif + +  return -1 +endfunction + +" Return the jsx context of the specified line  +function s:jsx_context(lnum) +  if !s:end_with_jsx(prev_lnum) +    return 'non-jsx' +  endif + +  let prev_lnum = s:prev_lnum(a:lnum) +  let start_syntax = s:start_syntax(prev_lnum) +  let end_col = s:end_col(prev_lnum) +  let end_syntax_stack = s:syntax_stack_at(prev_lnum, end_col) +  let reversed = reverse(end_syntax_stack) + +  for item in reversed +    if item =~? 'jsxEscapeJs' +      return 'unknown' +    elseif s:is_jsx_element(item) && s:is_jsx(start_syntax) && start_syntax !~? 'jsxEscapeJs' +      " <div> +      "   <br /> <-- press o +      " </div> +      " -------------------- +      " <div> +      " { +      "     a > 0 ? 1 <div>|</div> <-- press enter +      " } +      " </div> +      return 'jsxElement' +    elseif s:is_jsx_tag(item) +      return 'jsxTag' +    elseif s:is_jsx_brace(item) && trim(getline(prev_lnum)) =~ '{$' +      return 'jsxBraces'      endif +  endfor + +  return 'unknown' +endfunction + +function! jsx_pretty#indent#get(js_indent) +  " The start column index of the current line (one-based) +  let start_col = s:start_col(v:lnum) +  " The end column index of the current line (one-based) +  let end_col = s:end_col(v:lnum) + +  if s:start_with_jsx(v:lnum) +    let ind = s:jsx_indent(v:lnum) +    return ind == -1 ? a:js_indent() : ind +  elseif s:is_embedded_comment(v:lnum) +    return s:jsx_indent_comment(v:lnum)    else -    let ind = a:js_indent() - -    " Issue #68 -    " return (<div> -    " |<div>) -    if (line =~ '^/\s*>' || line =~ '^<\s*' . s:end_tag) -          \ && !s:syn_xmlish(prev_syn_sol) -      return prev_ind +    let line = trim(getline(v:lnum)) +    let prev_lnum = s:prev_lnum(v:lnum) + +    " Fix the case where pressing enter at the cursor +    " return <div>|</div> +    if line =~ '^' . s:end_tag && +          \ s:end_with_jsx(s:prev_lnum(v:lnum)) +      return s:jsx_indent_closing_tag(v:lnum)      endif -    " If current syntax is not a jsx syntax group -    if s:syn_xmlish(prev_syn_eol) && line !~ '^[)\]}]' -      let sol = matchstr(line, s:opfirst) -      if sol is '' -        " Fix javascript continue indent -        return ind - s:sw() -      else -        return ind +    " Fix cases for the new line +    if empty(line) +      let context = s:jsx_context(v:lnum) + +      if context == 'jsxElement' +        " <div> <-- press o +        " </div> +        return s:jsx_indent_element(v:lnum) +      elseif context == 'jsxTag' +        " <div <-- press o +        " > +        " </div> +        " ----------------------- +        " <div +        "   attr="attr" <-- press o +        " > +        " </div> +        return s:jsx_indent_attr(v:lnum) +      elseif context == 'jsxBraces' +        " <div> +        "   { <-- press o +        "   } +        " </div> +        return indent(prev_lnum) + s:sw()        endif      endif -    return ind -  endif +    return a:js_indent() +  endif  endfunction  endif diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 3dc8a3ec..7306f02b 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -634,6 +634,13 @@ endif  if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'javascript') == -1    augroup filetypedetect +  " javascript, from flow.vim in pangloss/vim-javascript:_JAVASCRIPT +autocmd BufNewFile,BufRead *.flow setfiletype flow +  augroup end +endif + +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'javascript') == -1 +  augroup filetypedetect    " javascript, from javascript.vim in pangloss/vim-javascript:_JAVASCRIPT  fun! s:SelectJavascript()    if getline(1) =~# '^#!.*/bin/\%(env\s\+\)\?node\>' @@ -1109,7 +1116,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'racket') == -1  let g:racket_hash_lang_regexp = '^#lang\s\+\([^][)(}{[:space:]]\+\)'  " Tries to detect filetype from #lang line; defaults to ft=racket. -function RacketDetectHashLang() +function! RacketDetectHashLang()    let old_ft = &filetype    let matches = matchlist(getline(1), g:racket_hash_lang_regexp) diff --git a/ftplugin/ruby.vim b/ftplugin/ruby.vim index 9abce9f9..9c9289b1 100644 --- a/ftplugin/ruby.vim +++ b/ftplugin/ruby.vim @@ -374,7 +374,6 @@ function! RubyCursorFile() abort    endtry    let pre = matchstr(strpart(getline('.'), 0, col('.')-1), '.*\f\@<!')    let post = matchstr(strpart(getline('.'), col('.')), '\f\@!.*') -  let ext = getline('.') =~# '^\s*\%(require\%(_relative\)\=\|autoload\)\>' && cfile !~# '\.rb$' ? '.rb' : ''    if s:synid() ==# hlID('rubyConstant')      let cfile = substitute(cfile,'\.\w\+[?!=]\=$','','')      let cfile = substitute(cfile,'^::','','') @@ -383,12 +382,15 @@ function! RubyCursorFile() abort      let cfile = substitute(cfile,'\(\l\|\d\)\(\u\)','\1_\2', 'g')      return tolower(cfile) . '.rb'    elseif getline('.') =~# '^\s*require_relative\s*\(["'']\).*\1\s*$' -    let cfile = expand('%:p:h') . '/' . matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1') . ext +    let cfile = expand('%:p:h') . '/' . matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1') +    let cfile .= cfile !~# '\.rb$' ? '.rb' : ''    elseif getline('.') =~# '^\s*\%(require[( ]\|load[( ]\|autoload[( ]:\w\+,\)\s*\%(::\)\=File\.expand_path(\(["'']\)\.\./.*\1,\s*__FILE__)\s*$'      let target = matchstr(getline('.'),'\(["'']\)\.\.\zs/.\{-\}\ze\1') -    let cfile = expand('%:p:h') . target . ext +    let cfile = expand('%:p:h') . target +    let cfile .= cfile !~# '\.rb$' ? '.rb' : ''    elseif getline('.') =~# '^\s*\%(require \|load \|autoload :\w\+,\)\s*\(["'']\).*\1\s*$' -    let cfile = matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1') . ext +    let cfile = matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1') +    let cfile .= cfile !~# '\.rb$' ? '.rb' : ''    elseif pre.post =~# '\<File.expand_path[( ].*[''"]\{2\}, *__FILE__\>' && cfile =~# '^\.\.'      let cfile = expand('%:p:h') . strpart(cfile, 2)    else diff --git a/syntax/basic/type.vim b/syntax/basic/type.vim index bd1bdd1a..af2b535f 100644 --- a/syntax/basic/type.vim +++ b/syntax/basic/type.vim @@ -52,7 +52,8 @@ syntax cluster typescriptPrimaryType contains=    \ typescriptTupleType,    \ typescriptTypeQuery,    \ typescriptStringLiteralType, -  \ typescriptReadonlyArrayKeyword +  \ typescriptReadonlyArrayKeyword, +  \ typescriptAssertType  syntax region  typescriptStringLiteralType contained    \ start=/\z(["']\)/  skip=/\\\\\|\\\z1\|\\\n/  end=/\z1\|$/ @@ -130,6 +131,10 @@ syntax keyword typescriptTypeQuery typeof keyof    \ nextgroup=typescriptTypeReference    \ contained skipwhite skipnl +syntax keyword typescriptAssertType asserts +  \ nextgroup=typescriptTypeReference +  \ contained skipwhite skipnl +  syntax cluster typescriptCallSignature contains=typescriptGenericCall,typescriptCall  syntax region typescriptGenericCall matchgroup=typescriptTypeBrackets    \ start=/</ end=/>/ diff --git a/syntax/common.vim b/syntax/common.vim index 62e5bffd..cf0b7161 100644 --- a/syntax/common.vim +++ b/syntax/common.vim @@ -155,6 +155,7 @@ if exists("did_typescript_hilink")    HiLink typescriptTypeReference         Identifier    HiLink typescriptConstructor           Keyword    HiLink typescriptDecorator             Special +  HiLink typescriptAssertType            Keyword    highlight link typeScript             NONE diff --git a/syntax/flow.vim b/syntax/flow.vim new file mode 100644 index 00000000..ad4ba0a8 --- /dev/null +++ b/syntax/flow.vim @@ -0,0 +1,6 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'javascript') == -1 + +runtime syntax/javascript.vim +runtime extras/flow.vim + +endif diff --git a/syntax/go.vim b/syntax/go.vim index 5a23f24f..1d1cce13 100644 --- a/syntax/go.vim +++ b/syntax/go.vim @@ -166,13 +166,19 @@ syn match       goSingleDecl        /\%(import\|var\|const\) [^(]\@=/ contains=g  " Integers  syn match       goDecimalInt        "\<-\=\d\+\%([Ee][-+]\=\d\+\)\=\>"  syn match       goHexadecimalInt    "\<-\=0[xX]\x\+\>" +syn match       goHexadecimalError  "\<-\=0[xX]\x*[^ \t0-9A-Fa-f]\S*\>"  syn match       goOctalInt          "\<-\=0\o\+\>" -syn match       goOctalError        "\<-\=0\o*[89]\d*\>" +syn match       goOctalError        "\<-\=0[^XxBb]\o*[^ \t0-7]\S*\>" +syn match       goBinaryInt         "\<-\=0[bB][01]\+\>" +syn match       goBinaryError       "\<-\=0[bB][01]*[^ \t01]\S*\>"  hi def link     goDecimalInt        Integer  hi def link     goHexadecimalInt    Integer +hi def link     goHexadecimalError  Error  hi def link     goOctalInt          Integer  hi def link     goOctalError        Error +hi def link     goBinaryInt         Integer +hi def link     goBinaryError       Error  hi def link     Integer             Number  " Floating point @@ -384,6 +390,13 @@ hi def link goCoverageNormalText Comment  function! s:hi()    hi def link goSameId Search +  hi def link goDiagnosticError SpellBad +  hi def link goDiagnosticWarning SpellRare + +  hi def link goDeclsFzfKeyword        Keyword +  hi def link goDeclsFzfFunction       Function +  hi def link goDeclsFzfSpecialComment SpecialComment +  hi def link goDeclsFzfComment        Comment    " :GoCoverage commands    hi def      goCoverageCovered    ctermfg=green guifg=#A6E22E diff --git a/syntax/javascript.vim b/syntax/javascript.vim index 388d02f9..29863ee1 100644 --- a/syntax/javascript.vim +++ b/syntax/javascript.vim @@ -112,7 +112,7 @@ syntax keyword jsAsyncKeyword           async await  syntax match   jsSwitchColon   contained /::\@!/        skipwhite skipempty nextgroup=jsSwitchBlock  " Keywords -syntax keyword jsGlobalObjects      Array Boolean Date Function Iterator Number Object Symbol Map WeakMap Set WeakSet RegExp String Proxy Promise Buffer ParallelArray ArrayBuffer DataView Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray JSON Math console document window Intl Collator DateTimeFormat NumberFormat fetch +syntax keyword jsGlobalObjects     ArrayBuffer Array BigInt64Array BigUint64Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray Boolean Buffer Collator DataView Date DateTimeFormat Function Intl Iterator JSON Map Set WeakMap WeakSet Math Number NumberFormat Object ParallelArray Promise Proxy Reflect RegExp String Symbol Uint8ClampedArray WebAssembly console document fetch window  syntax keyword jsGlobalNodeObjects  module exports global process __dirname __filename  syntax match   jsGlobalNodeObjects  /\<require\>/ containedin=jsFuncCall  syntax keyword jsExceptions         Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError @@ -152,7 +152,7 @@ syntax region  jsSwitchBlock        contained matchgroup=jsSwitchBraces        s  syntax region  jsRepeatBlock        contained matchgroup=jsRepeatBraces        start=/{/  end=/}/  contains=@jsAll,jsBlock extend fold  syntax region  jsDestructuringBlock contained matchgroup=jsDestructuringBraces start=/{/  end=/}/  contains=jsDestructuringProperty,jsDestructuringAssignment,jsDestructuringNoise,jsDestructuringPropertyComputed,jsSpreadExpression,jsComment nextgroup=jsFlowDefinition extend fold  syntax region  jsDestructuringArray contained matchgroup=jsDestructuringBraces start=/\[/ end=/\]/ contains=jsDestructuringPropertyValue,jsDestructuringNoise,jsDestructuringProperty,jsSpreadExpression,jsDestructuringBlock,jsDestructuringArray,jsComment nextgroup=jsFlowDefinition extend fold -syntax region  jsObject             contained matchgroup=jsObjectBraces        start=/{/  end=/}/  contains=jsObjectKey,jsObjectKeyString,jsObjectKeyComputed,jsObjectShorthandProp,jsObjectSeparator,jsObjectFuncName,jsObjectMethodType,jsGenerator,jsComment,jsObjectStringKey,jsSpreadExpression,jsDecorator,jsAsyncKeyword extend fold +syntax region  jsObject             contained matchgroup=jsObjectBraces        start=/{/  end=/}/  contains=jsObjectKey,jsObjectKeyString,jsObjectKeyComputed,jsObjectShorthandProp,jsObjectSeparator,jsObjectFuncName,jsObjectMethodType,jsGenerator,jsComment,jsObjectStringKey,jsSpreadExpression,jsDecorator,jsAsyncKeyword,jsTemplateString extend fold  syntax region  jsBlock                        matchgroup=jsBraces              start=/{/  end=/}/  contains=@jsAll,jsSpreadExpression extend fold  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 diff --git a/syntax/meson.vim b/syntax/meson.vim index d41eb06e..a84a08f1 100644 --- a/syntax/meson.vim +++ b/syntax/meson.vim @@ -30,7 +30,7 @@ endif  " We need nocompatible mode in order to continue lines with backslashes.  " Original setting will be restored.  let s:cpo_save = &cpo -setlocal cpo&vim +set cpo&vim  " http://mesonbuild.com/Syntax.html  syn keyword mesonConditional	elif else if endif diff --git a/syntax/ocaml.vim b/syntax/ocaml.vim index 2058821e..6e6cf225 100644 --- a/syntax/ocaml.vim +++ b/syntax/ocaml.vim @@ -230,7 +230,18 @@ syn match    ocamlStar         "*"  syn match    ocamlAngle        "<"  syn match    ocamlAngle        ">"  " Custom indexing operators: -syn match    ocamlIndexingOp   "\.[~?!:|&$%=>@^/*+-][~?!.:|&$%<=>@^*/+-]*\(()\|\[]\|{}\)\(<-\)\?" +syn region   ocamlIndexing matchgroup=ocamlIndexingOp +  \ start="\.[~?!:|&$%=>@^/*+-][~?!.:|&$%<=>@^*/+-]*\_s*(" +  \ end=")\(\_s*<-\)\?" +  \ contains=ALLBUT,@ocamlContained,ocamlParenErr +syn region   ocamlIndexing matchgroup=ocamlIndexingOp +  \ start="\.[~?!:|&$%=>@^/*+-][~?!.:|&$%<=>@^*/+-]*\_s*\[" +  \ end="]\(\_s*<-\)\?" +  \ contains=ALLBUT,@ocamlContained,ocamlBrackErr +syn region   ocamlIndexing matchgroup=ocamlIndexingOp +  \ start="\.[~?!:|&$%=>@^/*+-][~?!.:|&$%<=>@^*/+-]*\_s*{" +  \ end="}\(\_s*<-\)\?" +  \ contains=ALLBUT,@ocamlContained,ocamlBraceErr  " Extension operators (has to be declared before regular infix operators):  syn match    ocamlExtensionOp          "#[#~?!.:|&$%<=>@^*/+-]\+"  " Infix and prefix operators: diff --git a/syntax/opam.vim b/syntax/opam.vim index d98dd0a7..a300b3b9 100644 --- a/syntax/opam.vim +++ b/syntax/opam.vim @@ -6,7 +6,7 @@ endif  " need %{vars}%  " env: [[CAML_LD_LIBRARY_PATH = "%{lib}%/stublibs"]] -syn keyword opamKeyword1 remove depends depopts conflicts env packages patches version maintainer tags license homepage authors doc install author available name depexts substs synopsis description +syn keyword opamKeyword1 remove depends pin-depends depopts conflicts env packages patches version maintainer tags license homepage authors doc install author available name depexts substs synopsis description  syn match opamKeyword2 "\v(bug-reports|post-messages|ocaml-version|opam-version|dev-repo|build-test|build-doc|build)"  syn keyword opamTodo FIXME NOTE NOTES TODO XXX contained diff --git a/syntax/plantuml.vim b/syntax/plantuml.vim index d6ac9af4..f3ebfaee 100644 --- a/syntax/plantuml.vim +++ b/syntax/plantuml.vim @@ -24,22 +24,28 @@ syntax match plantumlPreProc /\%(\%(^@start\|^@end\)\%(dot\|mindmap\|uml\|salt\|  syntax region plantumlDir start=/\s\+/ms=s+1 end=/$/ contained  " type +" From 'java - jar plantuml.jar - language' results {{{  syntax keyword plantumlTypeKeyword abstract actor agent archimate artifact boundary card cloud component control -syntax keyword plantumlTypeKeyword database diamond entity enum file folder frame node object robust concise package participant -syntax keyword plantumlTypeKeyword queue rectangle stack state storage usecase +syntax keyword plantumlTypeKeyword database detach diamond entity enum file folder frame node object package +syntax keyword plantumlTypeKeyword participant queue rectangle stack state storage usecase  " class and interface are defined as plantumlClassKeyword  syntax keyword plantumlClassKeyword class interface +"}}} +" Not in 'java - jar plantuml.jar - language' results +syntax keyword plantumlTypeKeyword concise robust  " keyword -" Exclude 'top to bottom direction' +" From 'java - jar plantuml.jar - language' results {{{ +" Since "syntax keyword" can handle only words, "top to bottom direction" is excluded.  syntax keyword plantumlKeyword accross activate again allow_mixing allowmixing also alt as autonumber bottom  syntax keyword plantumlKeyword box break caption center create critical deactivate destroy down else elseif end  syntax keyword plantumlKeyword endif endwhile footbox footer fork group header hide hnote if is kill left in at are to the and -syntax keyword plantumlKeyword legend endlegend link loop mainframe namespace newpage note of on opt order over package +syntax keyword plantumlKeyword legend link loop mainframe namespace newpage note of on opt order over package  syntax keyword plantumlKeyword page par partition ref repeat return right rnote rotate show skin skinparam  syntax keyword plantumlKeyword start stop title top up while -" Not in 'java - jar plantuml.jar - language' output -syntax keyword plantumlKeyword then detach split sprite +"}}} +" Not in 'java - jar plantuml.jar - language' results +syntax keyword plantumlKeyword endlegend split sprite then  " gantt  syntax keyword plantumlTypeKeyword project monday tuesday wednesday thursday friday saturday sunday  syntax keyword plantumlKeyword starts ends start end closed day after colored lasts happens diff --git a/syntax/terraform.vim b/syntax/terraform.vim index 9efcfee0..e830c458 100644 --- a/syntax/terraform.vim +++ b/syntax/terraform.vim @@ -15,9 +15,6 @@ endif  syn case match -syn keyword terraSection connection output provider variable data terraform locals -syn keyword terraValueBool true false on off yes no -  """ data  syn keyword terraDataTypeBI            \ aci_access_port_block @@ -4443,39 +4440,38 @@ syn keyword terraResourceTypeBI            \ yandex_vpc_subnet  """ end resources +syn keyword terraSection connection output variable terraform locals +syn keyword terraValueBool true false on off yes no +  syn keyword terraTodo         contained TODO FIXME XXX BUG  syn cluster terraCommentGroup contains=terraTodo  syn region  terraComment      start="/\*" end="\*/" contains=@terraCommentGroup,@Spell  syn region  terraComment      start="#" end="$" contains=@terraCommentGroup,@Spell  syn region  terraComment      start="//" end="$" contains=@terraCommentGroup,@Spell -syn match  terraResource        /\<resource\>/ nextgroup=terraResourceTypeStr skipwhite -syn region terraResourceTypeStr start=/"/ end=/"/ contains=terraResourceTypeBI -                              \ nextgroup=terraResourceName skipwhite -syn region terraResourceName    start=/"/ end=/"/ -                              \ nextgroup=terraResourceBlock skipwhite +syn keyword terraResource        resource nextgroup=terraResourceTypeStr skipwhite +syn region  terraResourceTypeStr start=/"/ end=/"/ contains=terraResourceTypeBI nextgroup=terraResourceName skipwhite +syn region  terraResourceName    start=/"/ end=/"/ nextgroup=terraResourceBlock skipwhite -syn match  terraData        /\<data\>/ nextgroup=terraDataTypeStr skipwhite -syn region terraDataTypeStr start=/"/ end=/"/ contains=terraDataTypeBI -                              \ nextgroup=terraDataName skipwhite -syn region terraDataName    start=/"/ end=/"/ -                              \ nextgroup=terraDataBlock skipwhite +syn keyword terraData        data nextgroup=terraDataTypeStr skipwhite +syn region  terraDataTypeStr start=/"/ end=/"/ contains=terraDataTypeBI nextgroup=terraDataName skipwhite +syn region  terraDataName    start=/"/ end=/"/ nextgroup=terraDataBlock skipwhite  """ provider -syn match  terraProvider      /\<provider\>/ nextgroup=terraProviderName skipwhite -syn region terraProviderName  start=/"/ end=/"/ nextgroup=terraProviderBlock skipwhite +syn keyword terraProvider     provider nextgroup=terraProviderName skipwhite +syn region  terraProviderName start=/"/ end=/"/ nextgroup=terraProviderBlock skipwhite  """ provisioner -syn match  terraProvisioner     /\<provisioner\>/ nextgroup=terraProvisionerName skipwhite -syn region terraProvisionerName start=/"/ end=/"/ nextgroup=terraProvisionerBlock skipwhite +syn keyword terraProvisioner     provisioner nextgroup=terraProvisionerName skipwhite +syn region  terraProvisionerName start=/"/ end=/"/ nextgroup=terraProvisionerBlock skipwhite  """ module -syn match  terraModule     /\<module\>/ nextgroup=terraModuleName skipwhite -syn region terraModuleName start=/"/ end=/"/ nextgroup=terraModuleBlock skipwhite +syn keyword terraModule     module nextgroup=terraModuleName skipwhite +syn region  terraModuleName start=/"/ end=/"/ nextgroup=terraModuleBlock skipwhite  """ dynamic (HCL2) -syn match  terraDynamic     /\<dynamic\>/ nextgroup=terraDynamicName skipwhite -syn region terraDynamicName start=/"/ end=/"/ nextgroup=terraDynamicBlock skipwhite +syn keyword terraDynamic     dynamic nextgroup=terraDynamicName skipwhite +syn region  terraDynamicName start=/"/ end=/"/ nextgroup=terraDynamicBlock skipwhite  """ misc.  syn match terraValueDec      "\<[0-9]\+\([kKmMgG]b\?\)\?\>" diff --git a/syntax/zig.vim b/syntax/zig.vim index 29f72353..a0b8330a 100644 --- a/syntax/zig.vim +++ b/syntax/zig.vim @@ -36,7 +36,7 @@ syn match zigBuiltinFn "\v\@(compileLog|ctz|popCount|divExact|divFloor|divTrunc)  syn match zigBuiltinFn "\v\@(embedFile|export|tagName|TagType|errorName)>"  syn match zigBuiltinFn "\v\@(errorReturnTrace|fence|fieldParentPtr|field|unionInit)>"  syn match zigBuiltinFn "\v\@(frameAddress|import|inlineCall|newStackCall|asyncCall|intToPtr|IntType)>" -syn match zigBuiltinFn "\v\@(maxValue|memberCount|memberName|memberType)>" +syn match zigBuiltinFn "\v\@(maxValue|memberCount|memberName|memberType|as)>"  syn match zigBuiltinFn "\v\@(memcpy|memset|minValue|mod|mulWithOverflow|splat)>"  syn match zigBuiltinFn "\v\@(noInlineCall|bitOffsetOf|byteOffsetOf|OpaqueType|panic|ptrCast)>"  syn match zigBuiltinFn "\v\@(ptrToInt|rem|returnAddress|setCold|Type|shuffle)>" @@ -58,6 +58,8 @@ syn match zigCharacterInvalidUnicode display contained /b'\zs[^[:cntrl:][:graph:  syn match zigCharacter /b'\([^\\]\|\\\(.\|x\x\{2}\)\)'/ contains=zigEscape,zigEscapeError,zigCharacterInvalid,zigCharacterInvalidUnicode  syn match zigCharacter /'\([^\\]\|\\\(.\|x\x\{2}\|u\x\{4}\|U\x\{6}\)\)'/ contains=zigEscape,zigEscapeUnicode,zigEscapeError,zigCharacterInvalid +syn region zigBlock start="{" end="}" transparent fold +  syn region zigCommentLine start="//" end="$" contains=zigTodo,@Spell  syn region zigCommentLineDoc start="////\@!" end="$" contains=zigTodo,@Spell | 
