Skip to content

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

Open
@dbarnett

Description

@dbarnett

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

Activity

dbarnett

dbarnett commented on Jan 8, 2024

@dbarnett
ContributorAuthor

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

dbarnett commented on Jan 8, 2024

@dbarnett
ContributorAuthor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @dbarnett

        Issue actions

          Add `:CodefmtInfo` command to report diagnostics to help users check config / diagnose problems · Issue #234 · google/vim-codefmt