Cursor 不支持 Python 语法高亮的解决方案 | 胡扯 AI

Cursor 不支持 Python 语法高亮的解决方案 | 胡扯 AI

https://mp.weixin.qq.com/s/EjLFwk497HTvhuML8Kv-YA

由于开源的 VS Code 在行业中的广泛接受度,几乎所有的新兴 AI 编程工具均采用 Fork VS Code 的方式以快速上线,例如 Cursor、Windsurf、VSCodium、Qoder(阿里)、CodeBuddy(腾讯)、Trae(字节)等等。

文章目录

然而,由于 Microsoft 的限制,在 VS Code 中为 Python 语言提供高亮和静态检测功能的 Pylance 插件,不能在以上的衍生版 IDE 中使用。

Because we have plans to include Pylance in Microsoft products outside of VS Code that do not have the same license, business models and/or are closed-source (for example, fully managed products and services), we do not currently have plans to open-source Pylance.

https://github.com/microsoft/pylance-release/blob/main/FAQ.md#what-features-are-in-pylance-but-not-in-pyright-what-is-the-difference-exactly

61c59e467e2641e9e620cabfd4289686.png

从上图可以看出,尽管我已经在 Qoder 中安装了 Pylance 插件,语法高亮却没有得到完整支持。

basedpyright

Trae、Qoder官方推荐的解决方案是 basedpyright:

dd1fd92ab901eafedd593e608ca62794.png

https://docs.basedpyright.com/

Pylance v2023.10.40

可以安装旧版本的 Pylance 跳过限制。

根据网友测试,v2023.10.40 是最后一个支持安装在衍生 VSCode IDE 中的 Pylance 版本。

https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance

b1c09bd4a129eb1640925a2b51eeb8d0.png

Windsurf Pyright

这个插件是 basepyright 的 fork,仅在 winsurf 中受到支持。

基于 basepyright 的修改包括:

  • 在文件重命名时禁用重构代码。
  • 将类型检查的默认严格性降低,以更好地匹配 PyLance。
  • 默认情况下禁用内联提示,以匹配 PyLance,并且因为它们与自动完成交互。

https://open-vsx.org/extension/Codeium/windsurfPyright

参考链接