vim-codefmt icon indicating copy to clipboard operation
vim-codefmt copied to clipboard

Add `:CodefmtInfo` command to report diagnostics to help users check config / diagnose problems

Open dbarnett opened this issue 1 year ago • 2 comments

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: ...]

dbarnett avatar Jan 05 '24 15:01 dbarnett

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.log before 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".

dbarnett avatar Jan 08 '24 16:01 dbarnett

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.

dbarnett avatar Jan 08 '24 16:01 dbarnett