Skip to content

Add experimental LSP server for bundle files#4714

Draft
shreyas-goenka wants to merge 5 commits intomainfrom
cli-dabs-lsp
Draft

Add experimental LSP server for bundle files#4714
shreyas-goenka wants to merge 5 commits intomainfrom
cli-dabs-lsp

Conversation

@shreyas-goenka
Copy link
Contributor

Summary

  • Adds a hidden databricks bundle lsp command that starts an LSP server for bundle YAML files
  • Supports document links (ctrl+click on resource keys to open in Databricks workspace) and hover (shows resource ID, name, and workspace link)
  • Reads deployment state from local state files (both direct engine resources.json and Terraform terraform.tfstate) to resolve resource IDs without requiring authentication
  • Uses github.com/creachadair/jrpc2 for JSON-RPC 2.0 transport (same library used by terraform-ls)
  • Stacks with existing Red Hat YAML language server — VS Code merges results from both

New files

  • bundle/lsp/protocol.go — Minimal LSP type definitions
  • bundle/lsp/documents.go — Thread-safe document store with YAML parsing via libs/dyn
  • bundle/lsp/resource_index.go — Resource position indexing from parsed YAML
  • bundle/lsp/state.go — State file reading, URL construction, target/host resolution
  • bundle/lsp/server.go — jrpc2-based LSP server with all handlers
  • bundle/lsp/server_test.go — 18 unit tests
  • bundle/lsp/server_integration_test.go — 6 integration tests using in-memory jrpc2 channels
  • cmd/bundle/lsp.go — Hidden cobra command with --target flag

Test plan

  • 24 tests pass (go test ./bundle/lsp/...)
  • Full build passes (go build ./...)
  • Manual test with VS Code extension language client
  • Test with actual deployed bundle project

🤖 Generated with Claude Code

shreyas-goenka and others added 2 commits March 12, 2026 00:01
Two proposals:
1. Replace regex-based ${...} parsing with a proper two-mode character scanner
2. Add "did you mean?" suggestions for invalid variable references

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Introduces a hidden `databricks bundle lsp` command that starts a
Language Server Protocol server for bundle YAML files. The server
provides:

- Document links: Ctrl+click on resource keys to open them in the
  Databricks workspace browser
- Hover: Shows resource ID, name, and a link to open in Databricks
  when hovering over resource keys

The server reads deployment state from local state files (both direct
engine and Terraform) to resolve resource IDs and construct workspace
URLs without requiring authentication.

Uses github.com/creachadair/jrpc2 for JSON-RPC 2.0 transport (same
library used by terraform-ls).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
shreyas-goenka added a commit to databricks/databricks-vscode that referenced this pull request Mar 12, 2026
Introduces a BundleLSPClient that spawns `databricks bundle lsp` via
stdio to provide deployment-aware features for bundle YAML files:

- Document links: Ctrl+click on resource keys to open in workspace
- Hover: Shows resource ID, name, and workspace link

The client connects to the CLI's new hidden LSP server and activates
for all bundle YAML files (databricks.yml, databricks.yaml, etc.).
Stacks with the existing Red Hat YAML extension.

Depends on: databricks/cli#4714

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@eng-dev-ecosystem-bot
Copy link
Collaborator

eng-dev-ecosystem-bot commented Mar 12, 2026

Commit: a27b67f

Run: 22982511783

Env 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
💚​ azure windows 2 9 273 777 3:27
💚​ gcp linux 2 9 267 782 4:37
11 interesting tests: 9 SKIP, 2 RECOVERED
Test Name azure windows gcp linux
💚​ TestAccept 💚​R 💚​R
🙈​ TestAccept/bundle/resources/permissions 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/basic 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/recreate 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/update_protected 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/without_branch_id 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_endpoints/recreate 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/synced_database_tables/basic 🙈​S 🙈​S
💚​ TestAccept/ssh/connection 💚​R 💚​R
Top 4 slowest tests (at least 2 minutes):
duration env testname
3:44 gcp linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:09 gcp linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:13 azure windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:08 azure windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct

- Ctrl+click on ${...} references navigates to where the path is defined
- Ctrl+click on resource keys shows all interpolation references (peek view)
- Hover on resource keys shows URLs for all targets (up to 10)
- Merged tree loading supports include file resolution
- var.X shorthand resolves to variables.X definitions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use PathToURI() instead of "file://" + path for cross-platform URI construction
- Replace platform-specific TestURIToPath with TestURIToPathRoundTrip
- Fix gofmt alignment in handler map declarations

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The command is now at `databricks experimental bundle-lsp` instead of
`databricks bundle lsp`. This better reflects its experimental status.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@eng-dev-ecosystem-bot
Copy link
Collaborator

eng-dev-ecosystem-bot commented Mar 12, 2026

Commit: a27b67f

Run: 22982511783

Env 🔄​flaky 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
💚​ aws linux 8 7 268 781 5:23
💚​ aws windows 8 7 270 779 4:43
🔄​ aws-ucws linux 2 7 7 364 696 6:33
🔄​ aws-ucws windows 2 6 7 367 694 4:22
💚​ azure linux 2 9 271 779 5:28
💚​ azure windows 2 9 273 777 3:27
🔄​ azure-ucws linux 2 1 9 369 692 7:19
🔄​ azure-ucws windows 2 1 9 371 690 5:22
💚​ gcp linux 2 9 267 782 4:37
💚​ gcp windows 2 9 269 780 4:15
16 interesting tests: 7 SKIP, 6 RECOVERED, 3 flaky
Test Name aws linux aws windows aws-ucws linux aws-ucws windows azure linux azure windows azure-ucws linux azure-ucws windows gcp linux gcp windows
🔄​ TestAccept 💚​R 💚​R 🔄​f 🔄​f 💚​R 💚​R 🔄​f 💚​R 💚​R 💚​R
🙈​ TestAccept/bundle/resources/permissions 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions 💚​R 💚​R 💚​R 💚​R 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=direct 💚​R 💚​R 💚​R 💚​R
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=terraform 💚​R 💚​R 💚​R 💚​R
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions 💚​R 💚​R 💚​R 💚​R 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=direct 💚​R 💚​R 💚​R 💚​R
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=terraform 💚​R 💚​R 💚​R 💚​R
🙈​ TestAccept/bundle/resources/postgres_branches/basic 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/recreate 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/update_protected 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/without_branch_id 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_endpoints/recreate 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/synced_database_tables/basic 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🔄​ TestAccept/ssh/connect-serverless-gpu 🙈​s 🙈​s 🔄​f ✅​p 🙈​s 🙈​s 🔄​f 🔄​f 🙈​s 🙈​s
🔄​ TestAccept/ssh/connection 💚​R 💚​R 💚​R 🔄​f 💚​R 💚​R 💚​R 🔄​f 💚​R 💚​R
Top 20 slowest tests (at least 2 minutes):
duration env testname
3:44 gcp linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:15 aws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:12 aws-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:11 gcp windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:11 aws-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:09 gcp linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:05 gcp windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:02 aws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:52 azure-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:50 aws-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:49 aws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:46 aws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:38 aws-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:33 azure-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:19 azure linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:17 azure-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:17 azure linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:13 azure windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:11 azure-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:08 azure windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct

@varundeepsaini
Copy link
Contributor

this is so cool !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants