From ff00d583af8f1ce21a508d701d09c54d2621b16e Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 24 Nov 2024 15:05:48 +0100 Subject: [PATCH] vim-patch:9.1.0886: filetype: debian control file not detected Problem: filetype: debian control file not detected Solution: detect 'debian/control' files as debcontrol filetype (author) closes: vim/vim#16067 https://github.com/vim/vim/commit/57b947e3c3b8d52b914158979263855d785445d5 Co-authored-by: Wu, Zhenyu --- runtime/lua/vim/filetype.lua | 2 ++ runtime/lua/vim/filetype/detect.lua | 3 ++- test/old/testdir/test_filetype.vim | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 4383c0983e..aa566973b6 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -1490,6 +1490,7 @@ local filename = { ['NEWS.dch'] = 'debchangelog', ['NEWS.Debian'] = 'debchangelog', ['/debian/control'] = 'debcontrol', + ['/DEBIAN/control'] = 'debcontrol', ['/debian/copyright'] = 'debcopyright', ['/etc/apt/sources.list'] = 'debsources', ['denyhosts.conf'] = 'denyhosts', @@ -2319,6 +2320,7 @@ local pattern = { ['%.cmake%.in$'] = 'cmake', ['^crontab%.'] = starsetf('crontab'), ['^cvs%d+$'] = 'cvs', + ['/DEBIAN/control$'] = 'debcontrol', ['^php%.ini%-'] = 'dosini', ['^php%-fpm%.conf'] = 'dosini', ['^www%.conf'] = 'dosini', diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index 81b94c69db..4f2fef5b1f 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -237,7 +237,8 @@ end --- Debian Control --- @type vim.filetype.mapfn function M.control(_, bufnr) - if getline(bufnr, 1):find('^Source:') then + local line1 = getline(bufnr, 1) + if line1 and findany(line1, { '^Source:', '^Package:' }) then return 'debcontrol' end end diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim index 62e339c1ca..58064ea412 100644 --- a/test/old/testdir/test_filetype.vim +++ b/test/old/testdir/test_filetype.vim @@ -211,7 +211,7 @@ func s:GetFilenameChecks() abort \ 'datascript': ['file.ds'], \ 'dcd': ['file.dcd'], \ 'debchangelog': ['changelog.Debian', 'changelog.dch', 'NEWS.Debian', 'NEWS.dch', '/debian/changelog'], - \ 'debcontrol': ['/debian/control', 'any/debian/control'], + \ 'debcontrol': ['/debian/control', 'any/debian/control', 'any/DEBIAN/control'], \ 'debcopyright': ['/debian/copyright', 'any/debian/copyright'], \ 'debsources': ['/etc/apt/sources.list', '/etc/apt/sources.list.d/file.list', 'any/etc/apt/sources.list', 'any/etc/apt/sources.list.d/file.list'], \ 'deb822sources': ['/etc/apt/sources.list.d/file.sources', 'any/etc/apt/sources.list.d/file.sources'],