commit 2b2a297bf16880c67b8652ac2cdf0a244d436ca0
parent 6b006a03c4053c09e4aa00d8cd4b6e2e63a7ae90
Author: zeertzjq <zeertzjq@outlook.com>
Date: Tue, 14 Oct 2025 10:43:45 +0800
vim-patch:4e9f16d: runtime(rst): Correctly end nested comments
Previously, a comment in a directive block would incorrectly mark
all subsequent lines in the directive block as comment, because the
syn-region did not check the leading indent.
related: vim/vim#18566
https://github.com/vim/vim/commit/4e9f16dd1ef8b48d4a37fde479adde1758796871
Co-authored-by: Antony Lee <anntzer.lee@gmail.com>
Diffstat:
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/runtime/syntax/rst.vim b/runtime/syntax/rst.vim
@@ -52,7 +52,8 @@ syn cluster rstDirectives contains=rstFootnote,rstCitation,
\ rstHyperlinkTarget,rstExDirective
syn match rstExplicitMarkup '^\s*\.\.\_s'
- \ nextgroup=@rstDirectives,rstComment,rstSubstitutionDefinition
+ \ nextgroup=@rstDirectives,rstSubstitutionDefinition
+ \ contains=rstComment
" "Simple reference names are single words consisting of alphanumerics plus
" isolated (no two adjacent) internal hyphens, underscores, periods, colons
@@ -61,10 +62,10 @@ let s:ReferenceName = '[[:alnum:]]\%([-_.:+]\?[[:alnum:]]\+\)*'
syn keyword rstTodo contained FIXME TODO XXX NOTE
-execute 'syn region rstComment contained' .
- \ ' start=/.*/'
- \ ' skip=+^$+' .
- \ ' end=/^\s\@!/ contains=rstTodo'
+syn region rstComment
+ \ start='\v^\z(\s*)\.\.(\_s+[\[|_]|\_s+.*::)@!' skip=+^$+ end=/^\(\z1 \)\@!/
+ \ contains=@Spell,rstTodo
+
execute 'syn region rstFootnote contained matchgroup=rstDirective' .
\ ' start=+\[\%(\d\+\|#\%(' . s:ReferenceName . '\)\=\|\*\)\]\_s+' .