Skip to content
This repository was archived by the owner on Jun 20, 2024. It is now read-only.

Commit 048baf8

Browse files
Alexandru Geanadbarnett
authored andcommitted
js-beautify support for mustache and handlebars
The `mustache/vim-mustache-handlebars` plugin sets the filetype to either `html.handlebars` or `html.mustache`. Even though js-beautify supports formatting for these files, the `--type` parameter must be `html`. This commit sets the `--type` parameter to `html` when the filetype either is `html` or matches the regex `\mhtml\.`.
1 parent 03d35f1 commit 048baf8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

autoload/codefmt/jsbeautify.vim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ function! codefmt#jsbeautify#GetFormatter() abort
3030
endfunction
3131

3232
function l:formatter.AppliesToBuffer() abort
33-
return &filetype is# 'css' || &filetype is# 'html' || &filetype is# 'json' ||
33+
return &filetype is# 'css' || &filetype is# 'html' ||
34+
\ &filetype =~# '\mhtml\.' || &filetype is# 'json' ||
3435
\ &filetype is# 'javascript'
3536
endfunction
3637

@@ -45,6 +46,8 @@ function! codefmt#jsbeautify#GetFormatter() abort
4546
let l:cmd = l:cmd + ['--type', 'js']
4647
elseif &filetype is# 'sass' || &filetype is# 'scss' || &filetype is# 'less'
4748
let l:cmd = l:cmd + ['--type', 'css']
49+
elseif &filetype =~# '\mhtml\.'
50+
let l:cmd = l:cmd + ['--type', 'html']
4851
elseif &filetype != ""
4952
let l:cmd = l:cmd + ['--type', &filetype]
5053
endif

0 commit comments

Comments
 (0)