timakro / vim-yadi

Yet Another Detect Indent
MIT License
15 stars 3 forks source link

Ignore lines with leading / after trailing strings #2

Closed Frederick888 closed 3 years ago

Frederick888 commented 3 years ago

Two configurations were added:

g:yadi_ignore_after_trailing:

If the preceding line of current one ends with any of the strings in this list, current line is ignored in DetectIndent.

g:yadi_ignore_with_leading:

If current line begins with any of the strings in this list, current line is ignored in DetectIndent.

Fixes #1.


This is an implementation of my comment at [1]. Default values for these lists should work for most C-like languages. If you don't want to change the default behaviour, I'm happy to clear out these defaults.

[1] https://github.com/timakro/vim-yadi/issues/1#issuecomment-798874367

Frederick888 commented 3 years ago

@timakro Could you please review this? Thanks :)

timakro commented 3 years ago

For over a month now I was holding off on dealing with this PR because I was not sure what to do with it. The way I feel is that this change makes too many assumptions about language and code style and hurts the transparency of the algorithm.

I can't help thinking that the character lists you chose might work for C-style languages but break the plugin for some different language completely. I dislike the code style this change is targeting anyways, namely choosing a different number of spaces for "continuation indents". So my snarky response would just be: fix your code style.

It would require a significant amount of users with the same request for me to change my mind about this.

Frederick888 commented 3 years ago

Thanks for putting thoughts into this. Unfortunately 'fixing my code style' is not an option for me.

For one they're not my personal projects; for another using wider continuation indentations, fixed or aligned with opening parentheses/braces/etc, is actually somewhat suggested:

  1. GNU C: https://www.gnu.org/prep/standards/html_node/Formatting.html#Formatting
  2. Google C++: https://google.github.io/styleguide/cppguide.html#Function_Declarations_and_Definitions
  3. LLVM C/C++: wasn't able to find anything on this in official doc, but can confirm clang-format output at https://zed0.co.uk/clang-format-configurator/
  4. Oracle Java: https://www.oracle.com/java/technologies/javase/codeconventions-indentation.html#1574

I understand it may not be very useful in your use cases. I guess for now I can simply maintain my own fork :)