vim-codefmt
vim-codefmt copied to clipboard
Add `:CodefmtInfo` command to report diagnostics to help users check config / diagnose problems
We should have a command called something like :CodefmtInfo that can dump a report on how it's configured wrt the current context and maybe the last known invocation.
For example:
:CodefmtInfo
Current buffer: foo.py
Autoformat [enabled|disabled] [using formatter yapf]
Selected formatter: [yapf]
All available formatters: yapf, black, isort, autopep8
Last invocation at [TIMESTAMP]:
Executed command: yapf -blah ...
Exit code: [0|...]
[Stderr: ...]
As a workaround in the meantime, here's a dump of some commands to manually look up some of this info:
:let b:codefmt_<TAB>to check for any buffer-local settings- Autoformat (if any): check
:autocmd codefmt - Selected formatter (if any):
:let b:codefmt_formatter - Available formatters:
:echo codefmt#GetSupportedFormatters(0, 0, 0) - Shell invocations: start vim with
-V9vim.logbefore running formatter, then after triggering the formatter search vim.log for "Executing command".
Note: Signature of codefmt#GetSupportedFormatters is weird and will probably change eventually, try :echo codefmt#GetSupportedFormatters() or variations on that if you get "Too many arguments".
Also for general troubleshooting, check :messages for any errors you might've missed, especially things like Not an editor command that might've tripped up autocmds etc.