-
Notifications
You must be signed in to change notification settings - Fork 122
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
Magrittr pipes trigger indent on newline #321
Comments
@gowerc Thank you for the suggestion! This would be a good feature. The slightly tricky thing here is that the indentation should not increase with subsequent pipes:
Hopefully we can do it using |
Actually looks like |
@gowerc REditorSupport/languageserver#209 implements on-type-formatting on user input at expression-level based on a backward parsing strategy. With |
Thanks @renkun-ken , This indeed does work. Only caveat would be that it also comes with the automatic formatting as well (i.e. converting This this does what I need so thank you very much :) @andycraig , I still think it would be nice to have an editor specific solution to this (if you have the desire to implement it) but I do have a workaround now so feel free to close the ticket if you are not interested :) |
@renkun-ken I’d quite like this feature too so that it’s there even when |
I thought this would be a matter of adding this to
But when I do that and type
and hit enter, this is the result:
So it seems that the indentation rule is erroneously triggering the |
I tried the following in
The results were: I'm struggling to think of a pattern that would work in both cases. I tried only using the |
@gowerc Thank you for working on this! I'll have a proper look this weekend. |
Just to add my findings so far though (as it's not overly well documented) You can set the following in the configuration.json file:
You can then also set additional on-enter rules which are well documented, though one thing I noticed is that any indentation that is added here i.e. The problem I was running into is that there is no meaningful way to distinguish the first use of the pipe (to thus do the initial indent) from subsequent uses of the pipe. I tried to play around with multiple line regex's using |
I think this is probably the best option for now but I want to have a little bit more of a think/experiment before we incorporate it. |
I'm curious about how the text edits are handled if |
I've had a bit more of a think and haven't come up with anything else. I think it would be okay to incorporate this provided there's no conflict between vscode-R formatting and languageserver formatting when |
It would be good to have indentation for parenthesis, brackets and braces specified in The open question is whether it will work properly together with format on type: #321 (comment) @gowerc Are you interested in doing some testing of how automatic indentation works together with format on type? If not I can work on this. |
Apologies but I just don't have time at the moment to assist :( |
@gowerc No problem, thank you for all your research! I will do some testing and see if I can get Reindent Lines working. |
Guys I am having something strange. My vscode-R with R LSP Client and languageserver installed in a Intel Mac and a M1 Mac. All configurations the same. I cannot get the: "editor.formatOnType": true,
"editor.formatOnSave": true,
"editor.formatOnPaste": true to work in the M1 and it is flawless in the Intel. Same VS Code versions and extensions installed in both systems. |
This issue is stale because it has been open for 365 days with no activity. |
This issue was closed because it has been inactive for 14 days since being marked as stale. |
Any plans to implement this capability? |
Not sure if this is the right place for this request, please delete if not !
Would it be possible to get magrittr's pipes
%>%
to be treated akin to brackets where an automatic indent happens if you press enter on a line whose last symbol is the pipes?i.e.
having
and pressing
enter
after the%>%
but before themutate(...)
would result inAt the moment when I do this it just comes out as:
The text was updated successfully, but these errors were encountered: