Git Product home page Git Product logo

Comments (6)

smschauhan avatar smschauhan commented on August 22, 2024

I was looking for autocomplete support for ace earlier but ended up with this issue, which was closed 4 months ago. Then I see this long running thread. I also did find this commit, which just confuses me.

Something tells me that they don't have a great support for autocomplete?

from rcloud.

cscheid avatar cscheid commented on August 22, 2024

There's this, which has been merged: ajaxorg/ace#1189

from rcloud.

gordonwoodhull avatar gordonwoodhull commented on August 22, 2024

Yayayay! How do we get the words to complete with?

from rcloud.

cscheid avatar cscheid commented on August 22, 2024

There's several steps to this.

First, we need a function that takes the current cursor position and isolates the "relevant R statement". There might be R code that does this (@s-u, help here?). Here are some relevant use cases, where I'm using <> to denote the position of the cursor.

First, trivial cases:

x <- rno<>

This should return rnorm, etc. Then, almost-as-trivial:

x <- 5; y <- rno<>

Then, a little more annoying, since it mixes markdown:

# Some title

A paragraph

```{r}
x <- rno<>

This takes some annoying parsing code duplication with knitr, but I see no way around it.

from rcloud.

cscheid avatar cscheid commented on August 22, 2024

Assuming we can isolate the latest incomplete R statement, the next step is to crib the rcompgen.completion function from the R graphical client:

> rcompgen.completion
function (x) 
{
    utils:::.assignLinebuffer(x)
    utils:::.assignEnd(nchar(x))
    utils:::.guessTokenFromLine()
    utils:::.completeToken()
    utils:::.CompletionEnv[["comps"]]
}

With that,

> rcompgen.completion("rno")
[1] "rnorm"

> rcompgen.completion("x <- rnorm(")
[1] "n="    "mean=" "sd="  

> rcompgen.completion("y <- 5; x <- rnorm(")
[1] "n="    "mean=" "sd="  

It's smart enough to pluck the last statement by itself, so it might just be a matter of isolating the last R block.

from rcloud.

gordonwoodhull avatar gordonwoodhull commented on August 22, 2024

Pushing basic support for this. Required a few changes to mode-r.js and ext-language_tools.js which I'm not completely sure about and which will need to be reapplied or rethought the next time we upgrade ace.

(See the commit messages.)

from rcloud.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.