runtime(java): Consent to HTML tags folding in Javadoc comments Commit: https://github.com/vim/vim/commit/910bfd5d38812079bf31cc91eb6978415f29b725 Author: Aliaksei Budavei <0x000...@gmail.com> Date: Mon Apr 28 17:58:22 2025 +0200
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 <0x000...@gmail.com> Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index a8fbe1a85..ed7283012 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -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 diff --git a/runtime/syntax/java.vim b/runtime/syntax/java.vim index 8dabc5e3d..37b99b736 100644 --- a/runtime/syntax/java.vim +++ b/runtime/syntax/java.vim @@ -3,7 +3,7 @@ " Maintainer: Aliaksei Budavei <0x000c70 AT gmail DOT com> " Former Maintainer: Claudio Fleiner <clau...@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 diff --git a/runtime/syntax/testdir/dumps/java_comments_html_00.dump b/runtime/syntax/testdir/dumps/java_comments_html_00.dump index be353893d..50c110924 100644 --- a/runtime/syntax/testdir/dumps/java_comments_html_00.dump +++ b/runtime/syntax/testdir/dumps/java_comments_html_00.dump @@ -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+0fd7ff255|:+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+0fd7ff255|:+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+0fd7ff255|:+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 diff --git a/runtime/syntax/testdir/dumps/java_comments_markdown_00.dump b/runtime/syntax/testdir/dumps/java_comments_markdown_00.dump index baf8f3893..2fe656fcd 100644 --- a/runtime/syntax/testdir/dumps/java_comments_markdown_00.dump +++ b/runtime/syntax/testdir/dumps/java_comments_markdown_00.dump @@ -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+0fd7ff255|:+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 diff --git a/runtime/syntax/testdir/dumps/java_comments_markdown_07.dump b/runtime/syntax/testdir/dumps/java_comments_markdown_07.dump index c6471d6d2..69a27aefa 100644 --- a/runtime/syntax/testdir/dumps/java_comments_markdown_07.dump +++ b/runtime/syntax/testdir/dumps/java_comments_markdown_07.dump @@ -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 diff --git a/runtime/syntax/testdir/input/java_comments_html.java b/runtime/syntax/testdir/input/java_comments_html.java index eeffef5b7..15d4a2fad 100644 --- a/runtime/syntax/testdir/input/java_comments_html.java +++ b/runtime/syntax/testdir/input/java_comments_html.java @@ -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] diff --git a/runtime/syntax/testdir/input/java_comments_markdown.java b/runtime/syntax/testdir/input/java_comments_markdown.java index fa369719d..a34af8f39 100644 --- a/runtime/syntax/testdir/input/java_comments_markdown.java +++ b/runtime/syntax/testdir/input/java_comments_markdown.java @@ -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 -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1u9Qtt-00DKt3-G7%40256bit.org.