vim-patch:9.1.1466: filetype: not all lex files are recognized

Problem:  filetype: not all lex files are recognized
Solution: detect *.ll as lex, llvm or lifelines filetype, depending on
          the content (Eisuke Kawashima)

closes: vim/vim#17560

48295111e5

Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
This commit is contained in:
Eisuke Kawashima
2025-06-18 19:21:16 +09:00
committed by Christian Clason
parent 32f30c4874
commit 5cf135f9a0
2 changed files with 12 additions and 2 deletions

View File

@ -908,9 +908,13 @@ function M.ll(_, bufnr)
local first_line = getline(bufnr, 1)
if matchregex(first_line, [[;\|\<source_filename\>\|\<target\>]]) then
return 'llvm'
else
return 'lifelines'
end
for _, line in ipairs(getlines(bufnr, 1, 100)) do
if line:find('^%s*%%') then
return 'lex'
end
end
return 'lifelines'
end
--- @type vim.filetype.mapfn

View File

@ -2600,6 +2600,12 @@ func Test_ll_file()
call assert_equal('llvm', &filetype)
bwipe!
" lex (C++)
call writefile(['%{', '#include <iostream>', '%}'], 'Xfile.ll', 'D')
split Xfile.ll
call assert_equal('lex', &filetype)
bwipe!
" lifelines
call writefile(['proc main() {}'], 'Xfile.ll', 'D')
split Xfile.ll