Skip to content

Add support for struct auto-completion#57

Open
JesseHerrick wants to merge 1 commit intomainfrom
struct-support
Open

Add support for struct auto-completion#57
JesseHerrick wants to merge 1 commit intomainfrom
struct-support

Conversation

@JesseHerrick
Copy link
Copy Markdown
Member

@JesseHerrick JesseHerrick commented May 4, 2026

#43


Note

Medium Risk
Adds a new CodeIntel protocol op and asynchronous caching to drive struct-field completions, touching completion triggers and concurrency paths in the LSP server. Risk is mainly around cache invalidation/build-root scoping and potential completion regressions in edge cursor positions.

Overview
Adds Elixir struct field auto-completion for %Module{...} by introducing a new BEAM CodeIntel op (struct_fields) that loads a compiled struct module and returns its sorted field names.

The LSP server now detects struct key vs value cursor positions, serves field-key completions (with field: insertion), and avoids offering field completions in value positions; value positions instead prioritize local variable completions. Struct fields are fetched asynchronously via a new per-build-root cache with invalidation on file reindex/removal and BEAM process eviction, plus document-open/change prewarming based on struct literals found in the buffer.

Completion trigger characters are expanded (including space) with gating logic to avoid firing on ordinary whitespace, and tests are added for struct context parsing, caching/invalidation, prewarm behavior, and the new completion behaviors.

Reviewed by Cursor Bugbot for commit 7823a10. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7823a10. Configure here.

Comment thread internal/lsp/server.go
Detail: "variable",
SortText: "000_" + varName,
})
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable sort priority leaks into non-struct completions

Medium Severity

The addVariableCompletion helper unconditionally sets SortText: "000_" + varName, which forces variables to sort before all other completions. This was intended only for struct value positions (where variables are the likely target), but the same helper is used in the regular funcPrefix != "" path too. Previously, variable completions had no SortText and sorted naturally alongside functions. This changes the ordering behavior of all non-struct completions as a side effect.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7823a10. Configure here.

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.

1 participant