clang-format wrapping of trailing comments

Viewed 148

Is there a way to tell clang-format to break and align trailing comments behind #defines, but leave the macro as it is?

What I write:

#define IDENTIFY_MODE_BSP_EVT    BSP_EVENT_KEY_3  // Button event used to enter the Bulb into the Identify  mode.
#define ZIGBEE_NETWORK_STATE_LED BSP_BOARD_LED_2  // LED indicating that light switch successfully joind  Zigbee network.
#define BULB_LED                 BSP_BOARD_LED_3  // LED immitaing dimmable light bulb.

What I want clang-format to do:

#define IDENTIFY_MODE_BSP_EVT    BSP_EVENT_KEY_3  // Button event used to      \
                                                     enter the Bulb into the   \
                                                     Identify  mode.
#define ZIGBEE_NETWORK_STATE_LED BSP_BOARD_LED_2  // LED indicating that light \
                                                     switch successfully joind \
                                                     Zigbee network.
#define BULB_LED                 BSP_BOARD_LED_3  // LED immitaing dimmable    \
                                                     light bulb.

What clang-format does:

#define IDENTIFY_MODE_BSP_EVT \
    BSP_EVENT_KEY_3  // Button event used to enter the Bulb into the Identify
                     // mode.
#define ZIGBEE_NETWORK_STATE_LED \
    BSP_BOARD_LED_2  // LED indicating that light switch successfully joind
                     // Zigbee network.
#define BULB_LED BSP_BOARD_LED_3  // LED immitaing dimmable light bulb.
#define LED_CHAIN_DOUT_PIN \
    NRF_GPIO_PIN_MAP(0, 5)  // GPIO pin used as DOUT (to be connected to DIN pin
                            // of the first ws2812 led in chain)

My .clang-format file so far:

BasedOnStyle:           Google
AlignConsecutiveMacros: true
AlignTrailingComments:  true
ColumnLimit:            80
0 Answers
Related