Neil Shah
Neil Shah

Reputation: 59

How To Make A VS Code Extension In Python

I Use Python As My Main Language, And I Want To Make A VS Code Extension, But I Cant Find Any Docs/Resources, Is Possible To Make One In Python?

Upvotes: 5

Views: 6432

Answers (2)

Peter K
Peter K

Reputation: 2484

VS Code has official documentation on using the Langugage Server/LSP to create a python extension: https://code.visualstudio.com/api/advanced-topics/python-extension-template

If you prefer to use the child_process approach, there is an unofficial python wrapper: https://github.com/CodeWithSwastik/vscode-ext?u=t&m=o#example-extension

Upvotes: 3

Wenhan Kong
Wenhan Kong

Reputation: 81

VS Code is built on Electron framework which run with Node.js, so it's impossible to make a extension "directly" using Python. However you can use these two ways to keep your stuff mainly in Python:

  • Node.js allows you to call outside scripts using child_process. it is often used to achieve multi-threading in Node.js.
  • If you are developing a language extension, you should give Language Server with LSP a try. By doing this you can start up a server written by Python and communicate with VSC JS client using LSP.

Note that both ways requires you to write some JS/TS code.

Upvotes: 7

Related Questions