Skip to content

Prepare extension for reworked nf-lang formatter - #215

Open
ewels wants to merge 4 commits into
mainfrom
claude/vscode-formatter-updates-qwoncr
Open

Prepare extension for reworked nf-lang formatter#215
ewels wants to merge 4 commits into
mainfrom
claude/vscode-formatter-updates-qwoncr

Conversation

@ewels

@ewels ewels commented Jul 16, 2026

Copy link
Copy Markdown
Member

Follow-up to the formatter overhaul in nextflow-io/nextflow#7346: adds the nextflow.formatting.maxLineLength setting, documents the new formatter behavior and // fmt: directives, and highlights those directives in comments.

⚠️ Do not release until nextflow-io/nextflow#7346 merges, an nf-lang release exists, and the language server ships against it.

New setting

  • nextflow.formatting.maxLineLength (integer, default 120, minimum 0; 0 disables line wrapping), matching the option added to the language server. The name is a fixed contract with the language-server change.
  • No client-side wiring is needed: the extension already synchronizes the entire nextflow configuration section with the language server (synchronize: { configurationSection: "nextflow" }), the same way harshilAlignment, maheshForm, and sortDeclarations work. Changes take effect without a server restart.

Documentation

  • New Formatting section in the README covering the reworked formatter behavior, with wording kept consistent with docs/vscode.mdx and docs/reference/cli.mdx from the upstream PR:
    • comments are always preserved
    • K&R style (} else {) for if/else and try/catch
    • blank-line normalization
    • multi-line string re-indentation
    • automatic line wrapping at the configured maximum length
    • // fmt: skip on the last line of a statement/declaration, and // fmt: off / // fmt: on around a region
  • Setting added to the README settings list, and a [Unreleased] changelog section.
  • The setting description and README carry a "requires Nextflow language version 26.08 or later" note (version taken from the upstream PR docs' AddedInVersion tag — worth re-checking at release time in case the PR lands in a later release), since users can pin nextflow.languageVersion to older releases where the setting is a no-op.

Directive highlighting

  • // fmt: skip|off|on comments are highlighted distinctly (scope keyword.codetag.notation.groovy, the standard codetag convention themes pick up). Implemented as a single line-comment rule with an optional capture group in the shared source.nextflow-groovy grammar, which both the script and config grammars include — so one rule covers both languages.
  • The match semantics mirror the language server's directive parser exactly (//\s*fmt:\s*(skip|off|on)\s*, full-match): whitespace is flexible, but a directive followed by trailing text is not highlighted, because the formatter would ignore it. Verified against the parser source in the upstream PR branch.

Checked, no changes needed

  • No extension-side tests, snippets, or docs assume Allman-style formatter output — nothing else to update.
  • JSON validity and tsc --noEmit pass.

Release ordering

This PR can merge, but a release must wait for, in order:

  1. Formatter overhaul: never remove comments, fmt directives, line wrapping, K&R style nextflow#7346 to merge
  2. an nf-lang release containing it
  3. a language server release built against that nf-lang (with matching nextflow.formatting.maxLineLength support)

Until then, existing language server releases silently ignore the new setting.

🤖 Generated with Claude Code

https://claude.ai/code/session_0137gokuJdJCZDRJMsF6GbFH


Generated by Claude Code

claude and others added 4 commits July 16, 2026 12:58
Add the nextflow.formatting.maxLineLength setting (integer, default 120,
0 disables line wrapping), matching the option added to the language
server for the formatter overhaul (nextflow-io/nextflow#7346). The
setting reaches the language server through the existing "nextflow"
configuration synchronization, so no client-side wiring is needed.

Document the new formatter behavior in the README: comments are always
preserved, K&R style if/else and try/catch, blank line normalization,
multi-line string re-indentation, automatic line wrapping, and the
fmt: skip / fmt: off / fmt: on directives.

Highlight fmt: directives distinctly in line comments via a new
TextMate rule in the shared groovy grammar (covers both scripts and
config files).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137gokuJdJCZDRJMsF6GbFH
Merge the fmt-directive pattern into the single line-comment rule with
an optional capture group, removing the duplicated rule and its
pattern-ordering dependency. Anchor the directive match so only
whitespace may follow it, mirroring the language server's full-match
directive parser exactly (no highlight for directives the formatter
would ignore).

Shorten the changelog entries to point at the README instead of
restating the formatter feature list, and note the required language
version (26.08) in the setting description and README.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137gokuJdJCZDRJMsF6GbFH
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137gokuJdJCZDRJMsF6GbFH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants