runtime(java): Consent to HTML tags folding in Javadoc comments

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: #17216

Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Aliaksei Budavei
2025-04-28 17:58:22 +02:00
committed by Christian Brabandt
parent e3302cf2b1
commit 910bfd5d38
7 changed files with 43 additions and 16 deletions

View File

@ -1,4 +1,4 @@
*syntax.txt* For Vim version 9.1. Last change: 2025 Apr 19
*syntax.txt* For Vim version 9.1. Last change: 2025 Apr 28
VIM REFERENCE MANUAL by Bram Moolenaar
@ -2175,6 +2175,13 @@ line for any comments written in this way, and showing the contents of a first
line otherwise, with >
:let g:java_foldtext_show_first_or_second_line = 1
HTML tags in Javadoc comments can additionally be folded by following the
instructions listed under |html-folding| 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.
Trailing whitespace characters or a run of space characters before a tab
character can be marked as an error with >
:let g:java_space_errors = 1

View File

@ -3,7 +3,7 @@
" Maintainer: Aliaksei Budavei <0x000c70 AT gmail DOT com>
" Former Maintainer: Claudio Fleiner <claudio@fleiner.com>
" Repository: https://github.com/zzzyxwvut/java-vim.git
" Last Change: 2025 Mar 26
" Last Change: 2025 Apr 28
" Please check ":help java.vim" for comments on some of the options
" available.
@ -387,15 +387,30 @@ if !exists("g:java_ignore_javadoc") && (s:with_html || s:with_markdown) && g:mai
" Include HTML syntax coloring for Javadoc comments.
if s:with_html
try
if exists("g:html_syntax_folding") && !exists("g:java_consent_to_html_syntax_folding")
let s:html_syntax_folding_copy = g:html_syntax_folding
unlet g:html_syntax_folding
endif
syntax include @javaHtml syntax/html.vim
finally
unlet! b:current_syntax
if exists("s:html_syntax_folding_copy")
let g:html_syntax_folding = s:html_syntax_folding_copy
unlet s:html_syntax_folding_copy
endif
endtry
endif
" Include Markdown syntax coloring (v7.2.437) for Javadoc comments.
if s:with_markdown
try
if exists("g:html_syntax_folding") && !exists("g:java_consent_to_html_syntax_folding")
let s:html_syntax_folding_copy = g:html_syntax_folding
unlet g:html_syntax_folding
endif
syntax include @javaMarkdown syntax/markdown.vim
try
@ -413,6 +428,11 @@ if !exists("g:java_ignore_javadoc") && (s:with_html || s:with_markdown) && g:mai
finally
unlet! b:current_syntax
if exists("s:html_syntax_folding_copy")
let g:html_syntax_folding = s:html_syntax_folding_copy
unlet s:html_syntax_folding_copy
endif
if exists("s:no_support")
unlet s:no_support
unlockvar s:with_markdown

View File

