diff options
| author | mitermayer <mitermayer.reis@gmail.com> | 2017-06-07 10:45:48 -0700 |
|---|---|---|
| committer | mitermayer <mitermayer.reis@gmail.com> | 2017-06-07 10:46:20 -0700 |
| commit | c211c98ab7118be61873d0fe9897e5986c6f6441 (patch) | |
| tree | fc18e666a6f7446ca8021119f16eb28b729e4e04 /README.md | |
| parent | c28004d9c616a3599e8d0622c87fa071aa2342e8 (diff) | |
| download | vim-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.md | 49 |
1 files changed, 41 insertions, 8 deletions
@@ -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 |
