From fb7cf8a9ab782d67db5aa71bffac67e63fcc0c4c Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Thu, 10 Sep 2020 10:30:32 +0200 Subject: Update --- after/ftplugin/javascript.vim | 44 ++++++---------------------- after/ftplugin/javascriptreact.vim | 2 +- after/ftplugin/jsx.vim | 35 ++++++++++++++++++++++ after/indent/javascript.vim | 30 ++----------------- after/indent/javascriptreact.vim | 2 +- after/indent/jsx.vim | 33 +++++++++++++++++++++ after/syntax/javascript.vim | 56 ++---------------------------------- after/syntax/javascriptreact.vim | 2 +- after/syntax/jsx.vim | 59 ++++++++++++++++++++++++++++++++++++++ after/syntax/reason/graphql.vim | 2 +- 10 files changed, 146 insertions(+), 119 deletions(-) create mode 100644 after/ftplugin/jsx.vim create mode 100644 after/indent/jsx.vim create mode 100644 after/syntax/jsx.vim (limited to 'after') diff --git a/after/ftplugin/javascript.vim b/after/ftplugin/javascript.vim index a590e11d..8ff3938a 100644 --- a/after/ftplugin/javascript.vim +++ b/after/ftplugin/javascript.vim @@ -1,3 +1,12 @@ +if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1) + +if get(g:, 'vim_jsx_pretty_disable_js', 0) + finish +endif + +source :h/jsx.vim + +endif if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'javascript') == -1 " Vim filetype plugin file @@ -14,38 +23,3 @@ else endif endif -if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1) - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Vim ftplugin file -" -" Language: javascript.jsx -" Maintainer: MaxMEllon -" -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - -" modified from html.vim -" For matchit plugin -if exists("loaded_matchit") - let b:match_ignorecase = 0 - let b:match_words = '(:),\[:\],{:},<:>,' . - \ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>' -endif - -" For andymass/vim-matchup plugin -if exists("loaded_matchup") - setlocal matchpairs=(:),{:},[:],<:> - let b:match_words = '<\@<=\([^/][^ \t>]*\)\g{hlend}[^>]*\%(/\@\|$\):<\@<=/\1>' - let b:match_skip = 's:comment\|string' -endif - -let b:jsx_pretty_old_cms = &l:commentstring - -augroup jsx_comment - autocmd! CursorMoved - autocmd CursorMoved call jsx_pretty#comment#update_commentstring(b:jsx_pretty_old_cms) -augroup end - -setlocal suffixesadd+=.jsx - -endif diff --git a/after/ftplugin/javascriptreact.vim b/after/ftplugin/javascriptreact.vim index ab847072..265415d0 100644 --- a/after/ftplugin/javascriptreact.vim +++ b/after/ftplugin/javascriptreact.vim @@ -1,5 +1,5 @@ if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1) -source :h/javascript.vim +source :h/jsx.vim endif diff --git a/after/ftplugin/jsx.vim b/after/ftplugin/jsx.vim new file mode 100644 index 00000000..94f90c13 --- /dev/null +++ b/after/ftplugin/jsx.vim @@ -0,0 +1,35 @@ +if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1) + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Vim ftplugin file +" +" Language: javascript.jsx +" Maintainer: MaxMEllon +" +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" modified from html.vim +" For matchit plugin +if exists("loaded_matchit") + let b:match_ignorecase = 0 + let b:match_words = '(:),\[:\],{:},<:>,' . + \ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>' +endif + +" For andymass/vim-matchup plugin +if exists("loaded_matchup") + setlocal matchpairs=(:),{:},[:],<:> + let b:match_words = '<\@<=\([^/][^ \t>]*\)\g{hlend}[^>]*\%(/\@\|$\):<\@<=/\1>' + let b:match_skip = 's:comment\|string' +endif + +let b:jsx_pretty_old_cms = &l:commentstring + +augroup jsx_comment + autocmd! CursorMoved + autocmd CursorMoved call jsx_pretty#comment#update_commentstring(b:jsx_pretty_old_cms) +augroup end + +setlocal suffixesadd+=.jsx + +endif diff --git a/after/indent/javascript.vim b/after/indent/javascript.vim index dd280edb..0add1da1 100644 --- a/after/indent/javascript.vim +++ b/after/indent/javascript.vim @@ -47,34 +47,10 @@ endfunction endif if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1) -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Vim indent file -" -" Language: javascript.jsx -" Maintainer: MaxMellon -" -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - -if exists('b:did_indent') - let s:did_indent = b:did_indent - unlet b:did_indent -endif - -let s:keepcpo = &cpo -set cpo&vim - -if exists('s:did_indent') - let b:did_indent = s:did_indent +if get(g:, 'vim_jsx_pretty_disable_js', 0) + finish endif -setlocal indentexpr=GetJsxIndent() -setlocal indentkeys=0.,0{,0},0),0],0?,0\*,0\,,!^F,:,<:>,o,O,e,<>>,=*/ - -function! GetJsxIndent() - return jsx_pretty#indent#get(function('GetJavascriptIndent')) -endfunction - -let &cpo = s:keepcpo -unlet s:keepcpo +source :h/jsx.vim endif diff --git a/after/indent/javascriptreact.vim b/after/indent/javascriptreact.vim index ab847072..265415d0 100644 --- a/after/indent/javascriptreact.vim +++ b/after/indent/javascriptreact.vim @@ -1,5 +1,5 @@ if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1) -source :h/javascript.vim +source :h/jsx.vim endif diff --git a/after/indent/jsx.vim b/after/indent/jsx.vim new file mode 100644 index 00000000..fcd7b5ad --- /dev/null +++ b/after/indent/jsx.vim @@ -0,0 +1,33 @@ +if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1) + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Vim indent file +" +" Language: javascript.jsx +" Maintainer: MaxMellon +" +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +if exists('b:did_indent') + let s:did_indent = b:did_indent + unlet b:did_indent +endif + +let s:keepcpo = &cpo +set cpo&vim + +if exists('s:did_indent') + let b:did_indent = s:did_indent +endif + +setlocal indentexpr=GetJsxIndent() +setlocal indentkeys=0.,0{,0},0),0],0?,0\*,0\,,!^F,:,<:>,o,O,e,<>>,=*/ + +function! GetJsxIndent() + return jsx_pretty#indent#get(function('GetJavascriptIndent')) +endfunction + +let &cpo = s:keepcpo +unlet s:keepcpo + +endif diff --git a/after/syntax/javascript.vim b/after/syntax/javascript.vim index 00c4b079..2992e942 100644 --- a/after/syntax/javascript.vim +++ b/after/syntax/javascript.vim @@ -1,59 +1,9 @@ if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1) -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Vim syntax file -" -" Language: javascript.jsx -" Maintainer: MaxMellon -" -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - -let s:jsx_cpo = &cpo -set cpo&vim - -syntax case match - -if exists('b:current_syntax') - let s:current_syntax = b:current_syntax - unlet b:current_syntax -endif - -if exists('s:current_syntax') - let b:current_syntax = s:current_syntax -endif - -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 -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 javaScriptBlock - \ matchgroup=javaScriptBraces - \ start="{" - \ end="}" - \ contained - \ extend - \ contains=javaScriptBlock,@javaScriptEmbededExpr,javaScript.* - \ fold - - syntax cluster javaScriptEmbededExpr add=jsxRegion,javaScript.* +if get(g:, 'vim_jsx_pretty_disable_js', 0) + finish endif -runtime syntax/jsx_pretty.vim - -let b:current_syntax = 'javascript.jsx' - -let &cpo = s:jsx_cpo -unlet s:jsx_cpo +source :h/jsx.vim endif diff --git a/after/syntax/javascriptreact.vim b/after/syntax/javascriptreact.vim index ab847072..265415d0 100644 --- a/after/syntax/javascriptreact.vim +++ b/after/syntax/javascriptreact.vim @@ -1,5 +1,5 @@ if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1) -source :h/javascript.vim +source :h/jsx.vim endif diff --git a/after/syntax/jsx.vim b/after/syntax/jsx.vim new file mode 100644 index 00000000..00c4b079 --- /dev/null +++ b/after/syntax/jsx.vim @@ -0,0 +1,59 @@ +if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1) + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Vim syntax file +" +" Language: javascript.jsx +" Maintainer: MaxMellon +" +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +let s:jsx_cpo = &cpo +set cpo&vim + +syntax case match + +if exists('b:current_syntax') + let s:current_syntax = b:current_syntax + unlet b:current_syntax +endif + +if exists('s:current_syntax') + let b:current_syntax = s:current_syntax +endif + +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 +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 javaScriptBlock + \ matchgroup=javaScriptBraces + \ start="{" + \ end="}" + \ contained + \ extend + \ contains=javaScriptBlock,@javaScriptEmbededExpr,javaScript.* + \ fold + + syntax cluster javaScriptEmbededExpr add=jsxRegion,javaScript.* +endif + +runtime syntax/jsx_pretty.vim + +let b:current_syntax = 'javascript.jsx' + +let &cpo = s:jsx_cpo +unlet s:jsx_cpo + +endif diff --git a/after/syntax/reason/graphql.vim b/after/syntax/reason/graphql.vim index 44a5c846..4f4ba44c 100644 --- a/after/syntax/reason/graphql.vim +++ b/after/syntax/reason/graphql.vim @@ -32,6 +32,6 @@ if exists('s:current_syntax') let b:current_syntax = s:current_syntax endif -syntax region graphqlMultilineString matchgroup=reasonMultilineString start=+graphql\_s*\zs{|+ end=+|}+ contains=@GraphQLSyntax,reasonEscape,reasonEscapeUnicode,reasonEscapeError,reasonStringContinuation keepend +syntax region graphqlExtensionPoint matchgroup=Noise start=+\[%graphql\_s*{|+lc=10 end=+|}\_s*]+he=s+1 contains=@GraphQLSyntax keepend endif -- cgit v1.2.3