From 56f23c54a685aa377ee244421582d0f07d76d7c6 Mon Sep 17 00:00:00 2001 From: Alexandru Geana Date: Sat, 27 Mar 2021 15:18:37 +0100 Subject: [PATCH] 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\.`. --- autoload/codefmt/jsbeautify.vim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/autoload/codefmt/jsbeautify.vim b/autoload/codefmt/jsbeautify.vim index f7f706c..a96cef5 100644 --- a/autoload/codefmt/jsbeautify.vim +++ b/autoload/codefmt/jsbeautify.vim @@ -30,7 +30,8 @@ function! codefmt#jsbeautify#GetFormatter() abort endfunction function l:formatter.AppliesToBuffer() abort - return &filetype is# 'css' || &filetype is# 'html' || &filetype is# 'json' || + return &filetype is# 'css' || &filetype is# 'html' || + \ &filetype =~# '\mhtml\.' || &filetype is# 'json' || \ &filetype is# 'javascript' endfunction @@ -45,6 +46,8 @@ function! codefmt#jsbeautify#GetFormatter() abort let l:cmd = l:cmd + ['--type', 'js'] elseif &filetype is# 'sass' || &filetype is# 'scss' || &filetype is# 'less' let l:cmd = l:cmd + ['--type', 'css'] + elseif &filetype =~# '\mhtml\.' + let l:cmd = l:cmd + ['--type', 'html'] elseif &filetype != "" let l:cmd = l:cmd + ['--type', &filetype] endif