Skip to content

Conversation

aaronvg
Copy link
Contributor

@aaronvg aaronvg commented Oct 6, 2025

Add context-aware code completions to the BAML language server for attributes, prompt helpers, keywords, and IR symbols.


Slack Thread

Open in Cursor Open in Web


Note

Adds LSP completion logic for attributes, prompt helpers, keywords, and IR-derived symbols, plus a basic completion test and resilient logging init.

  • Language Server
    • Completions: Implement context-aware suggestions in engine/language_server/src/server/api/requests/completion.rs.
      • Detect contexts via get_word_at_position and get_symbol_before_position (attributes @/@@, _.role(, ctx./ctx.client., top-level).
      • Provide items for attributes (@alias, @stream.*, @@dynamic, etc.), prompt helpers (_.role("system"|"user"|"assistant"), ctx.output_format, ctx.client.*), top-level keywords (function, class, enum, client, generator, retry_policy, template_string, type), and IR symbols (functions/classes/enums/type aliases) via runtime.
      • Return CompletionResponse::List with CompletionItemKind and minimal details; add helper builders.
  • Tests
    • Add test_basic_attribute_completion in engine/language_server/src/tests.rs validating @alias suggestion.
  • Logging
    • In engine/language_server/src/logging.rs, avoid panic if global subscriber already set; print warning and continue.
  • Docs
    • Add design doc docs/lsp-completions-design.md outlining goals, approach, examples, and testing.

Written by Cursor Bugbot for commit 6672932. This will update automatically on new commits. Configure here.

Copy link

cursor bot commented Oct 6, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

Copy link

vercel bot commented Oct 6, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
promptfiddle Ready Ready Preview Comment Oct 6, 2025 9:11pm

@aaronvg aaronvg temporarily deployed to boundary-tools-dev October 6, 2025 20:13 — with GitHub Actions Inactive
@aaronvg aaronvg temporarily deployed to boundary-tools-dev October 6, 2025 20:13 — with GitHub Actions Inactive
@aaronvg aaronvg temporarily deployed to boundary-tools-dev October 6, 2025 20:13 — with GitHub Actions Inactive
get_symbol_before_position(&doc.contents, &prev_pos)
} else {
String::new()
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Block Attribute Detection Logic Error

The logic for detecting @@ block attributes is flawed. When prev is identified as @, the subsequent check for a second @ uses get_symbol_before_position on a position one character back from the cursor. This effectively checks two positions back from the cursor, which may incorrectly identify or miss the @@ pattern.

Fix in Cursor Fix in Web

Copy link

github-actions bot commented Oct 6, 2025

Copy link

codecov bot commented Oct 6, 2025

Codecov Report

❌ Patch coverage is 62.28070% with 86 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...guage_server/src/server/api/requests/completion.rs 42.65% 82 Missing ⚠️
engine/language_server/src/tests.rs 95.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link

github-actions bot commented Oct 6, 2025

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.

2 participants