Skip to content

Add mechanism for chaining formatters #44

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

Open
dbarnett opened this issue Jul 6, 2015 · 3 comments
Open

Add mechanism for chaining formatters #44

dbarnett opened this issue Jul 6, 2015 · 3 comments

Comments

@dbarnett
Copy link
Contributor

dbarnett commented Jul 6, 2015

For some types of files you might want to run more than one formatter, for instance sort C++ includes (which clang-format doesn't handle) and then format with clang-format. Could codefmt support configuring a list of formatters instead of a single formatter? E.g.

AutoFormatBuffer sortincludes,clang-format
let b:codefmt_formatter = ['sortincludes', 'clang-format']
@dbarnett
Copy link
Contributor Author

Our hacky solution when this came up (for imports+formatting in java) was to define a little one-off formatter with its own formatter name that delegated and called formatter A then formatter B.

As noted in #178, you can't just invoke :AutoFormatBuffer twice and its docs don't explicitly explain it'll replace any previous autoformatting each time you invoke it.

@TamaMcGlinn
Copy link
Contributor

I think my hacky solution is a bit easier than what you describe, since I only needed to add a function to do the delegation, instead of a whole formatter.

@dbarnett
Copy link
Contributor Author

Yes, that's probably close to what I would've done as a one-off workaround. For our purposes on the java thing, we were solving a common issue and couldn't plop arbitrary autocmds into everyone's vimrc.

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

2 participants