mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-05 15:32:49 +00:00
config-schema: allow "command-env"-style for editors and fix tools
The `CommandNameAndArgs` struct is used in multiple places to specify external tools. Previously, the schema only allowed for this in `ui.pager`. This commit adds a few sample configs which define variables editors and fix tools as commands with env vars. The schema has also been updated to make these valid.
This commit is contained in:
parent
d35dd31c87
commit
bf2c01e74b
@ -47,6 +47,13 @@
|
||||
],
|
||||
"default": "diff"
|
||||
},
|
||||
"command": {
|
||||
"type": ["string", "array"],
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"command-env": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -108,23 +115,16 @@
|
||||
"default": "auto"
|
||||
},
|
||||
"pager": {
|
||||
"description": "Pager to use for displaying command output",
|
||||
"default": "less -FRX",
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
"$ref": "#/properties/ui/definitions/command"
|
||||
},
|
||||
{
|
||||
"$ref": "#/properties/ui/definitions/command-env"
|
||||
}
|
||||
],
|
||||
"description": "Pager to use for displaying command output",
|
||||
"default": "less -FRX"
|
||||
]
|
||||
},
|
||||
"streampager": {
|
||||
"type": "object",
|
||||
@ -169,12 +169,15 @@
|
||||
"default": "color-words"
|
||||
},
|
||||
"tool": {
|
||||
"type": ["array", "string"],
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "External tool for generating diffs"
|
||||
"description": "External tool for generating diffs",
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/properties/ui/definitions/command"
|
||||
},
|
||||
{
|
||||
"$ref": "#/properties/ui/definitions/command-env"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -210,26 +213,25 @@
|
||||
"default": true
|
||||
},
|
||||
"editor": {
|
||||
"type": ["array", "string"],
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Editor to use for commands that involve editing text"
|
||||
"description": "Editor to use for commands that involve editing text",
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/properties/ui/definitions/command"
|
||||
},
|
||||
{
|
||||
"$ref": "#/properties/ui/definitions/command-env"
|
||||
}
|
||||
]
|
||||
},
|
||||
"diff-editor": {
|
||||
"description": "Editor tool to use for editing diffs",
|
||||
"default": ":builtin",
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string"
|
||||
"$ref": "#/properties/ui/definitions/command"
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
"$ref": "#/properties/ui/definitions/command-env"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -238,14 +240,10 @@
|
||||
"default": ":builtin",
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string"
|
||||
"$ref": "#/properties/ui/definitions/command"
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
"$ref": "#/properties/ui/definitions/command-env"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -752,12 +750,15 @@
|
||||
"description": "Settings for how specific filesets are affected by a tool",
|
||||
"properties": {
|
||||
"command": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Arguments used to execute this tool"
|
||||
"description": "Arguments used to execute this tool",
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/properties/ui/definitions/command"
|
||||
},
|
||||
{
|
||||
"$ref": "#/properties/ui/definitions/command-env"
|
||||
}
|
||||
]
|
||||
},
|
||||
"patterns": {
|
||||
"type": "array",
|
||||
|
@ -0,0 +1,8 @@
|
||||
#:schema ../../../src/config-schema.json
|
||||
[fix.tools.clang-format.command]
|
||||
command = [
|
||||
"/usr/bin/clang-format",
|
||||
"--sort-includes",
|
||||
"--assume-filename=$path",
|
||||
]
|
||||
env = { NO_COLOR = 1 }
|
@ -0,0 +1,3 @@
|
||||
#:schema ../../../src/config-schema.json
|
||||
[fix.tools.clang-format]
|
||||
command = "/usr/bin/clang-format"
|
15
cli/tests/sample-configs/valid/ui_command-env.toml
Normal file
15
cli/tests/sample-configs/valid/ui_command-env.toml
Normal file
@ -0,0 +1,15 @@
|
||||
#:schema ../../../src/config-schema.json
|
||||
[ui]
|
||||
editor = { command = ["C:/Program Files/Notepad++/notepad++.exe", "-multiInst", "-notabbar", "-nosession", "-noPlugin"], env = {} }
|
||||
|
||||
[ui.diff-editor]
|
||||
command = ["diffedit3", "$left", "$right"]
|
||||
env = { RUST_LOG = "poem=debug" }
|
||||
|
||||
[ui.merge-editor]
|
||||
command = ["diffedit3", "$left", "$base", "$right"]
|
||||
env = { RUST_LOG = "poem=debug" }
|
||||
|
||||
[ui.diff.tool]
|
||||
command = ["difft", "--color=always", "$left", "$right"]
|
||||
env = { DFT_BACKGROUND = "light" }
|
Loading…
x
Reference in New Issue
Block a user