diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index 79cc6651c4..49739dba4f 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -936,10 +936,10 @@ function M.inc(path, bufnr) elseif findany(line, { '^%s{', '^%s%(%*' }) or matchregex(line, pascal_keywords) then return 'pascal' elseif - matchregex(line, [[\<\%(require\|inherit\)\>]]) + matchregex(line, [[^\s*\<\%(require\|inherit\)\>]]) or matchregex( line, - [=[[A-Z][A-Za-z0-9_:${}/]*\(\[[A-Za-z0-9_:/]\+\]\)*\s\+\%(??\|[?:+.]\)\?=.\? ]=] + [=[^\s*[A-Z][A-Za-z0-9_:${}/]*\%(\[[A-Za-z0-9_:/]\+\]\)*\s\+\%(??=\|[?:+.]=\|=[+.]\?\)\s\+]=] ) then return 'bitbake' diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim index c84c9c4b88..fa4d96247a 100644 --- a/test/old/testdir/test_filetype.vim +++ b/test/old/testdir/test_filetype.vim @@ -2817,11 +2817,17 @@ endfunc func Test_inc_file() filetype on + " pov call writefile(['this is the fallback'], 'Xfile.inc', 'D') split Xfile.inc call assert_equal('pov', &filetype) bwipe! + call writefile(['!Comment with formular a = b/c'], 'Xfile.inc') + split Xfile.inc + call assert_equal('pov', &filetype) + bwipe! + " ObjectScript routine call writefile(['ROUTINE Sample [Type=INC]'], 'Xfile.inc', 'D') split Xfile.inc @@ -2874,6 +2880,11 @@ func Test_inc_file() call assert_equal('bitbake', &filetype) bwipe! + call writefile(['MACHINE ?= "qemu"'], 'Xfile.inc') + split Xfile.inc + call assert_equal('bitbake', &filetype) + bwipe! + call writefile(['MACHINE ??= "qemu"'], 'Xfile.inc') split Xfile.inc call assert_equal('bitbake', &filetype)