posit-dev / posit-dev/ark

Improvements re: completing function as reference vs call

Open
#1,002 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

I think the last rounds of improvement re: function completions were in #819 and #754. For now, the heuristic for deciding whether to treat as a function reference vs. call is based on whether we're inside a list of special functions:

https://github.com/posit-dev/ark/blob/1577d04d2bc61e1484f8e0a57b99fe558b39a57c/crates/ark/src/lsp/completions/function_context.rs#L158-L166

Two examples of sites where a user wants a function reference (but gets parentheses anyway) came up in https://github.com/posit-dev/positron/issues/9044#issuecomment-3734419418

library(tidyverse)

penguins |> relocate(where(is.character()))
map(1:3, mean())

The current list only contains functions from the base and utils packages. But tidyselect::where() is a pretty clearcut case. More complicated, but also compelling is purrr::map() (and base equivalents). Not sure which will come first: improving the ad hoc list or improving the whole approach, but opening this as a place to track concrete examples that folks mention.

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

Read crates/ark/src/lsp/completions/function_context.rs around lines 158-166, then compare the existing special-function heuristic with the tidyselect::where() and purrr::map() examples in the issue. Review the referenced issues for context and determine whether the work should extend the list or replace the approach; done criteria are not specified beyond improving function-reference versus call completion behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
r, rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.