]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(htmldjango): Add syntax highlighting of comparison operators
authortecis <67809811+tecis@users.noreply.github.com>
Sun, 17 May 2026 08:44:39 +0000 (08:44 +0000)
committerChristian Brabandt <cb@256bit.org>
Sun, 17 May 2026 08:44:39 +0000 (08:44 +0000)
The presence `djangoOperators` in the file `syntax/django.vim` and
having the highlight function with a `match` statement leads to a
highlight spill-over with other elements defined in `syntax/html.vim`.
To avoid the highlight spill-over declare a region called
`djangoTagBlockNaive` to limit `djangoOperator` to only be matched
within.

related: #20225
closes:  #20232

Signed-off-by: tecis <67809811+tecis@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/syntax/htmldjango.vim

index 07b1c375e8652111c6cbddd16578216a0d533128..bffb11aa6444e2e1547b39d0d95135a4067c7bec 100644 (file)
@@ -2,6 +2,7 @@
 " Language:    Django HTML template
 " Maintainer:  Dave Hodder <dmh@dmh.org.uk>
 " Last Change: 2014 Jul 13
+" 2026 May 17 by Vim Project Add highlighting for comparison operators #20232
 
 " quit when a syntax file was already loaded
 if exists("b:current_syntax")
@@ -23,4 +24,8 @@ syn region djangoVarBlock start="{{" end="}}" contains=djangoFilter,djangoArgume
 syn region djangoComment start="{%\s*comment\(\s\+.\{-}\)\?%}" end="{%\s*endcomment\s*%}" contains=djangoTodo containedin=ALLBUT,@djangoBlocks
 syn region djangoComBlock start="{#" end="#}" contains=djangoTodo containedin=ALLBUT,@djangoBlocks
 
+" Use djangoTagBlockNaive to limit the djangoOperator matched characters to avoid spill-over with HTML, JS and CSS.
+syn region djangoTagBlockNaive start="{%" end="%}" contains=djangoTagBlock,djangoVarBlock,djangoComment,djangoComBlock
+syn match djangoOperator "==\|!=\|<=\|>=\|<\|>" contained containedin=CONTAINS,@djangoTagBlockNaive
+
 let b:current_syntax = "htmldjango"