Skip to content

Instantly share code, notes, and snippets.

@jmfergeau
Created October 20, 2022 12:39
Show Gist options
  • Save jmfergeau/b855ef63e9a5336d5f61e170031d1817 to your computer and use it in GitHub Desktop.
Save jmfergeau/b855ef63e9a5336d5f61e170031d1817 to your computer and use it in GitHub Desktop.
For some reason, Ren'Py refuses to set up vscode as editor on linux, even if it downloads it. In the meantime, i found this kind of fix.
# For some reason, Ren'Py refuses to set up vscode as editor, even if it downloads it.
# In the meantime, i found this kind of fix.
# 1. Attempt to install vscode for renpy.
# 2. if it fails and says "not specified", copypaste this in a new file
# called "vscode.edit.py" inside the 'vscode' folder in renpy.
# 3. Change the CODE_PATH variable as indicated.
# 4. launch (or restart) renpy, and in the settings, choose the lone 'vscode' in the editor settings
# Many thanks to the chinese dude for this file.
import os
import subprocess
import renpy
# Change this with the absolute path of where renpy installs the vscode program.
# should be something like "r'/path/to/renpy/vscode/VSCode-linux-x64/code'"
CODE_PATH = r'/home/user/renpy-sdk/vscode/VSCode-linux-x64/code'
def code(argv):
subprocess.Popen([CODE_PATH] + argv)
class Editor(renpy.editor.Editor):
has_projects = True
def begin(self, new_window=False, **kwargs):
self.args = ['-n' if new_window else '-r']
def end(self, **kwargs):
self.args.reverse()
code(self.args)
def open(self, filename, line=None, **kwargs):
filename = os.path.realpath(renpy.exports.fsencode(filename))
if line:
self.args.append('%s:%d' % (filename, line))
self.args.append('-g')
else:
self.args.append(filename)
self.args.append(os.path.split(filename)[0] + '/')
def open_project(self, directory):
directory = os.path.realpath(renpy.exports.fsencode(directory))
self.args.append('%s/' % directory)
def main():
e = Editor()
e.begin()
for i in sys.argv[1:]:
e.open(i)
e.end()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment