Skip to content

Commit 9693c6d

Browse files
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

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/release-proxy.yml

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,34 @@ jobs:
1717
include:
1818
- target: aarch64-apple-darwin
1919
runner: macos-15
20-
asset_name: java-lsp-proxy-darwin-aarch64.tar.gz
2120
helper_asset_name: java-task-helper-darwin-aarch64.tar.gz
21+
proxy_asset: java-lsp-proxy-darwin-aarch64.tar.gz
22+
bridge_asset: gradle-lsp-bridge-darwin-aarch64.tar.gz
2223
- target: x86_64-apple-darwin
2324
runner: macos-15-intel
24-
asset_name: java-lsp-proxy-darwin-x86_64.tar.gz
2525
helper_asset_name: java-task-helper-darwin-x86_64.tar.gz
26+
proxy_asset: java-lsp-proxy-darwin-x86_64.tar.gz
27+
bridge_asset: gradle-lsp-bridge-darwin-x86_64.tar.gz
2628
- target: x86_64-unknown-linux-gnu
2729
runner: ubuntu-22.04
28-
asset_name: java-lsp-proxy-linux-x86_64.tar.gz
2930
helper_asset_name: java-task-helper-linux-x86_64.tar.gz
31+
proxy_asset: java-lsp-proxy-linux-x86_64.tar.gz
32+
bridge_asset: gradle-lsp-bridge-linux-x86_64.tar.gz
3033
- target: aarch64-unknown-linux-gnu
3134
runner: ubuntu-22.04-arm
32-
asset_name: java-lsp-proxy-linux-aarch64.tar.gz
3335
helper_asset_name: java-task-helper-linux-aarch64.tar.gz
36+
proxy_asset: java-lsp-proxy-linux-aarch64.tar.gz
37+
bridge_asset: gradle-lsp-bridge-linux-aarch64.tar.gz
3438
- target: x86_64-pc-windows-msvc
3539
runner: windows-latest
36-
asset_name: java-lsp-proxy-windows-x86_64.zip
3740
helper_asset_name: java-task-helper-windows-x86_64.zip
41+
proxy_asset: java-lsp-proxy-windows-x86_64.zip
42+
bridge_asset: gradle-lsp-bridge-windows-x86_64.zip
3843
- target: aarch64-pc-windows-msvc
3944
runner: windows-11-arm
40-
asset_name: java-lsp-proxy-windows-aarch64.zip
4145
helper_asset_name: java-task-helper-windows-aarch64.zip
46+
proxy_asset: java-lsp-proxy-windows-aarch64.zip
47+
bridge_asset: gradle-lsp-bridge-windows-aarch64.zip
4248

4349
steps:
4450
- name: Checkout
@@ -49,9 +55,12 @@ jobs:
4955
with:
5056
targets: ${{ matrix.target }}
5157

52-
- name: Build proxy binary
53-
working-directory: proxy
54-
run: cargo build --release --target ${{ matrix.target }}
58+
# Build both native binaries from the workspace root. Selecting the two
59+
# packages explicitly keeps the WASM extension crate (`zed_java`, a
60+
# cdylib) out of the native target build. The gradle-lsp-bridge gRPC
61+
# bindings are committed, so no protoc toolchain is needed here.
62+
- name: Build binaries
63+
run: cargo build --release --target ${{ matrix.target }} -p java-lsp-proxy -p gradle-lsp-bridge
5564
shell: bash
5665

5766
- name: Build task helper binary
@@ -62,27 +71,32 @@ jobs:
6271
- name: Package binaries (Unix)
6372
if: runner.os != 'Windows'
6473
run: |
65-
tar -czf ${{ matrix.asset_name }} \
74+
tar -czf ${{ matrix.proxy_asset }} \
6675
-C target/${{ matrix.target }}/release \
6776
java-lsp-proxy
6877
tar -czf ${{ matrix.helper_asset_name }} \
6978
-C target/${{ matrix.target }}/release \
7079
java-task-helper
80+
tar -czf ${{ matrix.bridge_asset }} \
81+
-C target/${{ matrix.target }}/release \
82+
gradle-lsp-bridge
7183
7284
- name: Package binaries (Windows)
7385
if: runner.os == 'Windows'
7486
shell: pwsh
75-
run: |
76-
Compress-Archive -Path target/${{ matrix.target }}/release/java-lsp-proxy.exe -DestinationPath ${{ matrix.asset_name }}
87+
run: |
7788
Compress-Archive -Path target/${{ matrix.target }}/release/java-task-helper.exe -DestinationPath ${{ matrix.helper_asset_name }}
89+
Compress-Archive -Path target/${{ matrix.target }}/release/java-lsp-proxy.exe -DestinationPath ${{ matrix.proxy_asset }}
90+
Compress-Archive -Path target/${{ matrix.target }}/release/gradle-lsp-bridge.exe -DestinationPath ${{ matrix.bridge_asset }}
7891
7992
- name: Upload artifacts
8093
uses: actions/upload-artifact@v7
8194
with:
8295
name: binaries-${{ matrix.target }}
8396
path: |
84-
${{ matrix.asset_name }}
8597
${{ matrix.helper_asset_name }}
98+
${{ matrix.proxy_asset }}
99+
${{ matrix.bridge_asset }}
86100
retention-days: 1
87101

88102
release:

0 commit comments

Comments
 (0)