From 766efe5b51284767f25a82fdadd8b4cf571f4a69 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 16 Apr 2026 08:27:04 +0800 Subject: [PATCH] vim-patch:9.2.0354: filetype: not all Bitbake include files are recognized Problem: filetype: not all Bitbake include files are recognized Solution: Enhance the file detection logic and consider varflags (Martin Schwan) closes: vim/vim#19983 https://github.com/vim/vim/commit/0e02be191909df88a8d6ef0a1b091c67c49b1888 Co-authored-by: Martin Schwan --- runtime/lua/vim/filetype/detect.lua | 6 +++++- test/old/testdir/test_filetype.vim | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) 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)