-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expand Session watcher to help auto complete with NSE (tidyverse syntax) #323
Comments
For reference Rstudios implementation of this simply looks at the top most object for which names to use in the autocomplete, for example As you can see Rstudio just offers all the names of iris in the autocomplete even though none of them exist after the |
At @andycraig & @renkun-ken , Which files are related to the current session watcher autocomplete. For example when session watcher is enabled I am able to do this: But I'm struggling to work out where in the code provides this functionality |
On mobile now. If I remember correctly, The session watcher completion is implemented in extension.ts: provideCompletionItems, getBracketCompletionItems, etc. Please take a look at https://github.com/Ikuyadeu/vscode-R/blob/master/src/extension.ts#L224-L316. |
FYI, it is how RStudio implemented it: https://github.com/rstudio/rstudio/blob/7fd3ff2ba1b579952baceaddd6fcb2ca4c88d186/src/cpp/session/modules/SessionRCompletions.R#L1963 |
@gowerc I come up with an easy approach to this at https://github.com/renkun-ken/languageserver/tree/token-completion which simply put all symbols that appear in the same document into the completion list, which will be helpful to complete symbols that already appear in the document, including symbols in the pipelines. You might have a try on this any let me know if this is helpful. |
Thanks for looking into this, will try and find some time to have a play ! |
To provide completion items in a pipe expression, without a parser, it is a bit trickier to detect the names of the variables to show completions, although we already have the my_dt %>%
mutate(var3 = test) %>%
select(var1, var2, var3) As a starting point, we should detect |
My totally abstract idea by now is to dynamically compute Edit: Just for curiosity, apparently even with no rows at all
Correctly returns:
Even with a |
I'm afraid we cannot execute user code in any way because it might have side effects to user sessions. Imagine user in-place mutate or remove columns or execute some code that has important side effects like my_df %>%
filter(var == 4) %>%
select(path) %>%
remove_files() |
@gowerc @danielbasso would you like to try PR #530 by installing the artifact in https://github.com/Ikuyadeu/vscode-R/actions/runs/500273775? |
Sure will try and give it a test this weekend ! |
Sorry, it is not very useful at the moment since it only works with very limited cases. I'll improve it later. |
Same here!
No worries man, this is volunteer work, do it at your own pace. I'll try to help whenever I can. |
@gowerc @danielbasso You could try the latest development build and see if it works for you. |
Hey @renkun-ken , First off this is awesome, than you for your work on this !! It wasn't clear to me from the above conversation if inline variables (those created within the pipeline) were supposed to be made available in this update. For me at least the base dataframes variables are available but not those that are defined inline: EDIT: You can't see it in the screenshot due to the tooltip but I had defined a variable called |
@gowerc If I'm understanding it correctly, then you want x <- iris
x %>%
mutate(score = Petal.Length + Petal.Width) %>%
filter() The autocompletion triggered by |
Indeed, would be great if it could also be included in the autocompete triggered by |
I filed REditorSupport/languageserver#369 that adds |
Just starting to try to use R extension in VS Code to replace RStudio. It seems to me that the original ask of this issue has still not been addressed. If I initialize a new file, then using Specifically: library(dplyr)
iris %>%
select( The intellisense that appears after the Am I doing something wrong? Or is this a feature that "won't be done", hence this issue being closed? Thanks for your help! |
Here |
I had a suspicion that if it does not work with To test, I created a I can confirm that you are correct; when I subsequently use This is really terrific! Thank you for this extension and all of its features! 🥳 |
It would be awesome if the session watchers autocomplete could be expanded to work with non-standard evaluation for example when using dplyr's mutate/select/etc.
I.e. when writing something like:
Then have the auto-complete popup with the list of variables within the iris dataset.
The text was updated successfully, but these errors were encountered: