|
1 | 1 | import os |
2 | 2 | import json |
3 | 3 | import logging |
| 4 | +from itertools import chain |
4 | 5 | from os.path import isdir, isfile |
5 | 6 | from pathlib import Path |
6 | 7 |
|
|
9 | 10 | logger = logging.getLogger(__name__) |
10 | 11 |
|
11 | 12 | extension_paths = [ |
12 | | - str(Path.home()) + '/.vscode/extensions', |
13 | | - str(Path.home()) + '/.vscode-insiders/extensions', |
14 | | - str(Path.home()) + '/.vscode-oss/extensions', |
| 13 | + str(Path.home() / '.vscode/extensions'), |
| 14 | + str(Path.home() / '.vscode-insiders/extensions'), |
| 15 | + str(Path.home() / '.vscode-oss/extensions'), |
15 | 16 | '/usr/lib/code/extensions', |
16 | 17 | '/usr/lib/code-insiders/extensions', |
17 | 18 | '/usr/share/code/resources/app/extensions', |
18 | 19 | '/usr/share/code-insiders/resources/app/extensions', |
19 | 20 | '/opt/visual-studio-code/resources/app/extensions/', |
20 | 21 | '/opt/visual-studio-code-insiders/resources/app/extensions/', |
21 | 22 | '/var/lib/snapd/snap/code/current/usr/share/code/resources/app/extensions/', |
22 | | - '/var/lib/snapd/snap/code-insiders/current/usr/share/code-insiders/resources/app/extensions/' |
| 23 | + '/var/lib/snapd/snap/code-insiders/current/usr/share/code-insiders/resources/app/extensions/', |
| 24 | + str(Path.home() / '.var/app/com.visualstudio.code/data/vscode/extensions/'), |
| 25 | + str(Path.home() / '.var/app/com.visualstudio.code-oss/data/vscode/extensions/'), |
| 26 | + str(Path.home() / '.var/app/com.vscodium.codium/data/codium/extensions/'), |
| 27 | + '/var/lib/flatpak/app/com.visualstudio.code/current/active/files/extra/vscode/resources/app/extensions/' |
23 | 28 | ] |
24 | 29 |
|
25 | 30 |
|
@@ -75,11 +80,19 @@ def set_theme(self, theme: str): |
75 | 80 | "Code", |
76 | 81 | "Code - Insiders", |
77 | 82 | ] |
| 83 | + config_path = str(Path.home() / '.config/{name}/User/settings.json') |
| 84 | + native_settings = (config_path.format(name=name) for name in possible_editors) |
| 85 | + |
| 86 | + flatpak_settings = [ |
| 87 | + str(Path.home() / '.var/app/com.visualstudio.code/config/Code/User/settings.json'), |
| 88 | + str(Path.home() / '.var/app/com.visualstudio.code-oss/config/Code - OSS/User/settings.json'), |
| 89 | + str(Path.home() / '.var/app/com.vscodium.codium/config/VSCodium/User/settings.json') |
| 90 | + ] |
78 | 91 |
|
79 | 92 | try: |
80 | 93 | for editor in filter( |
81 | 94 | os.path.isfile, |
82 | | - (f'{str(Path.home())}/.config/{name}/User/settings.json' for name in possible_editors)): |
| 95 | + chain(native_settings, flatpak_settings)): |
83 | 96 | # load the settings |
84 | 97 | with open(editor, "r") as sett: |
85 | 98 | try: |
|
0 commit comments