R-Box icon indicating copy to clipboard operation
R-Box copied to clipboard

a couple of enhancements for auto-complete

Open faridcher opened this issue 8 years ago • 6 comments

In our terminology an object could be:

  • a dataset of any type (data.frame, vector, list, s4 object)
  • a function
  • an environment
  • hidden objects starting with .
  • a package

workspace required (active r session)

  • [ ] also show all objects present in the interactive session i.e. the search() path (.GlobalEnv etc)

workspace not required

  • [ ] typing a list (data.frame) with $ shows its components i.e. datasets::ability.cov$. if the dataset is not documented, it requires an R session.
  • [ ] typing a s4 object with @ shows its possible slots i.e. move::fishers@. if the dataset is not documented, it requires an R session.
  • [ ] assign icons to the items based on the type of object possibly similar to that of Rstudio. Not sure if it is possible in ST!
    • [ ] function,
    • [ ] list,
    • [ ] data.frame (s4 objects),
    • [ ] vectors,
    • [ ] environment,
    • [ ] package
  • [ ] descriptions of items and arguments along their names
  • [ ] only show possible arguments when the cursor is placed inside the parenthesis of a function call.
  • [ ] sort the results in any context
  • [ ] also export datasets
    • [ ] i.e. packageName with :: also show the exported objects/datasets (beside functions). for example datasets:: lists all the datasets.
  • [ ] always on as typing (even without ctrl+space. a on/off switch could be very useful)
  • [ ] also show non-exported functions and objects using ::: notation (for example stats:::C_acf). if you type stats::, only show the list of exported objects and when you type stats:::, also show non-exported objects
  • [ ] roxygen tags support, i.e.typing #' @ proposes possible roxygen tags.

faridcher avatar Sep 10 '17 06:09 faridcher

Thanks for the suggestions. I just want to reply for first point now.

auto-complete of list objects by typing $. for example alist$ pops up a context menu suggesting available components of the list

It is unfortunately not very possible because Sublime Text is not attached with any R console, it is just a pure editor without knowledge about an R instance.

The other points are quite valid, I'll consider them.

randy3k avatar Sep 10 '17 07:09 randy3k

The list components suggestion could work conditioning on the presence of a R console. Right now, you can send commands using SendCode; Is the reverse not possible? i.e. getting a response from the console. As you may be aware, getting possible list components is just a call to names function. I am transitioning from Rstudio to totally rely on ST3 (+packages) and am wondering to what extent I can rely on it. thanks

faridcher avatar Sep 10 '17 18:09 faridcher

Sending code to R console is very different from loading the workspace from it though.

randy3k avatar Sep 10 '17 19:09 randy3k

We don't have to load the workspace. I haven't done any development in sublime using python but the question is whether there is a way to get a textual response from the R console in a sublime python session? Assuming its feasibility, one can send ls() to the R-console and load the response character vector in sublime as the auto-complete suggestion.

I am note sure but maybe something like this!

faridcher avatar Sep 10 '17 21:09 faridcher

It is possible to connect a R session to a text editor by mean of socket connections. Nvim-R has done a great job with this idea. However, it is not an easy task also some how limited. For instance, the R session needs to be launched by the text editor and tie with a particular file.

randy3k avatar Sep 11 '17 01:09 randy3k

In any case, If this becomes feasible, it opens a new door for R-Box, potentially enabling a wide range of new features.

faridcher avatar Sep 11 '17 05:09 faridcher