vim-patch:9.1.0555: filetype: angular ft detection is still problematic

Problem:  filetype: angular ft detection is still problematic
          (after 9.1.0551)
Solution: detect htmlangular filetype only by inspecting the content,
          do not try to determine it from a generic name like
          '*.component.html'

For the reasons mentioned here:

https://github.com/vim/vim/pull/13594#issuecomment-1834465890

related: vim/vim#15190
related: vim/vim#13594
related: vim/vim#13604

c03f631b7b

Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Christian Clason 2024-07-10 19:47:28 +02:00
parent f24dd5481b
commit afbe7736a4
2 changed files with 8 additions and 8 deletions

View File

@ -710,12 +710,13 @@ function M.haredoc(path, _)
end end
--- @type vim.filetype.mapfn --- @type vim.filetype.mapfn
function M.html(path, bufnr) function M.html(_, bufnr)
-- Test if the filename follows the Angular component template convention -- Disabled for the reasons mentioned here:
local filename = fn.fnamemodify(path, ':t') -- https://github.com/vim/vim/pull/13594#issuecomment-1834465890
if filename:find('%.component%.html$') then -- local filename = fn.fnamemodify(path, ':t')
return 'htmlangular' -- if filename:find('%.component%.html$') then
end -- return 'htmlangular'
-- end
for _, line in ipairs(getlines(bufnr, 1, 40)) do for _, line in ipairs(getlines(bufnr, 1, 40)) do
if if

View File

@ -336,8 +336,7 @@ func s:GetFilenameChecks() abort
\ 'hoon': ['file.hoon'], \ 'hoon': ['file.hoon'],
\ 'hostconf': ['/etc/host.conf', 'any/etc/host.conf'], \ 'hostconf': ['/etc/host.conf', 'any/etc/host.conf'],
\ 'hostsaccess': ['/etc/hosts.allow', '/etc/hosts.deny', 'any/etc/hosts.allow', 'any/etc/hosts.deny'], \ 'hostsaccess': ['/etc/hosts.allow', '/etc/hosts.deny', 'any/etc/hosts.allow', 'any/etc/hosts.deny'],
\ 'html': ['file.html', 'file.htm', 'file.cshtml'], \ 'html': ['file.html', 'file.htm', 'file.cshtml', 'file.component.html'],
\ 'htmlangular': ['file.component.html'],
\ 'htmlm4': ['file.html.m4'], \ 'htmlm4': ['file.html.m4'],
\ 'httest': ['file.htt', 'file.htb'], \ 'httest': ['file.htt', 'file.htb'],
\ 'hurl': ['file.hurl'], \ 'hurl': ['file.hurl'],