Skip to content

Commit e004197

Browse files
authored
workspace: rework code completion using a custom build runner (zml#131)
Following the new release of the VSCode Zig plugin, rework the code completion logic to leverage a build runner. This is much lighter, faster and more reliable.
1 parent e5c152c commit e004197

File tree

15 files changed

+161
-3354
lines changed

15 files changed

+161
-3354
lines changed

.bazelrc-examples

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
common --override_module=zml=../
1+
common --override_module=zml=%workspace%/../../
22
common --registry=file://%workspace%/../third_party/

BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ load("@rules_zig//zig:defs.bzl", "zls_completion")
22

33
zls_completion(
44
name = "completion",
5+
visibility = ["//visibility:public"],
56
deps = [
67
"//async",
78
"//stdx",

MODULE.bazel.lock

Lines changed: 0 additions & 1767 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/.vscode/settings.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,16 @@
1919
"."
2020
],
2121
"bazel.buildifierExecutable": "@buildifier_prebuilt//:buildifier",
22-
"zig.formattingProvider": "zls",
23-
"zig.initialSetupDone": true,
24-
"zig.path": "${workspaceFolder}/tools/zig.sh",
25-
"zig.zls.globalCachePath": null,
26-
"zig.zls.path": "${workspaceFolder}/tools/zls.sh",
2722
"C_Cpp.formatting": "clangFormat",
2823
"C_Cpp.clang_format_style": "Microsoft",
24+
"zig.formattingProvider": "zls",
25+
"zig.path": "x",
26+
"zig.zls.path": "${workspaceFolder}/tools/zls.sh",
27+
"[zig]": {
28+
"editor.suggest.insertMode": "replace",
29+
"editor.stickyScroll.defaultModel": "foldingProviderModel",
30+
"editor.codeActionsOnSave": {
31+
"source.fixAll": "explicit",
32+
}
33+
},
2934
}

examples/MODULE.bazel.lock

Lines changed: 95 additions & 1456 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/tools/buildifier.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/bash
22
cd "$(dirname "${BASH_SOURCE[0]}")"
3+
cd "$(bazel info workspace)"
34
exec bazel run -- @buildifier_prebuilt//:buildifier "$@"

examples/tools/zig.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/tools/zls.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/bash
22
cd "$(dirname "${BASH_SOURCE[0]}")"
3-
exec bazel run --config=silent @zml//third_party/zls:zls -- "${@}"
3+
cd "$(bazel info workspace)"
4+
exec bazel run -- @zml//third_party/zls:zls "${@}"

examples/zls.build.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,2 @@
11
{
2-
"build_options": [
3-
{
4-
"name": "cmd",
5-
"value": "bazel run @zml//:completion"
6-
}
7-
]
82
}

third_party/zls/BUILD.bazel

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
load(":zls.bzl", "targets", "zig_runner", "zls_runner")
1+
load(":zls.bzl", "targets", "zls_runner")
22

33
toolchain_type(name = "toolchain_type")
44

55
targets()
66

7-
zig_runner(
8-
name = "zig",
9-
)
10-
117
zls_runner(
128
name = "zls",
13-
zig = ":zig",
9+
target = "//:completion",
1410
)

0 commit comments

Comments
 (0)