Formatting R code which is typically managed in per-project environments can be quite annoying 1. For formatting, defining a global environment with pixi makes life easier.

1pixi global add --environment r_env r-styler --expose pixiR=R

This globally managed renamed R executable can then be used for apheleia in doom or in scripts:

1(set-formatter!
2  'rstyler
3  '("pixiR" "-s" "--no-save" "--no-restore" "-e" "styler::style_text(readLines(file('stdin')))")
4  :modes '(ess-r-mode))

Which works well, isolating the formatting logic from transient per-project states and fragile global state.


  1. since I do not keep R installed system-wide ↩︎