From 8e77e3388c5ea23f22bb5f8e7ff50906ff0116a3 Mon Sep 17 00:00:00 2001 From: unrelentingtech Date: Fri, 29 Apr 2022 23:08:00 +0300 Subject: [PATCH] feat(lang): add devicetree (Flattened Device Tree Source) (#2329) --- book/src/generated/lang-support.md | 1 + languages.toml | 13 +++++ runtime/queries/devicetree/highlights.scm | 66 +++++++++++++++++++++++ runtime/queries/devicetree/indents.scm | 12 +++++ 4 files changed, 92 insertions(+) create mode 100644 runtime/queries/devicetree/highlights.scm create mode 100644 runtime/queries/devicetree/indents.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 69ae35c12d7a..fe697cdf7e47 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -8,6 +8,7 @@ | cpp | ✓ | ✓ | ✓ | `clangd` | | css | ✓ | | | `vscode-css-language-server` | | dart | ✓ | | ✓ | `dart` | +| devicetree | ✓ | | ✓ | | | dockerfile | ✓ | | | `docker-langserver` | | eex | ✓ | | | | | ejs | ✓ | | | | diff --git a/languages.toml b/languages.toml index 660cb4ca8468..e5230fbaa41f 100644 --- a/languages.toml +++ b/languages.toml @@ -1263,3 +1263,16 @@ indent = { tab-width = 4, unit = "\t" } [[grammar]] name = "hare" source = { git = "https://git.sr.ht/~ecmma/tree-sitter-hare", rev = "bc26a6a949f2e0d98b7bfc437d459b250900a165" } + +[[language]] +name = "devicetree" +scope = "source.devicetree" +injection-regex = "(dtsi?|devicetree|fdt)" +file-types = ["dts", "dtsi"] +roots = [] +comment-token = "//" +indent = { tab-width = 4, unit = "\t" } + +[[grammar]] +name = "devicetree" +source = { git = "https://github.com/joelspadin/tree-sitter-devicetree", rev = "877adbfa0174d25894c40fa75ad52d4515a36368" } diff --git a/runtime/queries/devicetree/highlights.scm b/runtime/queries/devicetree/highlights.scm new file mode 100644 index 000000000000..d27c79e4af25 --- /dev/null +++ b/runtime/queries/devicetree/highlights.scm @@ -0,0 +1,66 @@ +[ + "/dts-v1/" + "/memreserve/" + "/delete-node/" + "/delete-property/" +] @keyword + +[ + "#define" + "#include" +] @keyword.directive + +[ + "!" + "~" + "-" + "+" + "*" + "/" + "%" + "||" + "&&" + "|" + "^" + "&" + "==" + "!=" + ">" + ">=" + "<=" + ">" + "<<" + ">>" +] @operator + +[ + "," + ";" +] @punctuation.delimiter + +[ + "(" + ")" + "{" + "}" + "<" + ">" +] @punctuation.bracket + +(string_literal) @string + +(integer_literal) @constant.numeric.integer + +(call_expression + function: (identifier) @function) + +(labeled_item + label: (identifier) @label) + +(identifier) @variable + +(unit_address) @tag + +(reference) @constant + +(comment) @comment diff --git a/runtime/queries/devicetree/indents.scm b/runtime/queries/devicetree/indents.scm new file mode 100644 index 000000000000..0649088903db --- /dev/null +++ b/runtime/queries/devicetree/indents.scm @@ -0,0 +1,12 @@ +[ + (node) + (byte_string_literal) + (parenthesized_expression) + (argument_list) +] @indent + +[ + "}" + "]" + ")" +] @outdent \ No newline at end of file