Skip to content

Commit

Permalink
Squashed 'home/.vim/bundle/vim-jsx/' changes from d6bb935..efb24f4
Browse files Browse the repository at this point in the history
efb24f4 Merge pull request #24 from ingara/master
faf509a Escape filename when sourcing config file
e7784d1 Fix ext detection in syntax
6118a4d Enable JSX syntax/indent for .jsx files

git-subtree-dir: home/.vim/bundle/vim-jsx
git-subtree-split: efb24f487f4a61f9113fa4b2b64fe3ab5a030500
  • Loading branch information
avdgaag committed Feb 26, 2015
1 parent 176d67b commit 1e5cbd4
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 8 deletions.
15 changes: 15 additions & 0 deletions README.md
Expand Up @@ -10,6 +10,21 @@ This bundle requires pangloss's [vim-javascript][2] syntax highlighting.
Vim support for inline XML in JS is remarkably similar to the same for PHP,
which you can find [here][3].

Usage
-----

By default, JSX syntax highlighting and indenting will be enabled only for
files with the `.jsx` extension. If you would like JSX in `.js` files, add

let g:jsx_ext_required = 0

to your .vimrc or somewhere in your include path. If you wish to restrict JSX
to files with the pre-v0.12 `@jsx React.DOM` pragma, add

let g:jsx_pragma_required = 1

to your .vimrc or somewhere in your include path.

Installation
------------

Expand Down
10 changes: 10 additions & 0 deletions after/ftdetect/javascript.vim
@@ -0,0 +1,10 @@
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vim ftdetect file
"
" Language: JSX (JavaScript)
" Maintainer: Max Wang <mxawng@gmail.com>
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

autocmd BufNewFile,BufRead *.jsx let b:jsx_ext_found = 1
autocmd BufNewFile,BufRead *.jsx set filetype=javascript
7 changes: 5 additions & 2 deletions after/indent/javascript.vim
Expand Up @@ -7,10 +7,13 @@
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" Do nothing if we don't find the @jsx pragma.
exec 'source '.expand('<sfile>:p:h:h').'/jsx-pragma.vim'
" Do nothing if we don't find the @jsx pragma (and we care).
exec 'source '.fnameescape(expand('<sfile>:p:h:h').'/jsx-config.vim')
if g:jsx_pragma_required && !b:jsx_pragma_found | finish | endif

" Do nothing if we don't have the .jsx extension (and we care).
if g:jsx_ext_required && !exists('b:jsx_ext_found') | finish | endif

" Prologue; load in XML indentation.
if exists('b:did_indent')
let s:did_indent=b:did_indent
Expand Down
15 changes: 11 additions & 4 deletions after/jsx-pragma.vim → after/jsx-config.vim
@@ -1,8 +1,10 @@
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vimscript file
"
" Check whether or not the @jsx pragma is correctly included in '%'.
" Set the result in b:jsx_pragma_found.
" Set up a bunch of configuration variables.
"
" Also check (if desired) whether or not the @jsx pragma is correctly included
" in '%'. Set the result in b:jsx_pragma_found.
"
" Language: JSX (JavaScript)
" Maintainer: Max Wang <mxawng@gmail.com>
Expand All @@ -14,9 +16,14 @@ if exists('b:jsx_pragma_found')
finish
endif

" Whether the .jsx extension is required to enable JSX syntax/indent.
if !exists('g:jsx_ext_required')
let g:jsx_ext_required = 1
endif

" Whether the @jsx pragma is required to enable JSX syntax/indent.
if !exists("g:jsx_pragma_required")
let g:jsx_pragma_required = 1
if !exists('g:jsx_pragma_required')
let g:jsx_pragma_required = 0
endif
if !g:jsx_pragma_required | finish | endif

Expand Down
7 changes: 5 additions & 2 deletions after/syntax/javascript.vim
Expand Up @@ -9,10 +9,13 @@
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" Do nothing if we don't find the @jsx pragma.
exec 'source '.expand('<sfile>:p:h:h').'/jsx-pragma.vim'
" Do nothing if we don't find the @jsx pragma (and we care).
exec 'source '.fnameescape(expand('<sfile>:p:h:h').'/jsx-config.vim')
if g:jsx_pragma_required && !b:jsx_pragma_found | finish | endif

" Do nothing if we don't have the .jsx extension (and we care).
if g:jsx_ext_required && !exists('b:jsx_ext_found') | finish | endif

" Prologue; load in XML syntax.
if exists('b:current_syntax')
let s:current_syntax=b:current_syntax
Expand Down

0 comments on commit 1e5cbd4

Please sign in to comment.