You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
2.0 KiB
Markdown

vim-jsx
=======
Syntax highlighting and indenting for JSX. JSX is a JavaScript syntax
transformer which translates inline XML document fragments into JavaScript
objects. It was developed by Facebook alongside [React][1].
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
Squashed 'vim/bundle/jsx/' changes from 1886ffabc..c6d0fd7d4 c6d0fd7d4 Merge pull request #61 from simonratner/feature/yajs-no-reserved bc86a24c3 Allow reserved words in jsxRegion; fixes #60 b1047b075 Merge pull request #59 from maniart/patch-1 cc7641169 Add syntax highlighting to readme code snippets 82773e7be Update README to indicate lack of folding support bfe7f1bc9 Stop accepting string literals as JSX node children 6e761f4e6 Merge pull request #44 from mike-hearn/patch-2 a146429e1 Escape file path e762712b9 Merge pull request #39 from lencioni/suffixesadd 53b4fc978 Merge pull request #40 from othree/master bebf5b834 Add Vim's default js syntax support and general naming support 0e11958e5 Add `setlocal suffixesadd+=.jsx` to ftplugin c8fc9ec2e Set multiple filetypes: javascript.jsx efb24f487 Merge pull request #24 from ingara/master faf509a8b Escape filename when sourcing config file e7784d17b Fix ext detection in syntax 6118a4d4a Enable JSX syntax/indent for .jsx files d6bb935a8 Merge pull request #12 from jbaiter/namespaces c9add7fef Add support for namespaced JSX Tags (available since React 0.11) 5b454c3a4 Merge pull request #15 from baskerville/master 400628d13 Call the search function with the wrapping flag on 3b20d44e2 Cleanup 0eeb47fb6 Merge pull request #14 from baskerville/master 042daddd0 Use the *search* function to detect the pragma 1e50d3fd1 Add option to disable requiring @jsx pragma matching 795c2a74e Look for @jsx pragma natively, rather than with grep 467353fd6 Merge pull request #8 from dchest/letter 5436b498e Tags cannot start with a digit. 465480a32 Merge pull request #6 from dchest/patch-1 d04fd5ec4 Enable JSX syntax/indent only when @jsx pragma is found 58cba8d23 Do not consider << as a start tag. 890afd41c Merge pull request #4 from golmansax/master c09f9b5c7 Fixing Pathogen link 72926560b Merge pull request #2 from justinj/matchit 69f3f3a51 Enable using '%' to jump to matching tags 005282cfa Get rid of `xhp' instances in README 5b08c8732 Use default indentation when we leave a JSX context db237b957 Remove some indentkeys; execute less code 2893c4edc Much more robust indenting 292955d8f Better indent interactions with {}\n</x> and \n/>\n</x> 1aa4c15ed Add Depends comment line to indent c4f2d5976 Initial commit: JSX syntax and indenting REVERT: 1886ffabc Squashed 'vim/bundle/jsx/' content from commit 82773e7 git-subtree-dir: vim/bundle/jsx git-subtree-split: c6d0fd7d4d9d1e26c7643d02bb9abe5db91903c8
9 years ago
```viml
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
Squashed 'vim/bundle/jsx/' changes from 1886ffabc..c6d0fd7d4 c6d0fd7d4 Merge pull request #61 from simonratner/feature/yajs-no-reserved bc86a24c3 Allow reserved words in jsxRegion; fixes #60 b1047b075 Merge pull request #59 from maniart/patch-1 cc7641169 Add syntax highlighting to readme code snippets 82773e7be Update README to indicate lack of folding support bfe7f1bc9 Stop accepting string literals as JSX node children 6e761f4e6 Merge pull request #44 from mike-hearn/patch-2 a146429e1 Escape file path e762712b9 Merge pull request #39 from lencioni/suffixesadd 53b4fc978 Merge pull request #40 from othree/master bebf5b834 Add Vim's default js syntax support and general naming support 0e11958e5 Add `setlocal suffixesadd+=.jsx` to ftplugin c8fc9ec2e Set multiple filetypes: javascript.jsx efb24f487 Merge pull request #24 from ingara/master faf509a8b Escape filename when sourcing config file e7784d17b Fix ext detection in syntax 6118a4d4a Enable JSX syntax/indent for .jsx files d6bb935a8 Merge pull request #12 from jbaiter/namespaces c9add7fef Add support for namespaced JSX Tags (available since React 0.11) 5b454c3a4 Merge pull request #15 from baskerville/master 400628d13 Call the search function with the wrapping flag on 3b20d44e2 Cleanup 0eeb47fb6 Merge pull request #14 from baskerville/master 042daddd0 Use the *search* function to detect the pragma 1e50d3fd1 Add option to disable requiring @jsx pragma matching 795c2a74e Look for @jsx pragma natively, rather than with grep 467353fd6 Merge pull request #8 from dchest/letter 5436b498e Tags cannot start with a digit. 465480a32 Merge pull request #6 from dchest/patch-1 d04fd5ec4 Enable JSX syntax/indent only when @jsx pragma is found 58cba8d23 Do not consider << as a start tag. 890afd41c Merge pull request #4 from golmansax/master c09f9b5c7 Fixing Pathogen link 72926560b Merge pull request #2 from justinj/matchit 69f3f3a51 Enable using '%' to jump to matching tags 005282cfa Get rid of `xhp' instances in README 5b08c8732 Use default indentation when we leave a JSX context db237b957 Remove some indentkeys; execute less code 2893c4edc Much more robust indenting 292955d8f Better indent interactions with {}\n</x> and \n/>\n</x> 1aa4c15ed Add Depends comment line to indent c4f2d5976 Initial commit: JSX syntax and indenting REVERT: 1886ffabc Squashed 'vim/bundle/jsx/' content from commit 82773e7 git-subtree-dir: vim/bundle/jsx git-subtree-split: c6d0fd7d4d9d1e26c7643d02bb9abe5db91903c8
9 years ago
```viml
let g:jsx_pragma_required = 1
```
to your .vimrc or somewhere in your include path.
Please note that this package does not support syntax folding, and has not been
tested with either JavaScript or XML folding enabled.
Installation
------------
### Pathogen
The recommended installation method is via [Pathogen][4]. Then simply execute
cd ~/.vim/bundle
git clone https://github.com/mxw/vim-jsx.git
### Manual Installation
If you have no `~/.vim/after` directory, you can download the tarball or zip
and copy the contents to `~/.vim`.
If you have existing `~/.vim/after` files, copy the syntax and indent files
directly into their respective destinations. If you have existing after syntax
or indent files for Javascript, you'll probably want to do something like
mkdir -p ~/.vim/after/syntax/javascript
cp path/to/vim-jsx/after/syntax/javascript.vim ~/.vim/after/syntax/javascript/javascript.vim
mkdir -p ~/.vim/after/indent/javascript
cp path/to/vim-jsx/after/indent/javascript.vim ~/.vim/after/indent/javascript/javascript.vim
[1]: http://facebook.github.io/react/ "React"
[2]: https://github.com/pangloss/vim-javascript "pangloss: vim-javascript"
[3]: https://github.com/mxw/vim-xhp "mxw: vim-xhp"
[4]: https://github.com/tpope/vim-pathogen "tpope: vim-pathogen"