diff options
| author | Mitermayer Reis <mitermayer.reis@gmail.com> | 2019-09-13 22:43:44 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-13 22:43:44 -0700 |
| commit | 9c216df3a57d35dc90222473a3438697624c9a4f (patch) | |
| tree | e802daed1eaf09f6e847d57eb5ebadd5cb86e23a | |
| parent | 2bc93788e5a48e25ba6ed8f8a46e05cbd65489f3 (diff) | |
| parent | 322018fdeb5c5a5d3f2a68612d86b35fee22f7ea (diff) | |
| download | vim-prettier-9c216df3a57d35dc90222473a3438697624c9a4f.tar.xz | |
Merge pull request #208 from prettier/making-auto-format-disabled-by-default
making-auto-format-disabled-by-default - Making autoformat disabled by
| -rw-r--r-- | README.md | 13 | ||||
| -rw-r--r-- | doc/prettier.txt | 11 | ||||
| -rw-r--r-- | plugin/prettier.vim | 4 |
3 files changed, 11 insertions, 17 deletions
@@ -15,7 +15,7 @@ By default it will auto format **javascript**, **typescript**, **less**, **scss**, **css**, **json**, **graphql** and **markdown** files if they have/support the "@format" pragma annotation in the header of the file. - + ### INSTALL @@ -127,10 +127,10 @@ Change the mapping to run from the default of `<Leader>p` nmap <Leader>py <Plug>(Prettier) ``` -Disable auto formatting of files that have "@format" tag +Enable auto formatting of files that have "@format" or "@prettier" tag ```vim -let g:prettier#autoformat = 0 +let g:prettier#autoformat = 1 ``` Set the prettier CLI executable path @@ -164,20 +164,18 @@ By default we auto focus on the quickfix when there are errors but can also be d let g:prettier#quickfix_auto_focus = 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 +To enable vim-prettier to auto run in files without requiring the "@format" or "@prettier" doc tag. +First ensure that `g:prettier#autoformat` is not enabled on your `vimrc` (it should be disabled by default), then update to your own custom behaviour Running before saving sync: ```vim -let g:prettier#autoformat = 0 autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html Prettier ``` Running before saving async (vim 8+): ```vim -let g:prettier#autoformat = 0 autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync ``` @@ -187,7 +185,6 @@ Running before saving, changing text or leaving insert mode: " when running at every change you may want to disable quickfix let g:prettier#quickfix_enabled = 0 -let g:prettier#autoformat = 0 autocmd BufWritePre,TextChanged,InsertLeave *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync ``` diff --git a/doc/prettier.txt b/doc/prettier.txt index 11ed194..c2b38fd 100644 --- a/doc/prettier.txt +++ b/doc/prettier.txt @@ -111,9 +111,9 @@ to prettier, this allows for faster formatting but wont preserve indentation. ============================================================================== CONFIGURATION *vim-prettier-configuration* -Disable auto formatting of files that have "@format" tag +Enable auto formatting of files that have "@format" or "@prettier" tag > - let g:prettier#autoformat = 0 + let g:prettier#autoformat = 1 < Set the prettier CLI executable path > @@ -131,24 +131,21 @@ By default we auto focus on the quickfix when there are errors but can also be d > let g:prettier#quickfix_auto_focus = 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 +To enable vim-prettier to auto run in files without requiring the "@format" or "@prettier" doc tag. +First ensure that `g:prettier#autoformat` is not enabled on your `vimrc` (it should be disabled by default), then update to your own custom behaviour Running before saving sync: > - let g:prettier#autoformat = 0 autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html Prettier < Running before saving async (vim 8+): > - let g:prettier#autoformat = 0 autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync < Running before saving, changing text or leaving insert mode: > " when running at every change you may want to disable quickfix let g:prettier#quickfix_enabled = 0 - let g:prettier#autoformat = 0 autocmd BufWritePre,TextChanged,InsertLeave *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync < Overwrite default prettier configuration diff --git a/plugin/prettier.vim b/plugin/prettier.vim index 928630b..83656d3 100644 --- a/plugin/prettier.vim +++ b/plugin/prettier.vim @@ -17,8 +17,8 @@ endif let g:loaded_prettier = 1 " => Plugin config -" autoformating enabled by default upon saving -let g:prettier#autoformat = get(g:, 'prettier#autoformat', 1) +" autoformating disabled by default upon saving +let g:prettier#autoformat = get(g:, 'prettier#autoformat', 0) " path to prettier cli let g:prettier#exec_cmd_path = get(g:, 'prettier#exec_cmd_path', 0) |
