diff options
author | Roland Hieber <rhi@pengutronix.de> | 2025-03-03 13:55:02 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-03-03 21:38:57 +0000 |
commit | fec201518be3c35a9359ec8c37675a33e458b92d (patch) | |
tree | 29e97f66ffe543dbe4f90d3364b0dd4609a7f4fa | |
parent | 8ed26544f9dfef5ee42e2981befd7e9076cf5798 (diff) | |
download | poky-fec201518be3c35a9359ec8c37675a33e458b92d.tar.gz |
bitbake: contrib: vim: ftdetect: don't conflict with other filetypes
Use :setfiletype instead of :set filetype. The former only sets the
'filetype' option if it has not been set before, which makes it possible
to override the syntax of certain *.inc files in autocommands from e.g.
.vimrc or modelines. All other ftdetect plugins in upstream vim also use
:setfiletype for this reason.
The detection for bitbake *.inc files is now upstream since Vim 9.0
patch 0055 [1]. If we're running an earlier Vim, use the detection
heuristic from upstream [2] to overwrite the filetype explicitely if we
find bitbake code. But don't always assuming that *.inc files are
bitbake files so as not to break Perl, PHP, Assembly, Povray, etc.
[1]: https://github.com/vim/vim/commit/fa49eb482729
[2]: https://github.com/vim/vim/blob/fb49e3cde79d/runtime/autoload/dist/ft.vim#L715
(Bitbake rev: e8efbba5d7bb4b685ed0a9b970e042ad99be8afb)
Signed-off-by: Roland Hieber <rhi@pengutronix.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | bitbake/contrib/vim/ftdetect/bitbake.vim | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/bitbake/contrib/vim/ftdetect/bitbake.vim b/bitbake/contrib/vim/ftdetect/bitbake.vim index 09fc4dc74c..427ab5b987 100644 --- a/bitbake/contrib/vim/ftdetect/bitbake.vim +++ b/bitbake/contrib/vim/ftdetect/bitbake.vim | |||
@@ -11,10 +11,18 @@ if &compatible || version < 600 || exists("b:loaded_bitbake_plugin") | |||
11 | endif | 11 | endif |
12 | 12 | ||
13 | " .bb, .bbappend and .bbclass | 13 | " .bb, .bbappend and .bbclass |
14 | au BufNewFile,BufRead *.{bb,bbappend,bbclass} set filetype=bitbake | 14 | au BufNewFile,BufRead *.{bb,bbappend,bbclass} setfiletype bitbake |
15 | 15 | ||
16 | " .inc | 16 | " .inc -- meanwhile included upstream |
17 | au BufNewFile,BufRead *.inc set filetype=bitbake | 17 | if !has("patch-9.0.0055") |
18 | au BufNewFile,BufRead *.inc call s:BBIncDetect() | ||
19 | def s:BBIncDetect() | ||
20 | l:lines = getline(1) .. getline(2) .. getline(3) | ||
21 | if l:lines =~# '\<\%(require\|inherit\)\>' || lines =~# '[A-Z][A-Za-z0-9_:${}]*\s\+\%(??\|[?:+]\)\?= ' | ||
22 | set filetype bitbake | ||
23 | endif | ||
24 | enddef | ||
25 | endif | ||
18 | 26 | ||
19 | " .conf | 27 | " .conf |
20 | au BufNewFile,BufRead *.conf | 28 | au BufNewFile,BufRead *.conf |