尾随注释的 clang 格式包装

问题描述

有没有办法告诉 clang-format 中断并对齐 #defines 后面的尾随注释,但保持宏原样?

我写的:

#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.

我想让 clang-format 做什么:

#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.

clang-format 的作用:

#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)

到目前为止我的 .clang 格式文件:

BasedOnStyle:           Google
AlignConsecutiveMacros: true
AlignTrailingComments:  true
ColumnLimit:            80

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)