Home

Awesome

vim-jsx-pretty

The React syntax highlighting and indenting plugin for vim. Also supports the typescript tsx file.

Features

Demo

Syntax

vim-jsx-pretty<br />(add colorful config)vim-jsx-pretty
vim-jsx-pretty colorfulvim-jsx-pretty

Auto indent

Auto indent demo

Support typescript

typescript demo

Installation

vim-plug https://github.com/junegunn/vim-plug

your ~/.vimrc:

Using Vim8's package manager

mkdir -p ~/.vim/pack/vim-jsx-pretty/start
cd $_
git clone git@github.com:MaxMEllon/vim-jsx-pretty.git

For Neovim

mkdir -p ~/.local/share/nvim/site/vim-jsx-pretty/start
cd $_
git clone git@github.com:MaxMEllon/vim-jsx-pretty.git

⚠️ Work with vim-polyglot

Since vim-polyglot has already embedded this plugin, if you have installed vim-polyglot, you don't need to install this plugin anymore. But the bugfix for this plugin may not ship in vim-polyglot in time.

If you still want to use this plugin, make sure that you put this plugin ahead of vim-polyglot, and add let g:polyglot_disabled = ['jsx'] to your vimrc.

Syntax group list

nameplace
jsxElement<tag id="sample">text</tag><br />~~~~~~~~~~~~~~~~~~~~~~~~~~~
jsxTag<tag id="sample"><br />~~~~~~~~~~~~~~~~~
jsxTagName<tag id="sample"><br />_~~~_____________
jsxComponentName<Capitals><br />_~~~~~~~~_
jsxAttrib<tag id="sample"><br />_____~~__________
jsxEqual<tag id="sample"><br />_______~_________
jsxString<tag id="sample"><br />________~~~~~~~~_
jsxCloseTag</tag><br />~~~~~~
jsxCloseString<tag /><br />_____~~
jsxDot<Parent.Child><br />_______~______
jsxNamespace<foo:bar><br />____~____
jsxPunct<tag></tag><br />~___~~~___~

Configuration

namedefaultdescription
g:vim_jsx_pretty_disable_js0Disable the syntax highlighting for js files
g:vim_jsx_pretty_disable_tsx0Disable the syntax highlighting for tsx files
g:vim_jsx_pretty_template_tags['html', 'jsx']highlight JSX inside the tagged template string, set it to [] to disable this feature
g:vim_jsx_pretty_highlight_close_tag0highlight the close tag separately from the open tag
g:vim_jsx_pretty_colorful_config0colorful config flag

Colorful style (vim-javascript only)

let g:vim_jsx_pretty_colorful_config = 1 " default 0

Inspiration

LICENSE

MIT