diff --git a/.gitignore b/.gitignore index 065e568..e43e496 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ TODO +doc/tags node_modules .yarn_lock yarn.lock diff --git a/doc/prettier.txt b/doc/prettier.txt index 2bd3fc8..0a8dc30 100644 --- a/doc/prettier.txt +++ b/doc/prettier.txt @@ -182,6 +182,9 @@ However they can be configured by: " always|never|preserve " default: 'preserve' let g:prettier#config#prose_wrap = 'preserve' + + " css|strict|ignore + let g:prettier#config#html_whitespace_sensitivity = 'css' < ============================================================================== REQUIREMENT(S) *vim-prettier-requirements* diff --git a/ftdetect/javascript.vim b/ftdetect/javascript.vim index fc6b326..03b5ac6 100644 --- a/ftdetect/javascript.vim +++ b/ftdetect/javascript.vim @@ -1,3 +1,3 @@ augroup PrettierFileDetect - autocmd BufNewFile,BufReadPost *.js setfiletype javascript + autocmd BufNewFile,BufReadPost *.js,*jsx setfiletype javascript augroup end diff --git a/ftdetect/typescript.vim b/ftdetect/typescript.vim index 501b75b..1bd86e3 100644 --- a/ftdetect/typescript.vim +++ b/ftdetect/typescript.vim @@ -1,3 +1,3 @@ augroup PrettierFileDetect - autocmd BufNewFile,BufReadPost *.ts setfiletype typescript + autocmd BufNewFile,BufReadPost *.ts,*.tsx setfiletype typescript augroup end diff --git a/ftplugin/html.vim b/ftplugin/html.vim new file mode 100644 index 0000000..76ad0af --- /dev/null +++ b/ftplugin/html.vim @@ -0,0 +1,14 @@ +" markdown files run this as well +" https://stackoverflow.com/questions/22839269/why-does-vim-default-markdown-ftplugin-source-html-ftplugins-is-there-any-ways +if &ft !~# 'markdown' + let b:prettier_ft_default_args = { + \ 'parser': 'html', + \ } +endif + +augroup Prettier + autocmd! + if g:prettier#autoformat + autocmd BufWritePre *.html call prettier#Autoformat() + endif +augroup end