Feature request: better auto indent
See original GitHub issueWould be really great if the autoIndent worked better, preferably according to standard style guides. (see https://google.github.io/styleguide/Rguide.xml and http://adv-r.had.co.nz/Style.html)
When a line ends with an open bracket of some sort ((, [, {
) indentation kicks in according to whatever setting you have. This example already works as it should:
a <- b[
c >= 3 &
d == 2
]
However when a bracket is open, but there is something after it on the same line, indentation should be all the way to the opening bracket, not just the default number of spaces. For example:
bad way:
a <- b[c >= 3 &
d == 2]
correct:
a <- b[c >= 3 &
d == 2]
That is, when pressing enter after the &
sign, indent should be 7 spaces instead of 2. Right now, when one presses enter after the &
sign, no indent is applied at all.
Maybe one could implement the styler package to do it automatically (http://styler.r-lib.org) using the formatOnSave option in VsCode.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (2 by maintainers)
Just found an extension called “Indent To Bracket” that would do indent to open bracket.
The version of the language server on GitHub supports customised
styler
formatting: https://github.com/REditorSupport/languageserver/blob/master/README.md#customizing-formatting-styleI think customised indenting should be supported via the
styler
package rather than directly in vscode-R, so I’m going to close this. All the indenting formats described in this issue look good to me, so if they’re not already implemented instyler
please consider adding them there!