简体   繁体   中英

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?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM