aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorMitermayer Reis <mitermayer.reis@gmail.com>2019-09-13 14:56:12 -0700
committerGitHub <noreply@github.com>2019-09-13 14:56:12 -0700
commite98b108ded5c906dde32db2f9856184e00dfc945 (patch)
tree2bb00ea13832cd22f23566250ece8c93954a852e /plugin
parent758415cc88bbe7144964ef3ad770acd400567e55 (diff)
parent3dc6684302ff2749570d938e1d49862db0e2648c (diff)
downloadvim-prettier-e98b108ded5c906dde32db2f9856184e00dfc945.tar.xz
Merge pull request #206 from prettier/issues/184-fixing-undo-step
Adding support for require-pragma and depracting previous naive implemenation
Diffstat (limited to 'plugin')
-rw-r--r--plugin/prettier.vim10
1 files changed, 10 insertions, 0 deletions
diff --git a/plugin/prettier.vim b/plugin/prettier.vim
index 19b4002..aafa7a2 100644
--- a/plugin/prettier.vim
+++ b/plugin/prettier.vim
@@ -97,6 +97,9 @@ let g:prettier#config#arrow_parens = get(g:,'prettier#config#arrow_parens', 'avo
" default: 'none'
let g:prettier#config#trailing_comma = get(g:,'prettier#config#trailing_comma', 'none')
+" restrict itself to only format files that contain a special comment @prettier or @format
+let g:prettier#config#require_pragma= get(g:, 'prettier#config#require_pragma', 'false')
+
" synchronous by default
command! -nargs=? -range=% Prettier call prettier#Prettier(g:prettier#exec_cmd_async, <line1>, <line2>, g:prettier#partial_format)
@@ -133,3 +136,10 @@ nnoremap <silent> <Plug>(PrettierVersion) :PrettierVersion<CR>
nnoremap <silent> <Plug>(PrettierCli) :PrettierCli<CR>
nnoremap <silent> <Plug>(PrettierCliVersion) :PrettierCliVersion<CR>
nnoremap <silent> <Plug>(PrettierCliPath) :PrettierCliPath<CR>
+
+augroup Prettier
+ autocmd!
+ if g:prettier#autoformat
+ autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html call prettier#Autoformat()
+ endif
+augroup end