Repository navigation
Add --align and --spacing to fmt and the language server - #43
Merged
Merged
Conversation
`fmt --style legacy [--alignment-offset N]` formats like the VS Code
extension did before it used gh-codeowners: the first owner of every rule
in the file lines up after the longest pattern, and nothing else changes.
The language server reads the same choice from initializationOptions or
workspace/didChangeConfiguration:
{ "format": { "style": "legacy", "alignmentOffset": 4 } }
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018s9fHcEQxmXZ7pQ6v9W2KM
…-offset Clap can require another flag but not another flag's value, so with --style it couldn't reject --style default --alignment-offset 2 itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018s9fHcEQxmXZ7pQ6v9W2KM
…lignment-offset" This reverts commit 72be2df.
--align group (the default) lines up owners in each group of rules, and
--align file lines up every rule's owners in one column, like the VS Code
extension did before 5.1.0. --spacing is the exact number of spaces
between the longest pattern and the owners, 1 by default for both.
The language server takes { "format": { "align": "file", "spacing": 5 } }.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018s9fHcEQxmXZ7pQ6v9W2KM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018s9fHcEQxmXZ7pQ6v9W2KM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018s9fHcEQxmXZ7pQ6v9W2KM
chdsbd
marked this pull request as ready for review
November 10, 2026 02:28
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018s9fHcEQxmXZ7pQ6v9W2KM
chdsbd
added a commit
to chdsbd/vscode-github-code-owners
that referenced
this pull request
Nov 10, 2026
Add new formatting option (`file`) to match legacy behavior.
---
🤖 Adds settings for how the gh-codeowners language server formats
CODEOWNERS, including the pre-5.1.0 formatting, and bundles
gh-codeowners v0.4.0, which supports them.
- `githubCodeOwners.format.align`: `group` (the default, the current
behavior) or `file` (one column for the whole file, like before 5.1.0).
- `githubCodeOwners.format.spacing`: the number of spaces between the
longest pattern and the owners. It defaults to 1. To format exactly like
before 5.1.0, use `align: file` with `spacing: 5`.
- The deprecated `githubCodeOwners.format.alignmentOffset` and
`github-code-owners.format.alignment-offset` are deprecated again, now
pointing to `spacing`. If the user set one of them and hasn't set
`spacing`, the extension sends `offset + 1`, so their files format as
before.
- The deprecation message for `format.enabled` explains how to get the
old formatting.
- The extension sends `{ format: { align, spacing } }` as
`initializationOptions`, and sends `workspace/didChangeConfiguration`
when any of these settings change, so no restart is needed.
- `s/download-server` bundles gh-codeowners v0.4.0
(chdsbd/gh-codeowners#43), which reads these settings.
- Adds an integration test that covers the deprecated offset, and
`spacing` overriding it.
- Fixes a flaky test: "offers to escape brackets" now waits for the
language server's quick fix, since VS Code's own AI actions, which have
no edit, can arrive first.
## Verification
- `npm run typecheck`, `npm run eslint`, `npm run fmt:check` and `npm
run compile` pass.
- The published v0.4.0 linux-amd64 binary matches the release's SHA-256
digest, reports version 0.4.0, and formats with `--align file --spacing
3`.
- The test's expected text comes from the server's real output.
- I couldn't run the VS Code integration tests in my environment,
because the network blocks the VS Code download, so CI is the first full
run.
---------
Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Adds options for where
fmtputs owners, including the VS Code extension's pre-5.1.0 formatting, which was removed in chdsbd/vscode-github-code-owners#43. Releases 0.4.0.CLI
--align group(the default) is the existingterraform fmt-like style. Each group of consecutive rules lines up its owners and comments.--align filelines up the first owner of every rule in the file in one column, like the old extension. Only the space before the first owner changes. Indentation, the spacing between owners and comments stay as they are.--spacing <n>is the exact number of spaces between the longest pattern and the owners. It defaults to 1 and must be at least 1. It applies to owners only, so trailing comments still get one space. The old extension's output is--align file --spacing 5.Language server
It reads the settings from
initializationOptionsor from thesettingsofworkspace/didChangeConfiguration:{ "format": { "align": "file", "spacing": 5 } }Invalid settings (an unknown
align, or aspacingbelow 1) are logged to stderr, and the previous settings stay.Library
format::format_with(text, Align, spacing),format_groupandformat_file.format(text)is still the group style with spacing 1.format_filefixes bugs in the old extension's formatter. That formatter took the first@on a line as the start of the owners, so it split email owners (gopher@example.combecamegophe @example.com), indented rules that had no owners, and ignored a#inside a pattern.format_fileuses the real line splitter instead.Release
Bumps the version to 0.4.0 in
Cargo.toml,Cargo.lock,wasm/Cargo.lockandCHANGELOG.md.s/check-versionpasses.Tests
format_file(text, 5)gives byte-for-byte the same output)--align,--spacing, and for rejecting--spacing 0initializationOptions, for changing them withdidChangeConfiguration, and for bad settings being ignoredcargo test,cargo clippy --all-targetsandcargo fmtpass locallyThe extension change that uses this is chdsbd/vscode-github-code-owners#44. It needs v0.4.0 released, and
GH_CODEOWNERS_VERSIONbumped to match.🤖 Generated with Claude Code
https://claude.ai/code/session_018s9fHcEQxmXZ7pQ6v9W2KM