Skip to content

Commit 0ab0cdb

Browse files
zeertzjqzzzyxwvut
andauthored
vim-patch:910bfd5: runtime(java): Consent to HTML tags folding in Javadoc comments (#33718)
HTML tags in Javadoc comments can additionally be folded after applying ------------------------------------------------------------ let g:html_syntax_folding = 1 set foldmethod=syntax ------------------------------------------------------------ and giving explicit consent with ------------------------------------------------------------ let g:java_consent_to_html_syntax_folding = 1 ------------------------------------------------------------ Do not default to this kind of folding unless ALL start tags and optional end tags are balanced in Javadoc comments; otherwise, put up with creating runaway folds that break syntax highlighting. resolves: zzzyxwvut/java-vim#8. closes: vim/vim#17216 vim/vim@910bfd5 Co-authored-by: Aliaksei Budavei <0x000c70@gmail.com>
1 parent 99e754a commit 0ab0cdb

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

runtime/doc/syntax.txt

+7
Original file line numberDiff line numberDiff line change
@@ -1689,6 +1689,13 @@ line for any comments written in this way, and showing the contents of a first
16891689
line otherwise, with >
16901690
:let g:java_foldtext_show_first_or_second_line = 1
16911691
1692+
HTML tags in Javadoc comments can additionally be folded by following the
1693+
instructions listed under |html-folding| and giving explicit consent with >
1694+
:let g:java_consent_to_html_syntax_folding = 1
1695+
Do not default to this kind of folding unless ALL start tags and optional end
1696+
tags are balanced in Javadoc comments; otherwise, put up with creating runaway
1697+
folds that break syntax highlighting.
1698+
16921699
Trailing whitespace characters or a run of space characters before a tab
16931700
character can be marked as an error with >
16941701
:let g:java_space_errors = 1

runtime/syntax/java.vim

+21-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" Maintainer: Aliaksei Budavei <0x000c70 AT gmail DOT com>
44
" Former Maintainer: Claudio Fleiner <claudio@fleiner.com>
55
" Repository: https://github.com/zzzyxwvut/java-vim.git
6-
" Last Change: 2025 Mar 26
6+
" Last Change: 2025 Apr 28
77

88
" Please check ":help java.vim" for comments on some of the options
99
" available.
@@ -387,15 +387,30 @@ if !exists("g:java_ignore_javadoc") && (s:with_html || s:with_markdown) && g:mai
387387
" Include HTML syntax coloring for Javadoc comments.
388388
if s:with_html
389389
try
390+
if exists("g:html_syntax_folding") && !exists("g:java_consent_to_html_syntax_folding")
391+
let s:html_syntax_folding_copy = g:html_syntax_folding
392+
unlet g:html_syntax_folding
393+
endif
394+
390395
syntax include @javaHtml syntax/html.vim
391396
finally
392397
unlet! b:current_syntax
398+
399+
if exists("s:html_syntax_folding_copy")
400+
let g:html_syntax_folding = s:html_syntax_folding_copy
401+
unlet s:html_syntax_folding_copy
402+
endif
393403
endtry
394404
endif
395405

396406
" Include Markdown syntax coloring (v7.2.437) for Javadoc comments.
397407
if s:with_markdown
398408
try
409+
if exists("g:html_syntax_folding") && !exists("g:java_consent_to_html_syntax_folding")
410+
let s:html_syntax_folding_copy = g:html_syntax_folding
411+
unlet g:html_syntax_folding
412+
endif
413+
399414
syntax include @javaMarkdown syntax/markdown.vim
400415

401416
try
@@ -413,6 +428,11 @@ if !exists("g:java_ignore_javadoc") && (s:with_html || s:with_markdown) && g:mai
413428
finally
414429
unlet! b:current_syntax
415430

431+
if exists("s:html_syntax_folding_copy")
432+
let g:html_syntax_folding = s:html_syntax_folding_copy
433+
unlet s:html_syntax_folding_copy
434+
endif
435+
416436
if exists("s:no_support")
417437
unlet s:no_support
418438
unlockvar s:with_markdown

0 commit comments

Comments
 (0)