diff --git a/README.md b/README.md index 669051a..f5889ee 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 21899af..7cc5b36 100644 --- a/src/s-core-devcontainer/.devcontainer/devcontainer.json +++ b/src/s-core-devcontainer/.devcontainer/devcontainer.json @@ -36,6 +36,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,14 +61,18 @@ "customizations": { "vscode": { "extensions": [ + "usernamehw.errorlens", + "lextudio.restructuredtext", + "ms-python.python", + "charliermarsh.ruff", "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 + "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 ], @@ -79,6 +88,13 @@ "--pretty", "--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", @@ -103,7 +119,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", @@ -112,15 +128,7 @@ "options": { "cwd": "${workspaceFolder}" }, - "group": "build", - "problemMatcher": [], - "presentation": { - "reveal": "never", - "panel": "dedicated" - }, - "runOptions": { - "runOn": "folderOpen" - } + "group": "build" } ] } 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.