/VapourSynth-Plugins-Stub-Generator

An unofficial stub generator for vapoursynth and its plugins, which is helpful to autocomplete code in VSCode.

Primary LanguagePythonMIT LicenseMIT

VapourSynth-Plugins-Stub-Generator

An unofficial stub generator for vapoursynth and its plugins, which is helpful to autocomplete code in VSCode.

Generate the stub file

At first, you need to have a python with vapoursynth installed. You can check it with

python -c 'from vapoursynth import core; print(core.version())'

Then run the command:

python vs_plugins_helper.py

A file called vapoursynth.pyi should be created at where you run the command. Move it to where your language server or library like Jedi can recognize.

Install the vapoursynth-stubs package

Generating a stub-only package named vapoursynth-stubs usually helps a lot. You can install the vsstubs package by pip and then install the *-stubs package.

python -m pip install .\vsstubs\
python -m vsstubs install

All language servers in VSCode should work with such a package to autocomplete your code.

Once you have installed the stub file, you can update it if there are some new filters added to vapoursynth after installation.

python -m vsstubs update

For more usage and mode, get the help message by

python -m vsstubs help

Setting up VSCode

Files in .vscode folder might be helpful to set up VSCode.

  1. Install VSCode, then install Python extension and Pylance in VSCode extension market.

  2. Paste the settings.json to the user settings folder1 or work area settings folder2. This will enable the python code highlighting and autocompletion.

  3. Paste the tasks.json to the user settings folder1 or work area settings folder2, and paste the keybindings.json to your vscode user settings folder1. This will enable shift+f5/f6 hotkeys as f5/f6 in vsedit.

  4. Remember to change "path\\to\\your\\VapourSynth\\python.exe" in settings.json to your own python interpreter.

1: Usually refer to %APPDATA%\Code\User\ on Windows and $HOME/.config/Code/User/ on Linux

2: Usually refer to /path/to/your/workdir/.vscode/