REditorSupport / REditorSupport/languageserver

The pipe-bind operator =>

Open
#432 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
675
Forks
118
Avg merge
1d 37m
Merged PRs (30d)
11

Description

Currently, the pipe-bind operator => is disabled by default. It could be enabled by

Sys.setenv("_R_USE_PIPEBIND_" = "true")

It seems that the documentation does not mention it? Just to put a note here. Not suggesting that we should do anything about it at the moment.

mtcars |>
  transform(kmL = mpg / 2.35) |>
  d => lm(kmL ~ hp, data = d)

The XML parse tree of the third line is:

<expr line1="3" col1="3" line2="3" col2="29" start="102" end="128">
  <expr line1="3" col1="3" line2="3" col2="3" start="102" end="102">
    <SYMBOL line1="3" col1="3" line2="3" col2="3" start="102" end="102">d</SYMBOL>
  </expr>
  <PIPEBIND line1="3" col1="5" line2="3" col2="6" start="104" end="105">=&gt;</PIPEBIND>
  <expr line1="3" col1="8" line2="3" col2="29" start="107" end="128">
    <expr line1="3" col1="8" line2="3" col2="9" start="107" end="108">
      <SYMBOL_FUNCTION_CALL line1="3" col1="8" line2="3" col2="9" start="107" end="108">lm</SYMBOL_FUNCTION_CALL>
    </expr>
    <OP-LEFT-PAREN line1="3" col1="10" line2="3" col2="10" start="109" end="109">(</OP-LEFT-PAREN>
    <expr line1="3" col1="11" line2="3" col2="18" start="110" end="117">
      <expr line1="3" col1="11" line2="3" col2="13" start="110" end="112">
        <SYMBOL line1="3" col1="11" line2="3" col2="13" start="110" end="112">kmL</SYMBOL>
      </expr>
      <OP-TILDE line1="3" col1="15" line2="3" col2="15" start="114" end="114">~</OP-TILDE>
      <expr line1="3" col1="17" line2="3" col2="18" start="116" end="117">
        <SYMBOL line1="3" col1="17" line2="3" col2="18" start="116" end="117">hp</SYMBOL>
      </expr>
    </expr>
    <OP-COMMA line1="3" col1="19" line2="3" col2="19" start="118" end="118">,</OP-COMMA>
    <SYMBOL_SUB line1="3" col1="21" line2="3" col2="24" start="120" end="123">data</SYMBOL_SUB>
    <EQ_SUB line1="3" col1="26" line2="3" col2="26" start="125" end="125">=</EQ_SUB>
    <expr line1="3" col1="28" line2="3" col2="28" start="127" end="127">
      <SYMBOL line1="3" col1="28" line2="3" col2="28" start="127" end="127">d</SYMBOL>
    </expr>
    <OP-RIGHT-PAREN line1="3" col1="29" line2="3" col2="29" start="128" end="128">)</OP-RIGHT-PAREN>
  </expr>
</expr>

If the => operator is enabled and supported by default, we could make it behave like another kind of function and support scope completion, definition, hover, etc.

Contributor guide

No contributing guide indexed for this repository

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 with the issue's pipe-bind examples and XML parse tree, then inspect the language server's handling of R syntax and editor features. No file or test is named, and the report explicitly makes no request to act; a usable outcome would first require deciding whether default support is wanted and defining the completion, definition, and hover behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
devtools
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.