Skip to content

Allow configuring tools to inherit vim's indent and line length settings #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dbarnett opened this issue Jan 31, 2015 · 2 comments
Closed

Comments

@dbarnett
Copy link
Contributor

Since vim already has settings that correspond to indent size and max line length, it would be great to have an option to hook those up to automatically match vim's 'shiftwidth' and 'textwidth' settings, since I've already configured formatting settings once and shouldn't be forced to repeat myself. There could be a single global setting to enable the feature and a buffer-local override so you could still work around corner cases.

The indent and line length settings will vary from formatter to formatter and support will need to be implemented per-formatter. It could either be explicitly part of the API or formatters could just check the relevant preferences and vim settings themselves in the formatter code.

@dbarnett
Copy link
Contributor Author

My comments from unrelated PR #54:

My naive preference would be to
a) Have a global (+local?) option to enable sending shiftwidth, textwidth, and other editor settings to formatters, and
b) Give custom .clang-format rules higher precedence.

The reason is that a lot of casual vim users don't configure shiftwidth, textwidth, etc. properly but will still expect codefmt to not cause formatting "regressions", like formatting based on their broken settings instead of custom project configuration.

Side note: http://editorconfig.org/ looks interesting and I'm wondering if we can consolidate some configuration with that somehow.

My concern is that it adds a new way for users to accidentally get formatting wrong. I'm just hoping to add an explicit opt-in or some heuristics to ensure the shiftwidth we're passing through to formatters is more trustworthy than the formatters' defaults first.

@dbarnett
Copy link
Contributor Author

I gave this idea some more thought and I've decided this shouldn't be automated (though it could still be possible to manually configure flags to pass to formatters as in #66 or #24). You shouldn't get different formatting behavior if you invoke a tool from inside vim vs. standalone. EditorConfig is the ideal solution and Vim shouldn't be in the business of brokering style settings between configs and tools. Formatters tools should be able to detect and respect .editorconfig settings (e.g., google/yapf#826 for yapf).

See editorconfig/editorconfig-vim#141 for some additional context.

Closing this bug, but feel free to discuss further if you disagree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant