From 1de1c08210076edbdc23fba86d9ffff25b54cbd8 Mon Sep 17 00:00:00 2001 From: Anakin Childerhose <65310735+anakin4747@users.noreply.github.com> Date: Mon, 23 Mar 2026 19:40:03 -0400 Subject: [PATCH] vim-patch:9.2.0235: filetype: wks files are not recognized (#38451) Problem: filetype: wks files are not recognized. Solution: Detect *.wks, *.wks.in and *.wks.inc as wks filetype, include a filetype and syntax plugin (Anakin Childerhose) The OpenEmbedded Image Creation tool, `wic` uses wic kickstarter files to define image partition and bootloader layouts. wks files can end with .wks, .wks.in for templated wks files, and .wks.inc for including in other .wks files. The autocmd for *.wks.inc needs to come before *.inc in runtime/ftdetect.vim Reference: https://docs.yoctoproject.org/ref-manual/kickstart.html#openembedded-kickstart-wks-reference https://git.openembedded.org/openembedded-core/tree/scripts/lib/wic/canned-wks closes: vim/vim#19796 https://github.com/vim/vim/commit/8c116bbe79eab7337bb5c979468d3b0cb5933d07 --- runtime/ftplugin/wks.vim | 14 ++++++++++++++ runtime/lua/vim/filetype.lua | 3 +++ runtime/syntax/wks.vim | 29 +++++++++++++++++++++++++++++ test/old/testdir/test_filetype.vim | 1 + 4 files changed, 47 insertions(+) create mode 100644 runtime/ftplugin/wks.vim create mode 100644 runtime/syntax/wks.vim diff --git a/runtime/ftplugin/wks.vim b/runtime/ftplugin/wks.vim new file mode 100644 index 0000000000..c8d34818be --- /dev/null +++ b/runtime/ftplugin/wks.vim @@ -0,0 +1,14 @@ +" Vim filetype plugin file +" Language: OpenEmbedded Image Creator (WIC) Kickstarter files wks +" Maintainer: Anakin Childerhose +" Last Change: 2026 Mar 23 + +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +setlocal comments=:# +setlocal commentstring=#\ %s + +let b:undo_ftplugin = 'setlocal com< cms<' diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index bacbf17ab2..0a112fa894 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -1380,6 +1380,7 @@ local extension = { wgsl = 'wgsl', wbt = 'winbatch', wit = 'wit', + wks = 'wks', wml = 'wml', wsf = 'wsh', wsc = 'wsh', @@ -2781,6 +2782,8 @@ local pattern = { ['%.t%.html$'] = 'tilde', ['%.vhdl_[0-9]'] = starsetf('vhdl'), ['vimrc'] = starsetf('vim'), + ['%.wks%.in$'] = 'wks', + ['%.wks%.inc$'] = 'wks', ['/Xresources/'] = starsetf('xdefaults'), ['/app%-defaults/'] = starsetf('xdefaults'), ['^Xresources'] = starsetf('xdefaults'), diff --git a/runtime/syntax/wks.vim b/runtime/syntax/wks.vim new file mode 100644 index 0000000000..1d242ada12 --- /dev/null +++ b/runtime/syntax/wks.vim @@ -0,0 +1,29 @@ +" Vim syntax file +" Language: OpenEmbedded Image Creator (WIC) Kickstarter files wks +" Maintainer: Anakin Childerhose +" Last Change: 2026 Mar 23 + +if exists("b:current_syntax") + finish +endif + +let s:cpo_save = &cpo +set cpo&vim + +syn case match + +syn match wksComment "#.*$" +syn match wksCommand "\" +syn match wksCommand "\<\(part\|partition\)\>" skipwhite nextgroup=wksMountPoint +syn match wksMountPoint "\(/[^ \t]*\|swap\)" contained + +syn match wksOption "--[a-zA-Z_-]\+" + +hi def link wksComment Comment +hi def link wksCommand Statement +hi def link wksMountPoint Identifier +hi def link wksOption Special + +let b:current_syntax = "wks" +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim index 0902c78334..54178a9cfc 100644 --- a/test/old/testdir/test_filetype.vim +++ b/test/old/testdir/test_filetype.vim @@ -963,6 +963,7 @@ func s:GetFilenameChecks() abort \ 'wgsl': ['file.wgsl'], \ 'winbatch': ['file.wbt'], \ 'wit': ['file.wit'], + \ 'wks': ['file.wks', 'file.wks.in', 'file.wks.inc'], \ 'wml': ['file.wml'], \ 'wsh': ['file.wsf', 'file.wsc'], \ 'wsml': ['file.wsml'],