Skip to content

Prepare extension for reworked nf-lang formatter - #215

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

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

Conversation

@ewels

@ewels ewels commented Jul 16, 2026

Copy link
Copy Markdown
Member

Prepares the extension for the reworked nf-lang formatter. The formatter overhaul (nextflow-io/nextflow#7346) merged scoped down to comment preservation; the extension-facing features now live in stacked follow-ups — line wrapping in nextflow-io/nextflow#7520 and fmt: directives in nextflow-io/nextflow#7522. This PR adds the nextflow.formatting.maxLineLength setting, documents the new formatter behavior, and highlights fmt: directives in comments.

⚠️ Do not release until nextflow-io/nextflow#7520 and nextflow-io/nextflow#7522 merge, an nf-lang release contains them, and the language server ships against it.

Upstream status

The original formatter overhaul PR (nextflow-io/nextflow#7346) merged containing comment preservation and multi-line string re-indentation only. The remaining features were split into stacked PRs: include sorting (#7519) ← line wrapping (#7520) ← fmt: directives (#7522), plus blank-line normalization (#7523). K&R-style else/catch was dropped. This PR's docs and features have been aligned to that split.

New setting

  • nextflow.formatting.maxLineLength (integer, default 120, minimum 0; 0 disables line wrapping), matching the -line-length option from Wrap long lines in the formatter nextflow#7520 and the corresponding language-server setting. 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, with wording aligned to the upstream docs:
    • comments are always preserved (merged in #7346)
    • multi-line string re-indentation (merged in #7346)
    • automatic line wrapping at the configured maximum length (#7520)
    • // fmt: skip on the last line of a statement/declaration, and // fmt: off / // fmt: on around a region (#7522)
  • Setting added to the README settings list, and a [Unreleased] changelog section linking the upstream PRs.
  • The setting description and README note that line wrapping and the directives are ignored by older language server versions (deliberately version-agnostic, since the follow-up PRs are unmerged — pin the exact version at release time). 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 directive parser in Support fmt: skip / off / on directives in the formatter nextflow#7522 exactly (FmtDirectives.FMT_DIRECTIVE = //\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. Re-verified against the formatter-fmt-directives branch after the split — the regex is unchanged.

Checked, no changes needed

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

Release ordering

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

  1. Wrap long lines in the formatter nextflow#7520 (line wrapping) and Support fmt: skip / off / on directives in the formatter nextflow#7522 (fmt: directives) to merge — #7520 is stacked on #7519, and #7522 on #7520
  2. an nf-lang release containing them
  3. a language server release built against that nf-lang (with matching nextflow.formatting.maxLineLength support)

At release time, update the version notes in the README and setting description with the actual required language server version. Until then, existing language server releases silently ignore the new setting.

🤖 Generated with Claude Code

https://claude.ai/code/session_0137gokuJdJCZDRJMsF6GbFH

claude and others added 7 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
The formatter overhaul (nextflow-io/nextflow#7346) merged scoped down
to comment preservation and multi-line string re-indentation; line
wrapping, fmt directives, include sorting, and blank-line
normalization moved to stacked follow-up PRs (#7519, #7520, #7522,
#7523), and K&R style was dropped.

Trim the README formatter description to the merged and in-flight
features the extension depends on, align the maxLineLength wording
with the -line-length docs in #7520, and replace the speculative
26.08 version notes with version-agnostic ones. The fmt directive
parser in #7522 is unchanged from what the grammar rule mirrors, so
the highlighting needs no change.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137gokuJdJCZDRJMsF6GbFH
Run prettier on fetchLanguageServer.ts, which arrived from main
unformatted and failed the CI check. Pin the fmt directive grammar
rule in the new syntax highlighting test suite, covering the match
semantics shared with the language server parser: flexible
whitespace, no trailing text, and directive lines still scoped as
comments.

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