Skip to content

Latest commit

 

History

History
72 lines (49 loc) · 2.15 KB

README.md

File metadata and controls

72 lines (49 loc) · 2.15 KB

Sublime Text API Stubs

With LSP properly configured and type annotations provided, you can have something like the following screenshot.

LSP and pyright

You can also use these stub files in mypy to do static analysis for your plugin.

How to Use Them

Setup for LSP-pyright

  1. Configure the pyright.dev_environment:

    ST stubs have been bundled in LSP-pyright so you just have to activate the setup.

    {
        "settings": {
            // a special predefined setup for developing ST plugins
            "pyright.dev_environment": "sublime_text",
        },
    }
  2. Restart the language server (by restarting ST).

Setup for LSP-pylsp

  1. Copy typings/ from this repository to YOUR_PROJECT_ROOT/typings/ directory.

  2. Make the language server able to see them.

    Configure the pylsp.plugins.jedi.extra_paths:

    {
        "settings": {
            "pylsp.plugins.jedi.extra_paths": [
                // $folder is the first project folder in your ST project folders
                "$folder/typings",
            ],
        },
    }
  3. Restart the language server (by restarting ST).

Setup for mypy

  1. Copy typings/ from this repository as YOUR_PROJECT_ROOT/typings/ directory.

  2. In your mypy.ini, in the [mypy] section, set the stub directories.

    [mypy]
    mypy_path = typings:stubs
  3. mypy should be able to understand sublime and sublime_plugin modules now.

Acknowledgment and Related Resources

This repository is initially mostly based on AmjadHD/sublime_dev's work.

Apart from @AmjadHD's work, there are also some other similar works: