Provide completions in the "value" position
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 337
- Forks
- 32
- Avg merge
- 8d 17h
- Merged PRs (30d)
- 11
Description
This is a variation / follow-up on #770.
We generally don't provide completions in the "value" position, in the sense of fn(name = value). This feels weird to me. It's admittedly a somewhat pedantic point, but I don't think it's pure pedantry. It feels like this violates the logic of how completions should work.
Pro tip: An explicit gesture to get completions is Ctrl/Cmd + Space. This works in some contexts where, say, pressing "tab" inserts a literal \t vs. triggering completions.
Consider this code:
a_kinda_long_name <- letters[1:3]
another_long_name <- letters[4:6]
append(x = a_kinda_long_name, y = another_long_name)
Below I indicate cursor position with @.
If you explicitly ask for completions at x = @, you get 'No suggestions'.
But as soon as you type anything, e.g. x = a@, you get dozens of completions, including a_kinda_long_name and another_long_name.
It feels like the implicit contract is that the completions for x = an@ are a subset of the completions for x = a@ are a subset of the completions for x =@. And we're currently violating that.
You can actually see that in this recording, where I request completions before I've typed anything, then get stuck in the land of 'No suggestions' until I backspace all the way back to the "=":
https://github.com/user-attachments/assets/bc71ed5e-7447-4c12-9317-bf5b1a1a91e8
The place to intervene is around here, but we don't yet have an easy way to add something that is morally is_value_position(node) to this condition:
(Side note: I also noticie some duplication in the above completion lists 🤔. I have some ideas about that. But it's a separate matter, in any case.)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in crates/ark/src/lsp/completions/sources/composite.rs around lines 77-78, where the issue identifies the completion-source condition to change. Reproduce the R example with the cursor after x =, then trace how value-position detection is represented; done means explicit completion requests there return the same relevant suggestions available after typing a prefix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r, rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100