-
Notifications
You must be signed in to change notification settings - Fork 12
Extensions to R / RStudio's autocompletion system #52
Comments
@kevinushey yeah, that would be nice. |
Definitely think this could be useful, I experimented a little with this for base R's completion at https://github.com/tidyverse/readxl/pull/320/files. People completions independently won't work well because you can only define one custom completion function at a time. But a completion package package authors can use to register completion functions and will handle the fallbacks for you will work well. We also need a way to hook into RStudio's completion machinery and provide helper functions to make registration of completion functions easier. |
Ideally we'd have some way to take advantage of the file autocomplete, but with some function that filter the list of files. |
Here's the infrastructure I'm imagining: We could develop an R package (call it Suppose we wanted to register an autocompleter for # imagine this living in a package's .onLoad or similar
autocomp::register_completer("shiny::runExample", "example", function(token) {
examples <- list.files(system.file("examples", package = "shiny"))
types <- rep(autocomp::completion_types$FILE, length(examples))
autocomp::completions(examples, types)
}) The first argument is used to define the package + function name; the second the argument for which this completer should be registered, the third the actual completion function (which should return a set of completion results). The 'token' object would simply be the R code lying before the user's cursor; we can think about what other context might need to be stuffed in there. The R package could register its top-level own custom completer (ie, by defining |
Application numero uno: autocompleting |
@jennybc from your history. |
Jenny, just use https://github.com/jimhester/autoinst 😜 |
@jimhester it must be magical if it knows what I am about to install from GitHub. :) |
Well the lookup has to error first, but it uses http://rpkg.gepuro.net/ to figure out GitHub packages, which is clearly not perfect, but it works pretty well. |
Check my comment on ropensci/unconf18#65 (comment) Keeping this in case anyone is interested in this matter. Just a prototype which is doing following things
It can be extended to any custom packages/ functions I guess. |
It would be handy to allow packages to register their own autocompletion routines for certain functions. A simple example might be
shiny::runExample()
-- users might writeThe autocompletion system could then provide the set of available examples as autocompletion candidates.
The text was updated successfully, but these errors were encountered: