google / vim-codefmt

Vim plugin for syntax-aware code formatting
Apache License 2.0
1.11k stars 114 forks source link

Does vim-codefmt support react jsx files? #169

Closed theahura closed 3 years ago

theahura commented 3 years ago

Basically the title! I couldn't figure out whether codefmt supported jsx files. The vroom test for prettier seems to suggest it does, but the README does not list this as a supported type, and I personally could not get it to work.

Thanks!

dbarnett commented 3 years ago

Yes, if you have prettier installed you can open a jsx file and execute :FormatCode prettier. Although I can't vouch for how well JSX syntax is handled by the different formatters that handle JS (prettier, js-beautify, clang-format).

Vim seems to have filetype rules set up now to detect .jsx and .tsx as "javascriptreact" and "typescriptreact" filetypes, and AFAIK none of the existing formatters is associated with that filetype. You could send a pull request to associate those with some formatters' "AppliesToBuffer" checks if you believe any formatters have good support for them.

theahura commented 3 years ago

Ah, yep I needed javascriptreact, that did the trick. Thanks!