posit-dev / positron

Positron, a next-generation data science IDE
Other
2.31k stars 68 forks source link

R: Break styler dependency for code formatting #2251

Open jmcphers opened 6 months ago

jmcphers commented 6 months ago

Currently, we rely on styler to format R code. This has been a big time-saver when building out the initial implementation since code formatting is complicated and styler does a great job! However, this is not ideal in the long run for a number of reasons:

lionel- commented 3 months ago

With https://github.com/posit-dev/amalthea/pull/329, we now have a mechanism for indentation rules. They currently only deal with some edge cases that the frontend doesn't handle well. If we implemented a complete set of rules, which should be 1 or 2 weeks of work, we could use this as a rudimentary formatter. The formatter wouldn't do any other whitespace formatting such as line splitting but it would be fast, work on invalid code, be consistent with the as-you-type indenter, and could be use for format-on-save and format-on-paste.

Until we have a more complete formatter the line-splitting aspects can be achieved manually with codegrip (it would be nice to reimplement it in Ark).

jmcphers commented 2 months ago

Feedback from a beta user who is frustrated with styler because we can't use it while R is busy doing something else (another drawback). https://github.com/posit-dev/positron-beta/discussions/226