From 7702a2b1e30118471b00f7ba4ca4f47450c54ebb Mon Sep 17 00:00:00 2001 From: Christopher Moeller Date: Sat, 25 Mar 2017 10:10:38 -0500 Subject: [PATCH] Add note to README regarding vim-jsx plugin (#1085) --- README.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4bc2ab244..cd59e9f13 100644 --- a/README.md +++ b/README.md @@ -259,7 +259,7 @@ Emacs users should see [this folder](https://github.com/jlongster/prettier/tree/master/editors/emacs) for on-demand formatting. -### Vim +### Vim For Vim users there are two main approaches, one that leans on [sbdchd](https://github.com/sbdchd)/[neoformat](https://github.com/sbdchd/neoformat), which has the advantage of leaving the cursor in the same position despite changes, or a vanilla approach which can only approximate the cursor location, but might be good enough for your needs. @@ -271,6 +271,14 @@ Vim users can add the following to their `.vimrc`: autocmd FileType javascript set formatprg=prettier\ --stdin ``` +If you use the [vim-jsx](https://github.com/mxw/vim-jsx) plugin without +requiring the `.jsx` file extension (See https://github.com/mxw/vim-jsx#usage), +the FileType needs to include `javascript.jsx`: + +```vim +autocmd FileType javascript.jsx,javascript setlocal formatprg=prettier\ --stdin +``` + This makes Prettier power the [`gq` command](http://vimdoc.sourceforge.net/htmldoc/change.html#gq) for automatic formatting without any plugins. You can also add the following to your `.vimrc` to run prettier when `.js` files are saved: @@ -360,7 +368,7 @@ All of JSX and Flow syntax is supported. In fact, the test suite in - [`prettier-eslint`](https://github.com/prettier/prettier-eslint) passes `prettier` output to `eslint --fix` - [`prettier-standard`](https://github.com/sheerun/prettier-standard) -uses `prettier` and `prettier-eslint` to format code with standard rules +uses `prettier` and `prettier-eslint` to format code with standard rules - [`prettier-standard-formatter`](https://github.com/dtinth/prettier-standard-formatter) passes `prettier` output to `standard --fix` - [`prettier-with-tabs`](https://github.com/arijs/prettier-with-tabs)