Skip to content

Commit f07d944

Browse files
egolhellovaiimalsogregba11b0yaaronvg
authored
Egor/zed extension (#2044)
Fixes #932 ### Changes: - Embed playground server in the language server (LSP). - Allows support for any editor that supports LSP protocol. - Modify `language_server/server.rs` to launch the server on first available localhost starting at port `3030`. If `3030` is taken will try `3031` etc. - Sends events on every LSP `did_change` - Selects function on function ctrl + hover - Code actions for opening playground in browser - Create a new zed extension under `engine/zed` which packages the new embedded playground via LSP - **Embedding structure:** Wasm language runtime -> fiddle frontend -> baml-cli (LSP) -> zed-extension -> Wasm extension package. - Syntax highlighting partially implemented using the existing tree-sitter implementation - Added connection status for playground frontend on connection lost ### Known Issues: - Syntax highlighting is not fully implemented: - Jinja highlighting does not work - Incorrect field and type highlighting ### Notes: - May be useful to batch updates from LSP to not spam frontend - Entire frontend is now embedded in LSP increasing file size - Local baml version handling is currently not implemented <!-- ELLIPSIS_HIDDEN --> ---- > [!IMPORTANT] > Embed playground server in language server for LSP support and add Zed extension for packaging, with partial syntax highlighting and connection status indicator. > > - **Behavior**: > - Embed playground server in `language_server` to support any LSP-compatible editor. > - Launches on first available localhost port starting at `3030`. > - Sends events on LSP `did_change`, supports function selection on hover, and code actions for opening playground. > - **Zed Extension**: > - New extension under `engine/zed` packages embedded playground via LSP. > - Embedding structure: Wasm language runtime -> fiddle frontend -> baml-cli (LSP) -> zed-extension -> Wasm extension package. > - Partial syntax highlighting using tree-sitter. > - **Playground Frontend**: > - Added connection status indicator for connection loss. > - **Known Issues**: > - Incomplete syntax highlighting: Jinja and incorrect field/type highlighting. > - Local baml version handling not implemented. > - **Misc**: > - Added `build.sh` script in `language_server/scripts` for building web-panel. > - Updated `Cargo.toml` and `Cargo.lock` for new dependencies and configurations. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup> for 7cc5efb. You can [customize](https://app.ellipsis.dev/BoundaryML/settings/summaries) this summary. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN --> --------- Co-authored-by: hellovai <vbv@boundaryml.com> Co-authored-by: Greg Hale <imalsogreg@gmail.com> Co-authored-by: Rahul Tiwari <jprrahultiwari@gmail.com> Co-authored-by: aaronvg <aaron@boundaryml.com> Co-authored-by: Sam Lijin <sam@boundaryml.com> Co-authored-by: Chris Watts <chris@boundaryml.com> Co-authored-by: Antonio Sarosi <sarosiantonio@gmail.com>
1 parent 2af60c3 commit f07d944

32 files changed

Lines changed: 1590 additions & 118 deletions

.github/workflows/primary.yml

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ jobs:
5353
- name: Check TS Lint
5454
run: pnpm biome ci . --organize-imports-enabled=false
5555
working-directory: typescript
56+
- name: Build web-panel for language server
57+
run: bash ./scripts/build.sh
58+
working-directory: engine/language_server
5659
- name: Check Rust Formatter
5760
# rustfmt can only run unstable features on stable toolchains if passed
5861
# through CLI. We don't want to download 2 toolchains just for this.
@@ -82,12 +85,19 @@ jobs:
8285
- uses: dtolnay/rust-toolchain@stable
8386
with:
8487
toolchain: stable
88+
- run: rustup target add wasm32-unknown-unknown
8589
- uses: Swatinem/rust-cache@v2
8690
with:
8791
workspaces: engine
8892
- name: Install Node
8993
run: pnpm install --frozen-lockfile
9094
working-directory: engine/language_client_typescript
95+
# This step is necessary to guarantee that the language server has a frontend to embed.
96+
# Is also included in build and integ-tests steps.
97+
- name: Build web-panel for language server
98+
run: bash ./scripts/build.sh
99+
working-directory: engine/language_server
100+
# ------------------------------------------------------------
91101
- name: Build Node
92102
run: pnpm build:debug
93103
working-directory: engine/language_client_typescript
@@ -122,6 +132,21 @@ jobs:
122132
- name: Ensure No Changes (3 of 3)
123133
run: |
124134
git diff --exit-code || (echo "::error:: merge canary and run codegen again" && exit 1)
135+
build-wasm:
136+
runs-on: ubuntu-latest
137+
steps:
138+
- uses: actions/checkout@v4
139+
- uses: jdx/mise-action@v2
140+
- uses: dtolnay/rust-toolchain@stable
141+
with:
142+
toolchain: stable
143+
- run: rustup target add wasm32-unknown-unknown
144+
- uses: Swatinem/rust-cache@v2
145+
with:
146+
workspaces: engine
147+
- name: Build rust for wasm32
148+
run: cargo build --target=wasm32-unknown-unknown
149+
working-directory: engine/baml-schema-wasm
125150
build:
126151
runs-on: ubuntu-latest
127152
steps:
@@ -130,6 +155,7 @@ jobs:
130155
- uses: dtolnay/rust-toolchain@stable
131156
with:
132157
toolchain: stable
158+
- run: rustup target add wasm32-unknown-unknown
133159
- uses: Swatinem/rust-cache@v2
134160
with:
135161
workspaces: engine
@@ -162,25 +188,13 @@ jobs:
162188
# env:
163189
# SRB_YES: "1"
164190
# run: bundle exec tapioca init
191+
- name: Build web-panel for language server
192+
run: bash ./scripts/build.sh
193+
working-directory: engine/language_server
165194
- name: Test Rust
166195
# skip doctests & integration tests (the latter require OPENAI_API_KEY and ANTHROPIC_API_KEY to be set)
167196
run: cargo test --lib
168197
working-directory: engine
169-
build-wasm:
170-
runs-on: ubuntu-latest
171-
steps:
172-
- uses: actions/checkout@v4
173-
- uses: jdx/mise-action@v2
174-
- uses: dtolnay/rust-toolchain@stable
175-
with:
176-
toolchain: stable
177-
- run: rustup target add wasm32-unknown-unknown
178-
- uses: Swatinem/rust-cache@v2
179-
with:
180-
workspaces: engine
181-
- name: Build rust for wasm32
182-
run: cargo build --target=wasm32-unknown-unknown
183-
working-directory: engine/baml-schema-wasm
184198
integ-tests:
185199
runs-on: ubuntu-latest
186200
steps:
@@ -193,9 +207,13 @@ jobs:
193207
- uses: dtolnay/rust-toolchain@stable
194208
with:
195209
toolchain: stable
210+
- run: rustup target add wasm32-unknown-unknown
196211
- uses: Swatinem/rust-cache@v2
197212
with:
198213
workspaces: engine
214+
- name: Build web-panel for language server
215+
run: bash ./scripts/build.sh
216+
working-directory: engine/language_server
199217
- name: run python tests
200218
run: |
201219
cd integ-tests/python

0 commit comments

Comments
 (0)