radian-software / apheleia

🌷 Run code formatter on buffer contents without moving point, using RCS patches and dynamic programming.
MIT License
517 stars 73 forks source link

Sorry for the beginner question! #305

Closed ukiran03 closed 17 hours ago

ukiran03 commented 1 week ago

I want to set an offset of 4 using clang-format. Here is the code:

(use-package apheleia
  :init
  (setf (alist-get 'clang-format apheleia-formatters)
        '("clang-format" "--offset=4")))

It was not working as expected. Could you please help out?

ZharMeny commented 1 week ago

The --offset option works as intended with the example you provided, but it seems you misunderstood what the option does; it is used to start formatting from the offset of that much bytes since the beginning of the file. If you want to use 4 spaces for indentation instead, you can use "--style={IndentWidth: 4}" option, or create a .clang-format file instead.