aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authormitermayer <mitermayer.reis@gmail.com>2017-06-07 10:45:48 -0700
committermitermayer <mitermayer.reis@gmail.com>2017-06-07 10:46:20 -0700
commitc211c98ab7118be61873d0fe9897e5986c6f6441 (patch)
treefc18e666a6f7446ca8021119f16eb28b729e4e04 /README.md
parentc28004d9c616a3599e8d0622c87fa071aa2342e8 (diff)
downloadvim-prettier-c211c98ab7118be61873d0fe9897e5986c6f6441.tar.xz
Adding async command and user configurations
- Adding configuration toggle for controlling error quick fix parsing - Adding PrettierAsync command - Fixing configuration bug where boolean values where not correctly parsed - Making sure that async jobs do not execute if already in progress
Diffstat (limited to 'README.md')
-rw-r--r--README.md49
1 files changed, 41 insertions, 8 deletions
diff --git a/README.md b/README.md
index 37fc501..0a87d7e 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ By default it will auto format **javascript**, **typescript**, **less**, **scss*
Install with [vim-plug](https://github.com/junegunn/vim-plug), assumes node and yarn|npm installed globally.
-```
+```vim
" post install (yarn install | npm install) then load plugin only for editing supported files
plug 'mitermayer/vim-prettier', {
\ 'do': 'yarn install',
@@ -33,38 +33,71 @@ vim-prettier executable resolution:
Prettier by default will run on auto save but can also be manualy triggered by:
-```
+```vim
<Leader>p
```
or
-```
+```vim
:Prettier
```
+If your are on vim 8+ you can also trigger async formatting by:
+
+```vim
+:PrettierAsync
+```
+
## Configuration
Disable auto formatting of files that have "@format" tag
-```
+```vim
let g:prettier#autoformat = 0
```
The command `:Prettier` by default is synchronous but can be forced to be async
-```
+```vim
let g:prettier#exec_cmd_async = 1
```
-Enable vim-prettier to run in files without requiring the "@format" doc tag
+By default parsing errors will open the quickfix, that behaviour can be controlled by
+
+```vim
+let g:prettier#quickfix_enabled = 0
+```
+
+To enable vim-prettier to run in files without requiring the "@format" doc tag.
+First disable the default autoformat, then update to your own custom behaviour
+
+Running before saving sync:
+```vim
+ let g:prettier#autoformat = 0
+ autocmd BufWritePre *.js,*.css,*.scss,*.less Prettier
```
- autocmd BufWritePre *.js,*.css,*.scss,*.less call prettier#Prettier()
+
+Running before saving async (vim 8+):
+
+```vim
+ let g:prettier#autoformat = 0
+ autocmd BufWritePre *.js,*.css,*.scss,*.less PrettierAsync
```
-Overwrite default configuration
+Running before saving, changing text or leaving insert mode:
+```vim
+" when running at every change you may want to disable quickfix error parsing to reduce noise
+let g:prettier#quickfix_enabled = 0
+
+let g:prettier#autoformat = 0
+autocmd BufWritePre,TextChanged,InsertLeave *.js,*.css,*.scss,*.less PrettierAsync
```
+
+Overwrite default configuration
+
+```vim
" max line lengh that prettier will wrap on
g:prettier#config#print_width = 80