Skip to content

Commit

Permalink
Fix vscode if installed as flatpak
Browse files Browse the repository at this point in the history
  • Loading branch information
l0drex committed Jan 17, 2024
1 parent cc766bc commit ddf912b
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions yin_yang/plugins/vscode.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import json
import logging
from itertools import chain
from os.path import isdir, isfile
from pathlib import Path

Expand All @@ -9,17 +10,21 @@
logger = logging.getLogger(__name__)

extension_paths = [
str(Path.home()) + '/.vscode/extensions',
str(Path.home()) + '/.vscode-insiders/extensions',
str(Path.home()) + '/.vscode-oss/extensions',
str(Path.home() / '.vscode/extensions'),
str(Path.home() / '.vscode-insiders/extensions'),
str(Path.home() / '.vscode-oss/extensions'),
'/usr/lib/code/extensions',
'/usr/lib/code-insiders/extensions',
'/usr/share/code/resources/app/extensions',
'/usr/share/code-insiders/resources/app/extensions',
'/opt/visual-studio-code/resources/app/extensions/',
'/opt/visual-studio-code-insiders/resources/app/extensions/',
'/var/lib/snapd/snap/code/current/usr/share/code/resources/app/extensions/',
'/var/lib/snapd/snap/code-insiders/current/usr/share/code-insiders/resources/app/extensions/'
'/var/lib/snapd/snap/code-insiders/current/usr/share/code-insiders/resources/app/extensions/',
str(Path.home() / '.var/app/com.visualstudio.code/data/vscode/extensions/'),
str(Path.home() / '.var/app/com.visualstudio.code-oss/data/vscode/extensions/'),
str(Path.home() / '.var/app/com.vscodium.codium/data/codium/extensions/'),
'/var/lib/flatpak/app/com.visualstudio.code/current/active/files/extra/vscode/resources/app/extensions/'
]


Expand Down Expand Up @@ -75,11 +80,19 @@ def set_theme(self, theme: str):
"Code",
"Code - Insiders",
]
config_path = str(Path.home() / '.config/{name}/User/settings.json')
native_settings = (config_path.format(name=name) for name in possible_editors)

flatpak_settings = [
str(Path.home() / '.var/app/com.visualstudio.code/config/Code/User/settings.json'),
str(Path.home() / '.var/app/com.visualstudio.code-oss/config/Code - OSS/User/settings.json'),
str(Path.home() / '.var/app/com.vscodium.codium/config/VSCodium/User/settings.json')
]

try:
for editor in filter(
os.path.isfile,
(f'{str(Path.home())}/.config/{name}/User/settings.json' for name in possible_editors)):
chain(native_settings, flatpak_settings)):
# load the settings
with open(editor, "r") as sett:
try:
Expand Down

0 comments on commit ddf912b

Please sign in to comment.