@ -1,9 +1,9 @@
| +0#0000e05#a8a8a8255@1>/+0&#ffffff0@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |u|n|l|e|t|!| |g+0&#5fd7ff255|:+0&#ffffff0|j|a|v|a|_|n|o|_|t|a|b|_|s|p|a|c|e|_|e|r@1|o|r| |g|:|j|a|v|a|_|i|g|n|o|r|e|_|j+0&#ffd7d7255|a|v|a|d|o|c| +0#0000000#ffffff0
| +0#0000e05#a8a8a8255@1|/+0&#ffffff0@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |u|n|l|e|t|!| |g+0&#5fd7ff255|:+0&#ffffff0|j|a|v|a|_|n|o|_|t|r|a|i|l|_|s|p|a|c|e|_|e|r@1|o|r| +0#0000000&@20
| +0#0000e05#a8a8a8255@1|/+0&#ffffff0@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| |[|g|:|j|a|v|a|_|s|p|a|c|e|_|e|r@1|o|r|s|,|g|:|j|a|v|a|_|c|o|m@1|e|n|t|_|s|t|r|i|n|g|s|]|=|[|1+0#e000002&|,+0#0000e05&|1+0#e000002&|]+0#0000e05&| +0#0000000&
| +0#0000e05#a8a8a8255@1|/+0&#ffffff0@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| |g|:|j|a|v|a|_|i|g|n|o|r|e|_|m|a|r|k|d|o|w|n| |=| |1+0#e000002&| +0#0000000&@24
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
| +0#0000e05#a8a8a8255@1|/+0&#ffffff0@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |u|n|l|e|t|!| |g+0&#5fd7ff255|:+0&#ffffff0|j|a|v|a|_|c|o|n|s|e|n|t|_|t|o|_|h|t|m|l|_|s|y|n|t|a|x|_|f|o|l|d|i|n|g| +0#0000000&@10
| +0#0000e05#a8a8a8255@1|/+0&#ffffff0@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t|[|g|:|j|a|v|a|_|s|p|a|c|e|_|e|r@1|o|r|s|,|g|:|j|a|v|a|_|c|o|m@1|e|n|t|_|s|t|r|i|n|g|s|]|=|[|1+0#e000002&|,+0#0000e05&|1+0#e000002&|]+0#0000e05&| +0#0000000&@1
| +0#0000e05#a8a8a8255@1|/+0&#ffffff0@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t|[|g|:|j|a|v|a|_|i|g|n|o|r|e|_|m|a|r|k|d|o|w|n|,|g|:|h|t|m|l|_|s|y|n|t|a|x|_|f|o|l|d|i|n|g|]|=|[|1+0#e000002&|,+0#0000e05&|1+0#e000002&|]+0#0000e05&
| +0&#a8a8a8255@1| +0#0000000#ffffff0@72
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72

View File

@ -2,8 +2,8 @@
| +0#0000e05#a8a8a8255@1|/+0&#ffffff0@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |u|n|l|e|t|!| |g+0&#5fd7ff255|:+0&#ffffff0|j|a|v|a|_|n|o|_|t|r|a|i|l|_|s|p|a|c|e|_|e|r@1|o|r| +0#0000000&@20
| +0#0000e05#a8a8a8255@1|/+0&#ffffff0@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t|[|g|:|j|a|v|a|_|s|p|a|c|e|_|e|r@1|o|r|s|,|g|:|j|a|v|a|_|c|o|m@1|e|n|t|_|s|t|r|i|n|g|s|]|=|[|1+0#e000002&|,+0#0000e05&|1+0#e000002&|]+0#0000e05&| +0#0000000&@1
| +0#0000e05#a8a8a8255@1|/+0&#ffffff0@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t|[|g|:|j|a|v|a|_|i|g|n|o|r|e|_|h|t|m|l|,|g|:|m|a|r|k|d|o|w|n|_|s|y|n|t|a|x|_|c|o|n|c|e|a|l|]|=|[|1+0#e000002&|,+0#0000e05&|1+0#e000002&|]+0#0000e05&
| +0&#a8a8a8255@1| +0#0000000#ffffff0@72
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
| +0&#a8a8a8255@1|/+0&#ffffff0@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| |g|:|h|t|m|l|_|s|y|n|t|a|x|_|f|o|l|d|i|n|g| |=| |1+0#e000002&| +0#0000000&@25
| +0#0000e05#a8a8a8255@1|/+0&#ffffff0@1| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| |g|:|j|a|v|a|_|c|o|n|s|e|n|t|_|t|o|_|h|t|m|l|_|s|y|n|t|a|x|_|f|o|l|d|i|n|g| |=| |1+0#e000002&| +0#0000000&@9
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72

View File

