From 84ef236e4f87e4a32a9e1fc8c335fb07d832f1bb Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 6 Mar 2023 12:34:23 -0700 Subject: [PATCH 1/3] chore: trim trailing whitespace --- plugin/prettier.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/prettier.vim b/plugin/prettier.vim index b85195e..d11c360 100644 --- a/plugin/prettier.vim +++ b/plugin/prettier.vim @@ -122,7 +122,7 @@ let g:prettier#config#arrow_parens = get(g:,'prettier#config#arrow_parens', 'alw " Define the flavor of line endings " lf|crlf|cr|all -" defaut: 'lf' +" defaut: 'lf' let g:prettier#config#end_of_line = get(g:, 'prettier#config#end_of_line', 'lf') " Print trailing commas wherever possible when multi-line. @@ -156,7 +156,7 @@ command! -nargs=? -range=% PrettierCliPath call prettier#PrettierCliPath() " sends selected text to prettier cli for formatting command! -nargs=? -range=% PrettierFragment call prettier#Prettier(g:prettier#exec_cmd_async, , , 0) -" sends entire buffer to prettier cli but format just selection +" sends entire buffer to prettier cli but format just selection command! -nargs=? -range=% PrettierPartial call prettier#Prettier(g:prettier#exec_cmd_async, , , 1) " map command From 246edfcf13a45fc415828bb304d5f2535c851c82 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 6 Mar 2023 12:35:03 -0700 Subject: [PATCH 2/3] feat: detect js by shebang --- ftdetect/javascript.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/ftdetect/javascript.vim b/ftdetect/javascript.vim index 03b5ac6..b74a2c3 100644 --- a/ftdetect/javascript.vim +++ b/ftdetect/javascript.vim @@ -1,3 +1,4 @@ augroup PrettierFileDetect autocmd BufNewFile,BufReadPost *.js,*jsx setfiletype javascript + autocmd BufRead,BufNewFile * if getline(1) =~ '#!/.*\<\(bun\|deno\|node\|zx\)\>' | setfiletype javascript | endif augroup end From 12d522e5d26bdfdde5570aebfccd23237d7ecb12 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 6 Mar 2023 12:35:40 -0700 Subject: [PATCH 3/3] feat: also run when filetype is javascript --- plugin/prettier.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/prettier.vim b/plugin/prettier.vim index d11c360..a08256f 100644 --- a/plugin/prettier.vim +++ b/plugin/prettier.vim @@ -175,4 +175,5 @@ nnoremap (PrettierCliPath) :PrettierCliPath augroup Prettier autocmd! autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.gql,*.markdown,*.md,*.mdown,*.mkd,*.mkdn,*.mdx,*.vue,*.svelte,*.yml,*.yaml,*.html,*.php,*.rb,*.ruby,*.xml noautocmd call prettier#Autoformat() + autocmd FileType javascript,typescript noautocmd BufWritePre call prettier#Autoformat() augroup end