Autocomplete for packages other then base #2

Closed
hugeme opened this Issue Nov 27, 2016 · 6 comments

Comments

Projects
None yet
4 participants
@hugeme

hugeme commented Nov 27, 2016

Thank you for providing autocomplete for R in atom.

I'm not fully understand the behavior however. Is there any autocomplete for packages other then base? I have tried with several packages like ggplot or dplyr but I just get suggestions for R base.

Thx
Eugene

@pimentel

This comment has been minimized.

Show comment
Hide comment
@pimentel

pimentel Nov 28, 2016

Collaborator

@hugeme It seems that you would need to add the package to https://github.com/guillaumechaumet/autocomplete-R/blob/master/R/scrapeRdoc.R#L102

That being said, there is a comment there that shows an error parsing the method package. My guess is that this scraping code is difficult to write in the general case.

Perhaps the easiest (naive) thing to do is look at .libPaths() + '/library/*/INDEX' to build a list of function names for each package. This would give you very basic high level completion but won't give you the very detailed expansions that you currently get.

In any case, I also came here to ask for autocomplete for other packages :-) it would be cool to perhaps in the future have a button in settings that says 'rebuild documentation' and then scrapes your installed packages for documentation. I am happy to help in any way I can as this is a pretty cool project!

Thanks for all the hard work, @guillaumechaumet !

Collaborator

pimentel commented Nov 28, 2016

@hugeme It seems that you would need to add the package to https://github.com/guillaumechaumet/autocomplete-R/blob/master/R/scrapeRdoc.R#L102

That being said, there is a comment there that shows an error parsing the method package. My guess is that this scraping code is difficult to write in the general case.

Perhaps the easiest (naive) thing to do is look at .libPaths() + '/library/*/INDEX' to build a list of function names for each package. This would give you very basic high level completion but won't give you the very detailed expansions that you currently get.

In any case, I also came here to ask for autocomplete for other packages :-) it would be cool to perhaps in the future have a button in settings that says 'rebuild documentation' and then scrapes your installed packages for documentation. I am happy to help in any way I can as this is a pretty cool project!

Thanks for all the hard work, @guillaumechaumet !

@pimentel

This comment has been minimized.

Show comment
Hide comment
@pimentel

pimentel Nov 28, 2016

Collaborator

So, I did a bit of digging and it seems that this might be able to be done a bit easier (maybe?) using the lazyLoad() function.

lazyLoad(paste0(.libPaths(), '/base/help/base'))

Your environment will now have documentation for every single function in base.
You can look at the \usage{} section and parse this to generate the completions.json file.

Sorry if you know this already or if I am missing something obvious.

Again, happy to help with this if you would like.

Collaborator

pimentel commented Nov 28, 2016

So, I did a bit of digging and it seems that this might be able to be done a bit easier (maybe?) using the lazyLoad() function.

lazyLoad(paste0(.libPaths(), '/base/help/base'))

Your environment will now have documentation for every single function in base.
You can look at the \usage{} section and parse this to generate the completions.json file.

Sorry if you know this already or if I am missing something obvious.

Again, happy to help with this if you would like.

@guillaumechaumet

This comment has been minimized.

Show comment
Hide comment
@guillaumechaumet

guillaumechaumet Nov 28, 2016

Owner

I am very pleased that you guys try to improve this package.

@hugeme The scrape method (used here) is not adapted for non-base (methods, graphic,util, etc.) packages. As @pimentel says, you could used the scrapeRdoc.R script to search and add new packages (ggplot2, etc).
But if you work with a lot of packages like me, it would be better to find another solution (by communication between atom.io and R) like RStudio or ESS. A package like Autocomplete-python is the aim of autocomplete-R.

Owner

guillaumechaumet commented Nov 28, 2016

I am very pleased that you guys try to improve this package.

@hugeme The scrape method (used here) is not adapted for non-base (methods, graphic,util, etc.) packages. As @pimentel says, you could used the scrapeRdoc.R script to search and add new packages (ggplot2, etc).
But if you work with a lot of packages like me, it would be better to find another solution (by communication between atom.io and R) like RStudio or ESS. A package like Autocomplete-python is the aim of autocomplete-R.

@rwatts3

This comment has been minimized.

Show comment
Hide comment
@rwatts3

rwatts3 Aug 16, 2017

Just want to add a note as I see it's been quite some time since this post was made.
Take a look at atom/atom-languageclient and atom/ide-typescript.
These are language server and language clients. It provides an api to talk to atom and frankly any text editor.

The overview

  • Language Server provides the backend for the intellisense "autocomplete"
  • Language Client "ide-typescript" "ide-java" is the client that talks to the server, and sends responses back to the editor. It's the middleman or bridge if you will. In this case atom-languageclient provides the gateway to talk to a server and send it's information back to the editor. If we can find a Language Server, it would be rather simple to build let's say an "ide-R" for atom.

rwatts3 commented Aug 16, 2017

Just want to add a note as I see it's been quite some time since this post was made.
Take a look at atom/atom-languageclient and atom/ide-typescript.
These are language server and language clients. It provides an api to talk to atom and frankly any text editor.

The overview

  • Language Server provides the backend for the intellisense "autocomplete"
  • Language Client "ide-typescript" "ide-java" is the client that talks to the server, and sends responses back to the editor. It's the middleman or bridge if you will. In this case atom-languageclient provides the gateway to talk to a server and send it's information back to the editor. If we can find a Language Server, it would be rather simple to build let's say an "ide-R" for atom.
@guillaumechaumet

This comment has been minimized.

Show comment
Hide comment
@guillaumechaumet

guillaumechaumet Aug 23, 2017

Owner

Thanks @rwatt3 for the info. I will investigate this.

Owner

guillaumechaumet commented Aug 23, 2017

Thanks @rwatt3 for the info. I will investigate this.

@guillaumechaumet

This comment has been minimized.

Show comment
Hide comment
@guillaumechaumet

guillaumechaumet Sep 21, 2017

Owner

@rwatts3 there is a project that aim to build a language server for R: https://github.com/REditorSupport/languageserver

Owner

guillaumechaumet commented Sep 21, 2017

@rwatts3 there is a project that aim to build a language server for R: https://github.com/REditorSupport/languageserver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment