From dd1d8bea0e442ab0236bfd5376ea83f0a5202e4b Mon Sep 17 00:00:00 2001 From: Pascal Eberhard Date: Sun, 24 Mar 2024 17:45:19 +0100 Subject: [PATCH] add initial support for bitbake language Signed-off-by: Pascal Eberhard --- book/src/generated/lang-support.md | 1 + languages.toml | 12 ++++++ runtime/queries/bitbake/highlights.scm | 53 ++++++++++++++++++++++++++ runtime/queries/bitbake/injections.scm | 17 +++++++++ 4 files changed, 83 insertions(+) create mode 100644 runtime/queries/bitbake/highlights.scm create mode 100644 runtime/queries/bitbake/injections.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 2030949eb465c..a43c0b70a8cbd 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -9,6 +9,7 @@ | beancount | ✓ | | | | | bibtex | ✓ | | | `texlab` | | bicep | ✓ | | | `bicep-langserver` | +| bitbake | ✓ | | | `bitbake-language-server` | | blade | ✓ | | | | | blueprint | ✓ | | | `blueprint-compiler` | | c | ✓ | ✓ | ✓ | `clangd` | diff --git a/languages.toml b/languages.toml index a5764420b1569..9831fedc421cf 100644 --- a/languages.toml +++ b/languages.toml @@ -12,6 +12,7 @@ awk-language-server = { command = "awk-language-server" } bash-language-server = { command = "bash-language-server", args = ["start"] } bass = { command = "bass", args = ["--lsp"] } bicep-langserver = { command = "bicep-langserver" } +bitbake-language-server = { command = "bitbake-language-server" } bufls = { command = "bufls", args = ["serve"] } cairo-language-server = { command = "cairo-language-server", args = [] } cl-lsp = { command = "cl-lsp", args = [ "stdio" ] } @@ -3209,6 +3210,17 @@ indent = { tab-width = 2, unit = " " } name = "dbml" source = { git = "https://github.com/dynamotn/tree-sitter-dbml", rev = "2e2fa5640268c33c3d3f27f7e676f631a9c68fd9" } +[[language]] +name = "bitbake" +language-servers = [ "bitbake-language-server" ] +scope = "source.bitbake" +file-types = ["bb", "bbappend", "bbclass", {glob = "conf/*.conf" }, {glob = "conf/*/*.{inc,conf}" }, { glob = "recipe-*/*/*.inc" }] +comment-token = "#" + +[[grammar]] +name = "bitbake" +source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-bitbake", rev = "10bacac929ff36a1e8f4056503fe4f8717b21b94" } + [[language]] name = "log" scope = "source.log" diff --git a/runtime/queries/bitbake/highlights.scm b/runtime/queries/bitbake/highlights.scm new file mode 100644 index 0000000000000..bce135f293f4b --- /dev/null +++ b/runtime/queries/bitbake/highlights.scm @@ -0,0 +1,53 @@ + +; variables +(variable_assignment (identifier) @variable.other.member) +(variable_assignment (override) @keyword.operator) + +[ + "=" + "?=" + "??=" + ":=" + "=+" + "+=" + ".=" + "=." + +] @operator + +[ + "noexec" + "INHERIT" + "OVERRIDES" + "$BB_ENV_PASSTHROUGH" + "$BB_ENV_PASSTHROUGH_ADDITIONS" +] @variable.builtin + +; functions +(function_definition (identifier) @function) +(function_definition (override) @keyword.operator) + +[ + "inherit" + "include" + "require" + "export" + "import" +] @keyword.control.import + +[ + "addtask" + "deltask" + "addhandler" + "unset" + "EXPORT_FUNCTIONS" + "python" +] @keyword.function + +[ + "before" + "after" +] @keyword.operator + +(string) @string +(comment) @comment diff --git a/runtime/queries/bitbake/injections.scm b/runtime/queries/bitbake/injections.scm new file mode 100644 index 0000000000000..4a7dbca6db04a --- /dev/null +++ b/runtime/queries/bitbake/injections.scm @@ -0,0 +1,17 @@ +((python_function_definition) @injection.content + (#set! injection.language "python") + (#set! injection.include-children)) + +((anonymous_python_function) @injection.content + (#set! injection.language "python") + (#set! injection.include-children)) + +((inline_python) @injection.content + (#set! injection.language "python") + (#set! injection.include-children)) + +((shell_content) @injection.content + (#set! injection.language "bash")) + +((comment) @injection.content + (#set! injection.language "comment"))