-
Notifications
You must be signed in to change notification settings - Fork 75
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
Provide option to have tab apply completion #229
base: master
Are you sure you want to change the base?
Conversation
I don't mind having the feature of committing completion with |
By the way, thank you for the contribution. |
try: | ||
return rcopy(rcall("class", reval(text))) == "function" | ||
except: | ||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is a robust way to detect if a token is a function. We may need to poke into how the token is determined: https://github.com/randy3k/rchitect/blob/master/rchitect/completion.py#L18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that this part of the code could be improved, but so far the parentheses are added without fail. In other words, I have not found a situation in which this doesn't work.
I can't find much in the way of documentation on completeToken
. It is used by the completeme
package. I looked at the source code for completeToken
and it seems like completeToken
guesses which function it is inside for argument completion, but I don't know how this might help us to identify the token as a function.
I'm hoping that you might have some ideas regarding the best way to determine if a token is a function😄
65210ee
to
f5bad69
Compare
I feel like tab to commit completion and adding parentheses after functions are two separate features. We should be able to enable one and disable the other and now you have tied the two features together. |
Yes, I agree with you, @randy3k, it will be better to have two independent features controlled by two independent settings. I will edit this PR to
What should the new setting be called?
|
The plan looks good to me. |
a1793b1
to
466f36f
Compare
@randy3k, I split the original feature into 5 independent features.
These features can be combined. Is 5 settings too many? Please let me know if any of the settings should be renamed. |
c202ef7
to
386c50f
Compare
386c50f
to
52ba013
Compare
So I can't break the habit of trying tab for completions. |
b161529
to
ac0e9cb
Compare
In #224, I requested a feature that adds parentheses after functions completed with
Tab
orEnter
.I decided the best solution will be to use
rchitect
to identify functions based on the string returned by the completer.This pull request implements the feature I requested (function completion with added parentheses), but also strives to make autocompletion work like in RStudio or the VSCode R extension. In VSCode and RStudio, tab applies completion instead of cycling through completion options, like in bash or zsh.
Currently, this feature is disabled by default, but it has to be enabled by adding
to
.radian_profile
.For more information, please take a look at this comment in #387.
To install radian with the
tab_apply_completion
feature, runpython -m pip install git+https://github.com/mskar/radian.git@tab_apply_completion
Note: This also completely changes how completion works:
Tab:
Enter:
TLDR:
previous behavior:
proposed behavior:
Changes:
Changed: when triggering completion with
Tab
, insert text that all options have in commonChanged: use
Tab
to accept only option or accept selectedChanged: do not move through options with not
Tab
andShift-Tab
Unchanged: use
Enter
to accept if completion menu is showingUnchanged: move through options with
c-n
andc-p
Unchanged: cancel completion with
c-g