From 98a21684c79ffe3185ec7fcfb4c39e670de5f979 Mon Sep 17 00:00:00 2001 From: raziman Date: Tue, 23 Jan 2024 15:22:34 +0800 Subject: [PATCH] fix: prettier auto format even the file is not valid files --- autoload/prettier.vim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/autoload/prettier.vim b/autoload/prettier.vim index 5645dc5..5d85dea 100644 --- a/autoload/prettier.vim +++ b/autoload/prettier.vim @@ -80,8 +80,11 @@ function! prettier#Prettier(...) abort let l:endSelection = line('$') endif - " format buffer - call prettier#job#runner#run(l:cmd, l:startSelection, l:endSelection, l:async) + " only format files with extension js, jsx, ts, tsx + if expand('%:e') =~ '\v^js$|^jsx$|^ts$|^tsx$' + " format buffer + call prettier#job#runner#run(l:cmd, l:startSelection, l:endSelection, l:async) + endif else call prettier#logging#error#log('EXECUTABLE_NOT_FOUND_ERROR') endif