From 57fe0462e3e6da3b4123cfc1af10d72886a0a403 Mon Sep 17 00:00:00 2001 From: Kerrick Staley Date: Wed, 7 Feb 2024 13:01:29 -0500 Subject: [PATCH] Add gen-vscode-manual-config command and config At work, my VSCode config can only be edited through the VSCode GUI. In order to version control it, check it in to homegit and add a small Python program that merges common (shared by home and work) config with work-specific config. Relevant issues: - https://github.com/gitpod-io/openvscode-server/discussions/199 - https://github.com/gitpod-io/openvscode-server/issues/535 - https://github.com/microsoft/vscode/issues/15909 --- .config/vscode-manual-config/common.json5 | 16 ++++++++++++++ bin/gen-vscode-manual-config | 27 +++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 .config/vscode-manual-config/common.json5 create mode 100755 bin/gen-vscode-manual-config diff --git a/.config/vscode-manual-config/common.json5 b/.config/vscode-manual-config/common.json5 new file mode 100644 index 0000000..8e7b4fe --- /dev/null +++ b/.config/vscode-manual-config/common.json5 @@ -0,0 +1,16 @@ +{ + "workbench.colorTheme": "Default Dark Modern", + "keyboard.dispatch": "keyCode", + "vim.vimrc.enable": true, + "[python]": { + "editor.defaultFormatter": "ms-python.python" + }, + "vim.handleKeys": { + "": false, + }, + "vim.useSystemClipboard": true, + "files.autoSave": "onFocusChange", + "editor.autoClosingBrackets": "never", + "security.workspace.trust.untrustedFiles": "open", + "files.insertFinalNewline": true, +} diff --git a/bin/gen-vscode-manual-config b/bin/gen-vscode-manual-config new file mode 100755 index 0000000..8f17220 --- /dev/null +++ b/bin/gen-vscode-manual-config @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +import json5 +import os +from pathlib import Path + + +def main(): + with open( + Path(os.environ["HOME"]) / ".config/vscode-manual-config/common.json5" + ) as f: + common = json5.load(f) + + try: + with open( + Path(os.environ["HOME"]) / ".config/vscode-manual-config/local.json5" + ) as f: + local = json5.load(f) + except: + local = {} + + merged = common | local + + print(json5.dumps(merged, indent=4)) + + +if __name__ == "__main__": + main()