google / google/vim-codefmt

Consider providing a standard way for formatters to report errors

Open
#60 1 comment 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Vim Script
Stars
1.1k
Forks
102
PR merge metrics
No merged PRs in 30d

Description

Currently, if formatters want to report errors, they update the quickfix list directly. (As shipped, only the gofmt formatter does this, but it would also make sense for e.g. google-java-format, were we to add support for that.) It would be nice to make it easier for formatters to report errors.

Additionally, we have some questions around when formatters should clear the quickfix list (e.g. #58), and I'm not sure how stacked formatters (#44) would work if formatters were managing the quickfix list individually.

I've been wondering whether formatters could pass a structured error list to codefmt somehow, and then codefmt itself could be responsible for merging/populating/hiding the quickfix list as appropriate, consistently.

As a strawman, perhaps `FormatRange()` (etc) could return a list of (line, column, message)? (Or accept a callback instead, if that sounds like a restrictive API? Would the line numbers be relative to the start of the range, for range formatting?)

And/or, since most formatters can get errors by looking for "file:line:column: error" on stderr, it might even be work providing a helper that handled exactly that pattern directly.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the formatter API around FormatRange() and the behavior discussed in issues #58 and #44. Clarify whether errors should be returned structurally or reported through a callback, including range-relative locations and stacked formatters. Done means codefmt consistently owns quickfix merging, clearing, populating, and hiding across supported formatters.

Written by the indexing model from the issue text.

Assessment

Tech stack
vim
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.