diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index 1680c316bf..435303c829 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -936,7 +936,11 @@ function M.inc(path, bufnr) elseif findany(line, { '^%s{', '^%s%(%*' }) or matchregex(line, pascal_keywords) then return 'pascal' elseif - findany(line, { '^%s*inherit ', '^%s*require ', '^%s*%u[%w_:${}/]*%s+%??[?:+.]?=.? ' }) + matchregex(line, [[\<\%(require\|inherit\)\>]]) + or matchregex( + line, + [=[[A-Z][A-Za-z0-9_:${}/]*\(\[[A-Za-z0-9_:/]\+\]\)*\s\+\%(??\|[?:+.]\)\?=.\? ]=] + ) then return 'bitbake' end diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim index cbecf0f9ba..62b32b5e9e 100644 --- a/test/old/testdir/test_filetype.vim +++ b/test/old/testdir/test_filetype.vim @@ -2839,6 +2839,16 @@ func Test_inc_file() call assert_equal('bitbake', &filetype) bwipe! + call writefile(['FOO_BAR[baz] = "foobar"'], 'Xfile.inc') + split Xfile.inc + call assert_equal('bitbake', &filetype) + bwipe! + + call writefile(['FOO_BAR_foo/bar[baz/bazzer] = "foobar"'], 'Xfile.inc') + split Xfile.inc + call assert_equal('bitbake', &filetype) + bwipe! + call writefile(['MACHINEOVERRIDES =. "qemuall:"'], 'Xfile.inc') split Xfile.inc call assert_equal('bitbake', &filetype)