diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index 45244af64c..16c3c43446 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -908,9 +908,13 @@ function M.ll(_, bufnr) local first_line = getline(bufnr, 1) if matchregex(first_line, [[;\|\\|\]]) 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 diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim index 760afc2e85..81dcb9a570 100644 --- a/test/old/testdir/test_filetype.vim +++ b/test/old/testdir/test_filetype.vim @@ -2600,6 +2600,12 @@ func Test_ll_file() call assert_equal('llvm', &filetype) bwipe! + " lex (C++) + call writefile(['%{', '#include ', '%}'], 'Xfile.ll', 'D') + split Xfile.ll + call assert_equal('lex', &filetype) + bwipe! + " lifelines call writefile(['proc main() {}'], 'Xfile.ll', 'D') split Xfile.ll