patch 9.1.0823: filetype: Zephyr overlay files not recognized
Problem: filetype: Zephyr overlay files not recognized
Solution: detect '*.overlay' files as dts filetype,
include syntax tests for DTS files
(Xudong Zheng)
Reference:
https://docs.zephyrproject.org/latest/build/dts/howtos.html
closes: #15963
Signed-off-by: Xudong Zheng <7pkvm5aw@slicealias.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 618d306..7b0014d 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -754,8 +754,12 @@
" DTD (Document Type Definition for XML)
au BufNewFile,BufRead *.dtd setf dtd
-" DTS/DSTI/DTSO (device tree files)
-au BufNewFile,BufRead *.dts,*.dtsi,*.dtso,*.its,*.keymap setf dts
+" Devicetree (.its for U-Boot Flattened Image Trees, .keymap for ZMK keymap, and
+" .overlay for Zephyr overlay)
+au BufNewFile,BufRead *.dts,*.dtsi,*.dtso setf dts
+au BufNewFile,BufRead *.its setf dts
+au BufNewFile,BufRead *.keymap setf dts
+au BufNewFile,BufRead *.overlay setf dts
" Earthfile
au BufNewFile,BufRead Earthfile setf earthfile
diff --git a/runtime/syntax/testdir/dumps/dts_zephyr_00.dump b/runtime/syntax/testdir/dumps/dts_zephyr_00.dump
new file mode 100644
index 0000000..6444d27
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/dts_zephyr_00.dump
@@ -0,0 +1,20 @@
+>/+0&#ffffff0| |{| @71
+@8|c+0#00e0003&|h|o|s|e|n| |{+0#0000000&| @58
+@16|z|e|p|h|y|r|,|u|a|r|t|-|m|c|u|m|g|r| |=| |&+0#e000e06&|c|d|c|_|a|c|m|_|u|a|r|t|0|;+0#0000000&| @22
+@16|z|e|p|h|y|r|,|s|h|e|l@1|-|u|a|r|t| |=| |&+0#e000e06&|c|d|c|_|a|c|m|_|u|a|r|t|1|;+0#0000000&| @23
+@8|}|;| @64
+|}|;| @72
+@75
+|&+0#e000e06&|z|e|p|h|y|r|_|u|d|c|0| +0#0000000&|{| @60
+| +0#af5f00255&@7|c|d|c|_|a|c|m|_|u|a|r|t|0|:| +0#0000000&|c+0#00e0003&|d|c|_|a|c|m|_|u|a|r|t|0| |{+0#0000000&| @36
+@16|c|o|m|p|a|t|i|b|l|e| |=| |"+0#e000002&|z|e|p|h|y|r|,|c|d|c|-|a|c|m|-|u|a|r|t|"|;+0#0000000&| @23
+@8|}|;| @64
+@75
+| +0#af5f00255&@7|c|d|c|_|a|c|m|_|u|a|r|t|1|:| +0#0000000&|c+0#00e0003&|d|c|_|a|c|m|_|u|a|r|t|1| |{+0#0000000&| @36
+@16|c|o|m|p|a|t|i|b|l|e| |=| |"+0#e000002&|z|e|p|h|y|r|,|c|d|c|-|a|c|m|-|u|a|r|t|"|;+0#0000000&| @23
+@8|}|;| @64
+|}|;| @72
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|,|1| @10|A|l@1|
diff --git a/runtime/syntax/testdir/dumps/dts_zmk_00.dump b/runtime/syntax/testdir/dumps/dts_zmk_00.dump
new file mode 100644
index 0000000..19f921c
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/dts_zmk_00.dump
@@ -0,0 +1,20 @@
+>#+0#e000e06#ffffff0|i|n|c|l|u|d|e| |<+0#e000002&|b|e|h|a|v|i|o|r|s|.|d|t|s|i|>| +0#0000000&@49
+|#+0#e000e06&|i|n|c|l|u|d|e| |<+0#e000002&|d|t|-|b|i|n|d|i|n|g|s|/|z|m|k|/|k|e|y|s|.|h|>| +0#0000000&@41
+@75
+|/+0#0000e05&@1| |D|e|f|i|n|e| |m|a|c|r|o| |f|o|r| |l|a|y|e|r|s|.| +0#0000000&@47
+|#+0#e000e06&|d|e|f|i|n|e| |L|A|Y|E|R|_|M|A|I|N| |0| +0#0000000&@54
+@75
+|/| |{| @71
+@8|k+0#00e0003&|e|y|m|a|p| |{+0#0000000&| @58
+@16|c|o|m|p|a|t|i|b|l|e| |=| |"+0#e000002&|z|m|k|,|k|e|y|m|a|p|"|;+0#0000000&| @32
+@75
+@16|l+0#00e0003&|a|y|e|r|_|0| |{+0#0000000&| @49
+@24|b|i|n|d|i|n|g|s| |=| |<+0#e000002&| +0#0000000&@38
+| +0#e000002&@31|&+0#e000e06&|k|p| +0#e000002&|Z| +0#0000000&@37
+| +0#e000002&@31|&+0#e000e06&|k|p| +0#e000002&|M| +0#0000000&@37
+| +0#e000002&@31|&+0#e000e06&|k|p| +0#e000002&|K| +0#0000000&@37
+| +0#e000002&@31|&+0#e000e06&|z|m|k|_|s|t|r|i|n|g| +0#0000000&@31
+| +0#e000002&@31|&+0#e000e06&|t|o| +0#e000002&|L|A|Y|E|R|_|M|A|I|N| +0#0000000&@28
+| +0#e000002&@23|>|;+0#0000000&| @48
+@16|}|;| @56
+@57|1|,|1| @10|T|o|p|
diff --git a/runtime/syntax/testdir/dumps/dts_zmk_01.dump b/runtime/syntax/testdir/dumps/dts_zmk_01.dump
new file mode 100644
index 0000000..20c02ee
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/dts_zmk_01.dump
@@ -0,0 +1,20 @@
+| +0#e000002#ffffff0@31|&+0#e000e06&|k|p| +0#e000002&|M| +0#0000000&@37
+| +0#e000002&@31|&+0#e000e06&|k|p| +0#e000002&|K| +0#0000000&@37
+| +0#e000002&@31|&+0#e000e06&|z|m|k|_|s|t|r|i|n|g| +0#0000000&@31
+| +0#e000002&@31|&+0#e000e06&|t|o| +0#e000002&|L|A|Y|E|R|_|M|A|I|N| +0#0000000&@28
+| +0#e000002&@23|>|;+0#0000000&| @48
+@16>}|;| @56
+@8|}|;| @64
+@75
+@8|Z|M|K|_|M|A|C|R|O|(|z|m|k|_|s|t|r|i|n|g|,| |w|a|i|t|-|m|s| |=| |<+0#e000002&|1|0|>|;+0#0000000&| |t|a|p|-|m|s| |=| |<+0#e000002&|1|0|>|;+0#0000000&| |b|i|n|d|i|n|g|s| |=| |<+0#e000002&|&+0#e000e06&|m
+|a|c|r|o|_|t|a|p| +0#e000002&|&+0#e000e06&|k|p| +0#e000002&|Z| |&+0#e000e06&|k|p| +0#e000002&|M| |&+0#e000e06&|k|p| +0#e000002&|K|>|;+0#0000000&|)| @45
+|}|;| @72
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|9|,|3|-|1|7| @6|B|o|t|
diff --git a/runtime/syntax/testdir/input/dts_zephyr.overlay b/runtime/syntax/testdir/input/dts_zephyr.overlay
new file mode 100644
index 0000000..40d9aa6
--- /dev/null
+++ b/runtime/syntax/testdir/input/dts_zephyr.overlay
@@ -0,0 +1,16 @@
+/ {
+ chosen {
+ zephyr,uart-mcumgr = &cdc_acm_uart0;
+ zephyr,shell-uart = &cdc_acm_uart1;
+ };
+};
+
+&zephyr_udc0 {
+ cdc_acm_uart0: cdc_acm_uart0 {
+ compatible = "zephyr,cdc-acm-uart";
+ };
+
+ cdc_acm_uart1: cdc_acm_uart1 {
+ compatible = "zephyr,cdc-acm-uart";
+ };
+};
diff --git a/runtime/syntax/testdir/input/dts_zmk.keymap b/runtime/syntax/testdir/input/dts_zmk.keymap
new file mode 100644
index 0000000..14fb210
--- /dev/null
+++ b/runtime/syntax/testdir/input/dts_zmk.keymap
@@ -0,0 +1,23 @@
+#include <behaviors.dtsi>
+#include <dt-bindings/zmk/keys.h>
+
+// Define macro for layers.
+#define LAYER_MAIN 0
+
+/ {
+ keymap {
+ compatible = "zmk,keymap";
+
+ layer_0 {
+ bindings = <
+ &kp Z
+ &kp M
+ &kp K
+ &zmk_string
+ &to LAYER_MAIN
+ >;
+ };
+ };
+
+ ZMK_MACRO(zmk_string, wait-ms = <10>; tap-ms = <10>; bindings = <¯o_tap &kp Z &kp M &kp K>;)
+};
diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim
index f81d18f..777f908 100644
--- a/src/testdir/test_filetype.vim
+++ b/src/testdir/test_filetype.vim
@@ -239,7 +239,7 @@
dracula: ['file.drac', 'file.drc', 'file.lvs', 'file.lpe', 'drac.file'],
dtd: ['file.dtd'],
dtrace: ['/usr/lib/dtrace/io.d'],
- dts: ['file.dts', 'file.dtsi', 'file.dtso', 'file.its', 'file.keymap'],
+ dts: ['file.dts', 'file.dtsi', 'file.dtso', 'file.its', 'file.keymap', 'file.overlay'],
dune: ['jbuild', 'dune', 'dune-project', 'dune-workspace', 'dune-file'],
dylan: ['file.dylan'],
dylanintr: ['file.intr'],
diff --git a/src/version.c b/src/version.c
index 74837b3..e670349 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 823,
+/**/
822,
/**/
821,