]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(filetype): update htmldjango detection
authorAfiq Nazrie <afnazrie@gmail.com>
Tue, 18 Jun 2024 17:59:53 +0000 (19:59 +0200)
committerChristian Brabandt <cb@256bit.org>
Tue, 18 Jun 2024 17:59:53 +0000 (19:59 +0200)
- update tags to detect djangohtml based on
  https://docs.djangoproject.com/en/5.0/ref/templates/builtins/#built-in-tag-reference

- increase the lines to inspect to 40 lines

  10 lines is too few and might result in high false negative.
  Increasing it to 40 lines should reduce the false negative.

closes: #15037

Signed-off-by: Afiq Nazrie <afnazrie@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/autoload/dist/ft.vim

index bf9e32e7831abb7abb6c8ab981e56816d107c759..50b4c3ef2102af17f58e7c9c6a904bcd33753081 100644 (file)
@@ -405,12 +405,12 @@ enddef
 # Distinguish between HTML, XHTML and Django
 export def FThtml()
   var n = 1
-  while n < 10 && n <= line("$")
+  while n < 40 && n <= line("$")
     if getline(n) =~ '\<DTD\s\+XHTML\s'
       setf xhtml
       return
     endif
-    if getline(n) =~ '{%\s*\(extends\|block\|load\)\>\|{#\s\+'
+    if getline(n) =~ '{%\s*\(autoescape\|block\|comment\|csrf_token\|cycle\|debug\|extends\|filter\|firstof\|for\|if\|ifchanged\|include\|load\|lorem\|now\|query_string\|regroup\|resetcycle\|spaceless\|templatetag\|url\|verbatim\|widthratio\|with\)\>\|{#\s\+'
       setf htmldjango
       return
     endif