Commit 9693c6d
authored
Gradle lsp (zed-extensions#275)
# Add Gradle Language Server support (gRPC-driven build model)
## Summary
Adds Gradle build-file intelligence to the extension via Microsoft's
[Gradle Language Server](https://github.com/microsoft/vscode-gradle),
driven the same way the official VS Code Gradle extension drives it, by
running the bundled `gradle-server` over gRPC. A new native binary,
**`gradle-lsp-bridge`**, sits between Zed and the language server: it
keeps a single `gradle-server` process (and its Gradle daemon) warm for
the session, resolves the build model, and feeds it to the LS.
For **Groovy** `.gradle` scripts this gives plugin-aware completions
(closures, plugin-contributed blocks like `java {}`/`application {}`),
Maven Central dependency coordinates, and diagnostics. For **Kotlin**
`.gradle.kts` scripts it provides syntax highlighting plus
build-evaluation diagnostics (see below).
## Kotlin DSL handling
The Gradle Language Server is Groovy-only (it can't parse Kotlin), so
`.gradle.kts` doesn't get completions. But `gradle-server` itself runs
Gradle's Kotlin-DSL compiler during configuration and emits real errors
with file/line, the bridge captures these and surfaces them as editor
diagnostics, which **VS Code only logs**. The Groovy LS's own (invalid)
diagnostics for `.gradle.kts` are suppressed. Highlighting uses the
bundled Kotlin grammar via a dedicated `Gradle KTS` language, scoped by
longest-suffix-match so plain `.kt` files are unaffected.
## Architecture / refactors included
- **`proxy-common`** crate extracted: shared LSP framing +
parent-process monitor + `file://` URI helper, used by both native
binaries (keeps the JDTLS proxy lean: no async/gRPC stack leaks into
it).
- **`gradle-lsp-bridge`** built as a separate binary
(tokio/tonic/prost), so the gRPC dependency tree stays out of
`java-lsp-proxy`.
- Native binaries now share a single install directory via one constant
(aligns with the direction in zed-extensions#274).
- Build-eval diagnostics merged with the LS's own diagnostics per URI
(neither erases the other).
## Configuration
Gradle settings live under the `gradle-language-server` LSP block
(separate from `jdtls`). All optional works out of the box. Notably
`java_home` controls the JDK the Gradle daemon uses (17+); it's
configured per-server and falls back to `$JAVA_HOME`. Full reference in
the README's new **Gradle Build Files** section.
## Distribution
CI builds and ships `gradle-lsp-bridge-<os>-<arch>` assets alongside the
proxy on the same release tag, across the existing 6-target matrix.
## Testing
- Unit tests for the bridge: save/injected-response detectors,
diagnostics parsing (incl. the Kotlin-DSL failure shape), URI/framing
helpers, and the model→executeCommand mapping.
- Verified end-to-end against real Groovy and Kotlin-DSL projects:
completions appear, build errors surface as squiggles with correct
lines, and re-syncs after the daemon is warm are fast.
- Builds + clippy clean on macOS/Linux/Windows targets and the
`wasm32-wasip1` extension target.1 parent f760f2c commit 9693c6d
49 files changed
Lines changed: 4681 additions & 410 deletions
File tree
- .github/workflows
- gradle-bridge
- proto
- src
- gen
- languages
- gradle-kts
- gradle
- proxy-common
- src
- platform
- proxy
- src
- src
- task_helper/src/build_tool
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | 20 | | |
| 21 | + | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | | - | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | | - | |
29 | 30 | | |
| 31 | + | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
32 | | - | |
33 | 35 | | |
| 36 | + | |
| 37 | + | |
34 | 38 | | |
35 | 39 | | |
36 | | - | |
37 | 40 | | |
| 41 | + | |
| 42 | + | |
38 | 43 | | |
39 | 44 | | |
40 | | - | |
41 | 45 | | |
| 46 | + | |
| 47 | + | |
42 | 48 | | |
43 | 49 | | |
44 | 50 | | |
| |||
49 | 55 | | |
50 | 56 | | |
51 | 57 | | |
52 | | - | |
53 | | - | |
54 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
55 | 64 | | |
56 | 65 | | |
57 | 66 | | |
| |||
62 | 71 | | |
63 | 72 | | |
64 | 73 | | |
65 | | - | |
| 74 | + | |
66 | 75 | | |
67 | 76 | | |
68 | 77 | | |
69 | 78 | | |
70 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
71 | 83 | | |
72 | 84 | | |
73 | 85 | | |
74 | 86 | | |
75 | | - | |
76 | | - | |
| 87 | + | |
77 | 88 | | |
| 89 | + | |
| 90 | + | |
78 | 91 | | |
79 | 92 | | |
80 | 93 | | |
81 | 94 | | |
82 | 95 | | |
83 | 96 | | |
84 | | - | |
85 | 97 | | |
| 98 | + | |
| 99 | + | |
86 | 100 | | |
87 | 101 | | |
88 | 102 | | |
| |||
0 commit comments