@ -1,8 +1,8 @@
||+0#0000e05#a8a8a8255| | +0#e000e06#ffffff0@3|/@2| |}| +0#0000000&@63
||+0#0000e05#a8a8a8255| | +0&#ffffff0@3|/@2| +0#af5f00255&|+| +0#0000e05&|E|.|g|.| +0#0000000&@58
||+0#0000e05#a8a8a8255| | +0&#ffffff0@3|/@2| |<+0#00e0e07&|p+0#af5f00255&|r|e| +0#00e0e07&|c+0#00e0003&|l|a|s@1|=+0#00e0e07&|"+0#e000002&|s|n|i|p@1|e|t|"|>+0#00e0e07&| +0#0000000&@43
||+0#0000e05#a8a8a8255| | +0&#ffffff0@3|/@2| +0#e000e06&@3|p|u|b|l|i|c| |s|t|a|t|i|c| |v|o|i|d| |m|a|i|n|(|S|t|r|i|n|g|.@2| |a|r|g|s|)| |{| |}| +0#0000000&@18
||+0#0000e05#a8a8a8255| | +0&#ffffff0@3|/@2| |<+0#00e0e07&|/|p+0#af5f00255&|r|e|>+0#00e0e07&| +0#0000000&@58
|-+0#0000e05#a8a8a8255| | +0&#ffffff0@3|/@2| |<+0#00e0e07&|p+0#af5f00255&|r|e| +0#00e0e07&|c+0#00e0003&|l|a|s@1|=+0#00e0e07&|"+0#e000002&|s|n|i|p@1|e|t|"|>+0#00e0e07&| +0#0000000&@43
|2+0#0000e05#a8a8a8255| | +0&#ffffff0@3|/@2| +0#e000e06&@3|p|u|b|l|i|c| |s|t|a|t|i|c| |v|o|i|d| |m|a|i|n|(|S|t|r|i|n|g|.@2| |a|r|g|s|)| |{| |}| +0#0000000&@18
|2+0#0000e05#a8a8a8255| | +0&#ffffff0@3|/@2| |<+0#00e0e07&|/|p+0#af5f00255&|r|e|>+0#00e0e07&| +0#0000000&@58
||+0#0000e05#a8a8a8255| | +0&#ffffff0@3>/@2| +0#0000000&@65
||+0#0000e05#a8a8a8255| | +0&#ffffff0@3|/@2| |@+0#e000e06&|p|a|r|a|m| |a+0#00e0e07&|r|g|s| +0#0000e05&|o|p|t|i|o|n|a|l| |c+0&#ffd7d7255|o|m@1|a|n|d|e|-+0&#ffffff0|l|i|n|e| |a|r|g|u|m|e|n|t|s| +0#0000001#a8a8a8255| +0#0000000#ffffff0@19
||+0#0000e05#a8a8a8255| | +0&#ffffff0@3|/@2| |@|j+0&#ffd7d7255|l|s| +0&#ffffff0|1|2|.|1|.|4| |I|n|v|o|k|e| |`+0#e000e06&|T|e|s|t|.|m|a|i|n|`| +0#0000000&@34

View File

@ -1,8 +1,8 @@
// VIM_TEST_SETUP unlet! g:java_no_tab_space_error g:java_ignore_javadoc
// VIM_TEST_SETUP unlet! g:java_no_trail_space_error
// VIM_TEST_SETUP let [g:java_space_errors,g:java_comment_strings]=[1,1]
// VIM_TEST_SETUP let g:java_ignore_markdown = 1
// VIM_TEST_SETUP unlet! g:java_consent_to_html_syntax_folding
// VIM_TEST_SETUP let[g:java_space_errors,g:java_comment_strings]=[1,1]
// VIM_TEST_SETUP let[g:java_ignore_markdown,g:html_syntax_folding]=[1,1]

View File

@ -2,8 +2,8 @@
// VIM_TEST_SETUP unlet! g:java_no_trail_space_error
// VIM_TEST_SETUP let[g:java_space_errors,g:java_comment_strings]=[1,1]
// VIM_TEST_SETUP let[g:java_ignore_html,g:markdown_syntax_conceal]=[1,1]
// VIM_TEST_SETUP let g:html_syntax_folding = 1
// VIM_TEST_SETUP let g:java_consent_to_html_syntax_folding = 1