Skip to content

Commit

Permalink
support javascriptreact, close #52
Browse files Browse the repository at this point in the history
  • Loading branch information
chemzqm committed Jul 2, 2020
1 parent 16efd12 commit 2c8a999
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 4 deletions.
10 changes: 8 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# vim-jsx-improve

[![](http://img.shields.io/github/issues/neoclide/vim-jsx-improve.svg)](https://github.com/neoclide/vim-jsx-improve/issues)
[![](http://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

Expand All @@ -8,8 +9,8 @@ Javascript syntax from [pangloss/vim-javascript](https://github.com/pangloss/vim

Jsx highlight and indent code changed from [MaxMEllon/vim-jsx-pretty](https://github.com/MaxMEllon/vim-jsx-pretty)

* Fixed syntax highlighting and indentation for React jsx files.
* Works well with xml.vim
- Fixed syntax highlighting and indentation for React jsx files.
- Works well with xml.vim

This plugin have no dependency, all the code you need for jsx and javascript is
included.
Expand All @@ -23,6 +24,11 @@ Use pathogen or vundle is recommended. Vundle:

Plugin 'chemzqm/vim-jsx-improve'

This plugin support `javascriptreact` filetype which is introduced on newer
version of vim8 and neovim.

Use `let g:jsx_improve_javascriptreact = 0` to disable javascriptreact support.

### Quick jump to function braces

You can use `[[` `]]` `[]` `][` to quick jump to `{` `}` position of functions, set `g:jsx_improve_motion_disable` to `1` to disable it.
Expand Down
6 changes: 6 additions & 0 deletions after/ftplugin/javascriptreact.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if !get(g:, 'jsx_improve_javascriptreact', 1)
finish
endif

let s:path = expand('<sfile>:p:h')
exec 'so ' . s:path . '/javascript.vim'
6 changes: 6 additions & 0 deletions after/indent/javascriptreact.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if !get(g:, 'jsx_improve_javascriptreact', 1)
finish
endif

let s:path = expand('<sfile>:p:h')
exec 'so ' . s:path . '/javascript.vim'
4 changes: 2 additions & 2 deletions after/syntax/javascript.vim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" disable on vue or html like files
if index(['javascript', 'javascript.jsx'], &ft) == -1 | finish | endif
if index(['javascript.jsx', 'javascriptreact'], &ft) == -1 | finish | endif

let s:jsx_cpo = &cpo
set cpo&vim
Expand Down Expand Up @@ -97,7 +97,7 @@ syntax match jsxEndComponentName
" <tag key={this.props.key}>
" ~~~
syntax match jsxAttrib
\ +[-'"<]\@<!\<[a-zA-Z:_][-.0-9a-zA-Z0-9:_]*\>\(['">]\@!\|\>\|$\)+
\ +[-'"<]\@<!\<[a-zA-Z:_][-.0-9a-zA-Z0-9:_]*\>\(['">]\@!\|>\|$\)+
\ contained
\ contains=jsxAttribPunct,jsxAttribHook
\ display
Expand Down
6 changes: 6 additions & 0 deletions after/syntax/javascriptreact.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if !get(g:, 'jsx_improve_javascriptreact', 1)
finish
endif

let s:path = expand('<sfile>:p:h')
exec 'so ' . s:path . '/javascript.vim'
6 changes: 6 additions & 0 deletions syntax/javascriptreact.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if exists("b:current_syntax") || !get(g:, 'jsx_improve_javascriptreact', 1)
finish
endif

let s:path = expand('<sfile>:p:h')
exec 'so ' . s:path . '/javascript.vim'

0 comments on commit 2c8a999

Please sign in to comment.