vim-jp / vim-cpp

c or cpp syntax files
145 stars 44 forks source link

Lambda indentation #12

Closed x37v closed 9 years ago

x37v commented 11 years ago

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

koron commented 11 years ago

:+1:

mattn commented 11 years ago

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

x37v commented 11 years ago

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;
}
oblitum commented 10 years ago

:+1:

crazymaster commented 9 years ago

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

crazymaster commented 9 years ago

Oops, it was reported to vim-dev. https://groups.google.com/d/topic/vim_dev/Hr_vGp_-JxM/discussion https://groups.google.com/d/topic/vim_dev/IAnQft51UEY/discussion