You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
David Barnett edited this page Aug 6, 2015
·
2 revisions
If you have a formatter codefmt doesn't support that you want to integrate with codefmt, you have two choices:
Implement a codefmt extension plugin for your formatter.
Add it directly into codefmt.
For robust, publicly available formatters, adding them directly into codefmt is usually fine. See the FAQ for reasons to go with one approach over the other.
Writing an extension plugin
TODO: Details
Adding a formatter into codefmt directly
The first step for integrating a new formatter with codefmt directly is always to file a feature request for your formatter at https://github.com/google/vim-codefmt/issues if one hasn't already been filed.
Next, read through :help codefmt, have a look at the other formatters implemented in autoload/codefmt.vim for inspiration, and get started implementing the formatter API.
TODO: Specifics
FAQ
Why integrate it with codefmt? Why not just shell out to the formatter with :%!SOMEFORMATTER?
Codefmt formatters work better in a lot of corner cases and support several nice features like
a simple format-on-save mechanism
range formatting
motion mappings to format specific code blocks, etc.
The quick and dirty :%!SOMEFORMATTER approach also won't have any error handling. Once you add error handling and such, the advantages of the quick and dirty approach vs. a codefmt formatter are less obvious.
Why would I want to implement a separate extension plugin instead of adding the formatter into codefmt directly?
The main reasons are if the formatter isn't ready for wide adoption, if it has dependencies that are hard to install, or if it's a special-purpose/proprietary formatter.