-
Notifications
You must be signed in to change notification settings - Fork 343
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
FR: Support configuration of multiple tools for jj fix
#3801
Comments
If one is not willing to implement a wrapper script, is it really a problem to just run multiple serial I don't know if the listed "solution" has a lot to do with the listed "problem", anyways. The listed items largely seem like general configuration options. |
My expectation is that users will generally run I think the key word in the solution was "repeatable". I described the main configuration options just to make sure those ideas are documented. They're generally borrowed from
|
Here's a concrete proposal for the configuration syntax. A simple example for a single code formatter:
This would result in argv like the following, which would vary per
The patterns will be handled by Multiple tools can be defined by repeating the section with unique identifiers, and their priority is undefined. Until we implement the priority option, we can operate under the assumption that the tools are run in the order they are specified.
We would like to implement that basic syntax this week if there are no objections. Some other functionality can be added incrementally. When #3802 is implemented, we will need to support communicating the boundaries of the diff hunks using repeated flags. We see two main approaches. The first one puts the repeated flags in the same list with the other arguments, and implicitly repeats them at the same position in the argument list. The presence of substitutions for the line range variables determines which arguments are handled this way. For example:
This would result in an argv like the following:
Another approach, which is used by Mercurial, is to list the line range flags separately so that the difference in how they are handled is more explicit:
Without any extra features to specify where the line range flags go, they would just be appended to the end of the command list:
Including the other options alluded to in #3801 (comment), a more complete configuration could look like this:
|
This happened a while back in #4079. |
Problem:
As of #3698,
jj fix
can only be configured to run different code formatters on different file types if a wrapper script is used to make such decisions. That is an unreasonable requirement for anyone who didn't already have such a wrapper script, and it means thatjj fix
is unable to make any useful decisions about which files even need to be processed at all. Even users of a wrapper script might want to avoid processing some files.Solution:
Support a repeatable configuration syntax for defining the properties of each tool:
As @PhilipMetzger mentioned, TOML tables seem to be a good approach:
#3698 (comment)
Alternatives:
You could imagine configuring some other source of information, from which
jj fix
would fetch the tool properties. I don't think that would be useful, although we could look around to see if there is some existing standard for declaring this kind of thing.You could imagine deferring formatting to something like LSP, but that would require more setup, would be less generic, would encounter more complicated failure modes, and would share some of the limitations of wrapper scripts as described above:
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_formatting
Context:
Prior art: https://www.mercurial-scm.org/doc/hg.1.html#fix
I specifically want to avoid re-implementing the
:metadata
subconfig fromhg fix
, because it's weird and probably unnecessary. I say this as the person who implemented it and oversaw its use at Google; I don't know if others have found it useful.The text was updated successfully, but these errors were encountered: