Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Improved Formatting for Long Tuple Definitions #84

Open
exai-sukh opened this issue Dec 2, 2024 · 2 comments
Open
Labels
formatting Related to automatic code formatting

Comments

@exai-sukh
Copy link

exai-sukh commented Dec 2, 2024

Current Behavior

When defining tuples with multiple elements, the current formatter outputs all elements on a single line. This can be difficult to read, especially when there are many elements, making the code less readable.

Current Formatting Example:

  input:
  tuple val(the), val(nextflow), val(formatter), val(is), val(great), val(because), val(it), val(ensures), val(consistent), val(and), val(clean), val(syntax)

Proposed Improvement

Introduce formatting rules that break tuple definitions into multiple lines when the total length or the number of elements exceeds a threshold. Ideally, this threshold is configurable.

Proposed Formatting Example:

  input:
  tuple val(the),
    val(nextflow),
    val(formatter),
    val(is),
    val(great),
    val(because),
    val(it),
    val(ensures),
    val(consistent),
    val(and),
    val(clean),
    val(syntax)
@bentsherman bentsherman transferred this issue from nextflow-io/vscode-language-nextflow Dec 4, 2024
@bentsherman bentsherman added the formatting Related to automatic code formatting label Dec 4, 2024
@awgymer
Copy link

awgymer commented Feb 28, 2025

I don't know what auto-formatting would do to it, but the following is already possible in nextflow and at the least is not reformatted by the extension on my VSCode:

  input:
  tuple (
    val(the),
    val(nextflow),
    val(formatter),
    val(is),
    val(great),
    val(because),
    val(it),
    val(ensures),
    val(consistent),
    val(and),
    val(clean),
    val(syntax)
)

Worth noting though that this will break nf-core linting if you use that.

@bentsherman
Copy link
Member

Normally, function calls will be wrapped across multiple lines if you add a trailing comma. But this behavior doesn't apply to directives. Might be a good idea to make it consistent though.

@awgymer the formatter will definitely reformat that tuple input to a single line. it may be that the formatter is just doing nothing, which can happen if there are syntax errors. I should probably show a message to the user when that happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatting Related to automatic code formatting
Projects
None yet
Development

No branches or pull requests

3 participants