Skip to content

Commit 54d1eac

Browse files
infokillerdbarnett
authored andcommitted
prettier: add other supported filetypes (html, css, etc). (google#110)
Also let js-beautify take precedence over prettier so that the behavior stays the same when users update the plugin.
1 parent 2147649 commit 54d1eac

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

autoload/codefmt/prettier.vim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515

1616
let s:plugin = maktaba#plugin#Get('codefmt')
1717

18+
" See https://prettier.io for a list of supported file types.
19+
let s:supported_filetypes = ['javascript', 'markdown', 'html', 'css', 'yaml',
20+
\ 'jsx', 'less', 'scss', 'mdx']
21+
1822

1923
""
2024
" @private
@@ -30,7 +34,7 @@ function! codefmt#prettier#GetFormatter() abort
3034
endfunction
3135

3236
function l:formatter.AppliesToBuffer() abort
33-
return &filetype is# 'javascript'
37+
return index(s:supported_filetypes, &filetype) >= 0
3438
endfunction
3539

3640
""

plugin/register.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ call s:registry.SetValidator('codefmt#EnsureFormatter')
2323

2424
" Formatters that are registered later are given more priority when deciding
2525
" what the default formatter will be for a particular file type.
26-
call s:registry.AddExtension(codefmt#jsbeautify#GetFormatter())
2726
call s:registry.AddExtension(codefmt#prettier#GetFormatter())
27+
call s:registry.AddExtension(codefmt#jsbeautify#GetFormatter())
2828
call s:registry.AddExtension(codefmt#clangformat#GetFormatter())
2929
call s:registry.AddExtension(codefmt#gofmt#GetFormatter())
3030
call s:registry.AddExtension(codefmt#dartfmt#GetFormatter())

0 commit comments

Comments
 (0)