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

Formatting only specific line ranges #223

Open
infinisil opened this issue Jul 17, 2024 · 1 comment
Open

Formatting only specific line ranges #223

infinisil opened this issue Jul 17, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@infinisil
Copy link
Member

The context for this is here.

For a more future-proof solution, we should consider implementing a partial formatter mode, which can be told to format only specific line ranges of a file. This way we can extend the conflict-avoiding trick to format all line ranges that aren't touched by recent PRs.

The alternative of just ripping the band-aid off and formatting all files at some point also works, and would be much simpler at the expense of more conflicts. But especially as we change the formatter again over time we'll run into the same problem over and over again, whereas the line range conflict-avoiding trick would enable a smooth mode of operation that almost never causes any churn for other users.

@piegamesde
Copy link
Member

Nixfmt works by pretty-printing parsed AST nodes. How should it deal with partial nodes, especially at the line boundaries? Also, how does it know the base indentation to use? It could calculate that from the global AST but it may differ from the unformatted parts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

2 participants