1

I have been trying to get an indentation for the constructor which looks like this:

ClassName::ClassName(const std::string &id,
                     std::shared_ptr<AbstractInterface> object,
                     bool isDynamic) :
    m_id(id),
    m_object(object),
    m_isDynamic(isDynamic),
    m_state(ClassState::CREATED)
{
}

I want the arguments to be indented so they are aligned with the first parenthesis for the argument list, but the initializer list should be indented by 4 spaces (which is my regular indent size).

I have generated my uncrustify config from a code sample file which includes this code example. I have seen that I can use indent_ctor_init, but this is set to 0 in the generated config.

Is this the config option I should be using for the initializer list?

I also have not been able to find where to set the indentation for the arguments so I don't get a newline before the first argument.

This is what I am getting now:

ClassName::ClassName(
    const std::string &id,
    std::shared_ptr<AbstractInterface> object,
    bool isDynamic) :
    m_id(id),
    m_object(object),
    m_isDynamic(isDynamic),
    m_state(ClassState::CREATED)
 {
 }
thenor
  • 21
  • 2

2 Answers2

1

I managed to find a solution. Not sure exactly which options were incorrect. I found another configutation file to start from and then changed the indent_continue option and the nl_func_decl_start (and possibly another I have forgotten) and now it looks as I want.

thenor
  • 21
  • 2
0

For uncrustify 0.71.0 I got this to work with

indent_continue                 = 4
nl_constr_colon                 = force
CodeMonkey
  • 4,067
  • 1
  • 31
  • 43