Skip to content

Commit fce101e

Browse files
matttbeFlorentRevest
authored andcommitted
settings: load settings-extra.json file
This allows users to manage extra settings in an external file, e.g. to use one from another repository where the file can be tracked and even shared. Also, by loading it at the end, it can override some "default" settings. Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
1 parent 10aa86e commit fce101e

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
local*.sh
22
settings.json
3+
settings-extra.json

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ the `Ctrl+P` dialog box):
179179
* Customize per-workspace VS-Code settings the normal way (edit local
180180
`.vscode/settings.json`, or use `Ctrl+Shift+P` -> "Preferences: Open
181181
Settings (UI)"). Note that fields that exist in `settings.jsonnet` will get
182-
overwritten when you run the `update` task. Also, comments in your
182+
overwritten when you run the `update` task. If needed, extra settings can be
183+
added in `.vscode/settings-extra.json` file. Also, comments in your
183184
`.vscode/settings.json` will get deleted.
184185
* **Autostart** commands or codes at VM start time by modifying the content of
185186
`.vscode/autostart/` (eg: always run tests that exercise the kernel

settings.jsonnet

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
// This is a jsonnet file, to evaluate it on the command-line use
22
//
3-
// jsonnet --ext-code-file old_settings=<path to old settings> <path to this file>
3+
// jsonnet \
4+
// --ext-code-file old_settings=<path to old settings> \
5+
// --ext-code-file extra_settings=<path to extra settings> \
6+
// <path to this file>
47
//
58
// JSonnet is a superset of JSON. Here we are using a minimal subset of
6-
// JSonnet's extra freatures, see the "External Variables" and "Object
9+
// JSonnet's extra features, see the "External Variables" and "Object
710
// Orientation" section of jsonnet tutorials (plus we use comments).
811
std.extVar('old_settings') + {
912
"files.exclude": {
@@ -87,4 +90,4 @@ std.extVar('old_settings') + {
8790
"systemtap-assistant.output": ".vscode/autostart/tracer.stp",
8891
"systemtap-assistant.deploy-task": "Build systemtap tracer",
8992
"debug.onTaskErrors": "debugAnyway"
90-
}
93+
} + std.extVar('extra_settings')

tasks.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,14 @@ EOF
457457
# Seed JSonnet with empty object
458458
echo "{}" > "settings.json"
459459
fi
460+
if [ ! -e "settings-extra.json" ]; then
461+
# Seed JSonnet with empty object
462+
echo "{}" > "settings-extra.json"
463+
fi
460464
tmp="$(mktemp --suffix=.json)"
461-
jsonnet settings.jsonnet --ext-code-file old_settings="settings.json" > "${tmp}"
465+
jsonnet settings.jsonnet \
466+
--ext-code-file old_settings="settings.json" \
467+
--ext-code-file extra_settings="settings-extra.json" > "${tmp}"
462468
mv "$tmp" settings.json
463469
;;
464470
*)

0 commit comments

Comments
 (0)