Is there a way to disable folding for comments with foldmethod=syntax
for Javascript files in vim?
I'm using the following folding code in my vimrc
:
if has("folding")
set foldenable
set foldopen=hor,search,tag,undo
set fillchars=diff:\ ,fold:\ ,vert:\
function! JavaScriptFold()
setl foldmethod=syntax
setl foldlevelstart=1
syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend
endfunction
endif
Calling JavaScriptFold
folds the following code:
/**
* Hello, this is a comment.
*/
function hello() {
console.log('hello');
}
into this:
+-- 3 lines: *
+-- 3 lines: function hello() {
I want it to get folded into this:
/**
* Hello, this is a comment.
*/
+-- 3 lines: function hello() {
I found out about c_no_comment_fold
via this Stack Overflow question on C comment folding, but I can't find an equivalent for Javascript. Is there a way to do this?