vim-patch:9718ed7: runtime(filetype): update htmldjango detection

- 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: vim/vim#15037

9718ed7ab9

Co-authored-by: Afiq Nazrie <afnazrie@gmail.com>
This commit is contained in:
Christian Clason 2024-06-18 20:00:43 +02:00
parent 102971a396
commit 6012f79557

View File

@ -676,10 +676,15 @@ end
--- @type vim.filetype.mapfn --- @type vim.filetype.mapfn
function M.html(_, bufnr) function M.html(_, bufnr)
for _, line in ipairs(getlines(bufnr, 1, 10)) do for _, line in ipairs(getlines(bufnr, 1, 40)) do
if matchregex(line, [[\<DTD\s\+XHTML\s]]) then if matchregex(line, [[\<DTD\s\+XHTML\s]]) then
return 'xhtml' return 'xhtml'
elseif matchregex(line, [[\c{%\s*\(extends\|block\|load\)\>\|{#\s\+]]) then elseif
matchregex(
line,
[[\c{%\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\+]]
)
then
return 'htmldjango' return 'htmldjango'
end end
end end