posit-dev / posit-dev/ark

Provide completions in the "value" position

Open
#812 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: language server
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'.

Image

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.

Image

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:

https://github.com/posit-dev/ark/blob/2013ca15704284d36ea0908a3b497832dfdff49f/crates/ark/src/lsp/completions/sources/composite.rs#L77-L78

(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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.