Hi,
In general I'm quite happy with vim's default C(++) indentation style (or rather, together with cinoptions=+l1 (indent just by 1sw after a case:) and +=h0 (don't indent after public:)). In particular, I like the fact that argument lists are indented by 2sw (the examples below use sw=2, just as a reference):
// Case 1: 2-space indent.
if (foo) {
bar;
}
// Case 2: 4-space indent.
some_func(
arg_1,
arg_2);
However, vim is by default unable to recognize a C++ braced-initializer list, which effectively have similar semantics as parentheses in a function call; it will indent
// Case 3: oops, 2-space indent, but 4 would be preferred.
some_type{
arg1,
arg2};
probably because, well, it does not distinguish this with Case 1 (and probably because braced initializer lists are a "relatively" recent addition to C++). In fact it "should" be easy to distinguish Case 1 from Case 3, as Case 1 always (AFAICT?) has a closing parenthesis just before the opening brace (excluding whitespace) (... and you may also want to check whether the word before the previous word is struct/class/union/namespace).
Does anyone know of a setting or a plugin which would solve this issue?
Just to be clear, I am not particularly interested in plugins that shell out to clang-format and other external tools, because these are far too opinionated and rigid IMO.
Thanks!
Antony
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment