vim-jp/vim-cpp

Lambda indentation

x37v opened this issue · 6 comments

x37v commented

vim indenting is very poor for c++ lambdas, if someone has an indent file to share that resolves that, that would be great!

👍

I want some example that can make sure broken indentation...

x37v commented

Its actually not lambdas alone, its lambdas as passed to functions:

#include <functional>
#include <cstdlib>

void foo(std::function<bool(int)> f) {
  f(rand());
}

int main(int argc, char * argv[]) {
  int i = 0;
  //indenting looks fine
  auto f = [&i](int input) -> bool {
    if (input) {
      i = 12;
      return true;
    }
    return false;
  };
  f(rand());

  //really terrible indenting
  foo([&i](int input) -> bool {
      if (input) {
      i = 12;
      return true;
      }
      return false;
      });

  std::vector<int> v({2,3,4});
  //really terrible indenting
  for_each(v.begin(), v.end(), [](int x) {
      if (x == 2)
      cout << "2";
      else {
      cout << "not two" << endl;
      }
      });
  return 0;
}

👍

This repository doesn't contains indent/cpp.vim. So please report it to vim-dev.