From b2cec61546fa4e76a9c767361569ae4498f4a2bc Mon Sep 17 00:00:00 2001 From: Oliver Pajonk Date: Thu, 24 Jul 2025 12:59:23 +0000 Subject: [PATCH 1/4] Add Starlark Language Server Support for Bazel auto completion / navigation --- src/s-core-devcontainer/.devcontainer/devcontainer.json | 8 +++++++- .../.devcontainer/s-core-local/install.sh | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/s-core-devcontainer/.devcontainer/devcontainer.json b/src/s-core-devcontainer/.devcontainer/devcontainer.json index 17fb611..dd50aad 100644 --- a/src/s-core-devcontainer/.devcontainer/devcontainer.json +++ b/src/s-core-devcontainer/.devcontainer/devcontainer.json @@ -35,6 +35,11 @@ // from the GitHub release page of buildtools // It is generated by running 'sha256sum buildifier-linux-amd64' "BUILDIFIER_SHA256": "6ceb7b0ab7cf66fceccc56a027d21d9cc557a7f34af37d2101edb56b92fcfa1a", + "STARPLS_VERSION": "0.1.21", + // The following sha256sum is for the binary starpls-linux-amd64 + // from the GitHub release page of starpls + // It is generated by running 'sha256sum starpls-linux-amd64' + "STARPLS_SHA256": "45692ecb9d94a19a15b1e7b240acdff5702f78cd22188dac41e1879cb8bdcdcf", "BAZEL_COMPILE_COMMANDS_VERSION": "0.17.2", // The following sha256sums are for the deb package bazel-compile-commands_-_amd64.deb // where is the Ubuntu codename (e.g., jammy, focal, noble) @@ -56,7 +61,7 @@ "vscode": { "extensions": [ "mads-hartmann.bash-ide-vscode", - "bazelbuild.vscode-bazel", + "bazelbuild.vscode-bazel", // Bazel support for Visual Studio Code; see also bazel.lsp.command below "dbaeumer.vscode-eslint", "EditorConfig.EditorConfig", "ms-vscode.live-server", // for live preview of HTML files @@ -78,6 +83,7 @@ "--pretty", "--background-index" ], + "bazel.lsp.command": "/usr/local/bin/starpls", // use the Starlark Language Server for Bazel projects "C_Cpp.intelliSenseEngine": "disabled", "tasks": { "version": "2.0.0", diff --git a/src/s-core-devcontainer/.devcontainer/s-core-local/install.sh b/src/s-core-devcontainer/.devcontainer/s-core-local/install.sh index 8705455..2554a7f 100755 --- a/src/s-core-devcontainer/.devcontainer/s-core-local/install.sh +++ b/src/s-core-devcontainer/.devcontainer/s-core-local/install.sh @@ -65,6 +65,11 @@ curl -L "https://github.com/bazelbuild/buildtools/releases/download/v${BUILDIFIE echo "${BUILDIFIER_SHA256} /usr/local/bin/buildifier" | sha256sum -c - || exit -1 chmod +x /usr/local/bin/buildifier +# Starlark Language Server, directly from GitHub (apparently no APT repository available) +curl -L "https://github.com/withered-magic/starpls/releases/download/v${STARPLS_VERSION}/starpls-linux-amd64" -o /usr/local/bin/starpls +echo "${STARPLS_SHA256} /usr/local/bin/starpls" | sha256sum -c - || exit -1 +chmod +x /usr/local/bin/starpls + # Code completion for C++ code of Bazel projects # (see https://github.com/kiron1/bazel-compile-commands) # The version is pinned to a specific release, and the SHA256 checksum is provided by the devcontainer-features.json file. From d8aa6b336f8a5e2ea78d429b7fa0b619f9f15a5e Mon Sep 17 00:00:00 2001 From: Oliver Pajonk Date: Thu, 24 Jul 2025 13:00:16 +0000 Subject: [PATCH 2/4] fix: do not automatically run gen_rust_project This fails if the project is not a Rust project. So this can be quite annoying. --- README.md | 2 +- .../.devcontainer/devcontainer.json | 18 +++++------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index b6e44f7..a3671a0 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ Open a Terminal, and - for example - type `bazel build ...` to execute the defau After you have build the code, create [compilation databases](https://clang.llvm.org/docs/JSONCompilationDatabase.html) via Visual Studio Code [Task](https://code.visualstudio.com/docs/debugtest/tasks): - C++: Ctrl + Shift + p -> `Tasks: Run Task` -> `Update compile_commands.json` -- Rust: Ctrl + Shift + p -> `Tasks: Run Task` -> `Generate rust-project.json` +- Rust: Ctrl + Shift + p -> `Tasks: Run Task` -> `Update rust-project.json` These databases are used by Visual Studio Code to support code navigation and auto-completion with the help of [language servers](https://microsoft.github.io/language-server-protocol/). diff --git a/src/s-core-devcontainer/.devcontainer/devcontainer.json b/src/s-core-devcontainer/.devcontainer/devcontainer.json index dd50aad..3bffa56 100644 --- a/src/s-core-devcontainer/.devcontainer/devcontainer.json +++ b/src/s-core-devcontainer/.devcontainer/devcontainer.json @@ -64,10 +64,10 @@ "bazelbuild.vscode-bazel", // Bazel support for Visual Studio Code; see also bazel.lsp.command below "dbaeumer.vscode-eslint", "EditorConfig.EditorConfig", - "ms-vscode.live-server", // for live preview of HTML files + "ms-vscode.live-server", // live preview of HTML files "llvm-vs-code-extensions.vscode-clangd", - "jebbs.plantuml", //to preview PlantUML diagrams - "hediet.vscode-drawio", //for drawio integration + "jebbs.plantuml", // preview PlantUML diagrams + "hediet.vscode-drawio", // Draw.IO integration "swyddfa.esbonio", // for Sphinx documentation support "rust-lang.rust-analyzer" // Rust language support for Visual Studio Code; see also tasks below ], @@ -108,7 +108,7 @@ } }, { // see https://bazelbuild.github.io/rules_rust/rust_analyzer.html#vscode - "label": "Generate rust-project.json", + "label": "Update rust-project.json", "command": "bazel", "args": [ "run", @@ -117,15 +117,7 @@ "options": { "cwd": "${workspaceFolder}" }, - "group": "build", - "problemMatcher": [], - "presentation": { - "reveal": "never", - "panel": "dedicated" - }, - "runOptions": { - "runOn": "folderOpen" - } + "group": "build" } ] } From 76cc0b6199088807b1e67bff1476951aa5017d68 Mon Sep 17 00:00:00 2001 From: Oliver Pajonk Date: Thu, 24 Jul 2025 13:17:32 +0000 Subject: [PATCH 3/4] enable some advanced features of the language server --- src/s-core-devcontainer/.devcontainer/devcontainer.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/s-core-devcontainer/.devcontainer/devcontainer.json b/src/s-core-devcontainer/.devcontainer/devcontainer.json index 9e7e3d9..2163716 100644 --- a/src/s-core-devcontainer/.devcontainer/devcontainer.json +++ b/src/s-core-devcontainer/.devcontainer/devcontainer.json @@ -85,6 +85,12 @@ "--background-index" ], "bazel.lsp.command": "/usr/local/bin/starpls", // use the Starlark Language Server for Bazel projects + "bazel.lsp.args": [ + "server", // see https://github.com/withered-magic/starpls/issues/400#issuecomment-3095469671 - this is "what developers expect" + "--experimental_infer_ctx_attributes", + "--experimental_use_code_flow_analysis", + "--experimental_enable_label_completions" + ], "C_Cpp.intelliSenseEngine": "disabled", "tasks": { "version": "2.0.0", From 02a6def9e4a342914e1bbbe5c1f52981d032eac5 Mon Sep 17 00:00:00 2001 From: Oliver Pajonk Date: Thu, 24 Jul 2025 13:33:02 +0000 Subject: [PATCH 4/4] add extensions already present in the devcontainer of score --- src/s-core-devcontainer/.devcontainer/devcontainer.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/s-core-devcontainer/.devcontainer/devcontainer.json b/src/s-core-devcontainer/.devcontainer/devcontainer.json index 2163716..7cc5b36 100644 --- a/src/s-core-devcontainer/.devcontainer/devcontainer.json +++ b/src/s-core-devcontainer/.devcontainer/devcontainer.json @@ -61,6 +61,10 @@ "customizations": { "vscode": { "extensions": [ + "usernamehw.errorlens", + "lextudio.restructuredtext", + "ms-python.python", + "charliermarsh.ruff", "mads-hartmann.bash-ide-vscode", "bazelbuild.vscode-bazel", // Bazel support for Visual Studio Code; see also bazel.lsp.command below "dbaeumer.vscode-eslint",