如何为Sublime Text 3配置第三方包(如appJar)的代码自动补全?
Sublime Text 3: Auto-Complete for Third-Party Packages (Including appJar) & Anaconda Alternatives
Hey there! Let's break down your questions and share practical solutions for your workflow:
1. Tools That Generate Completion Libraries From Documentation
If you want auto-completion that pulls from package docs or source code, these tools are worth checking out:
- SublimeJEDI: Built on the Jedi library (the same engine used in VS Code and PyCharm), it automatically parses third-party packages—including their methods, classes, and docstrings—to generate accurate auto-completions. It handles CamelCase naming conventions seamlessly, which should fix your appJar pain points.
- LSP-pyright: This integrates Microsoft's Pyright language server into Sublime. Pyright excels at type inference and can pull completion data from both package source code and type stubs. If a package doesn't have official stubs, you can generate them using
stubgen(from mypy) and place them in your Python environment'ssite-packagesdirectory—Pyright will pick them up and generate completions. - AutoDocstring (paired with completion plugins): While AutoDocstring focuses on generating docstrings, combining it with a tool like SublimeJEDI lets you leverage existing package docs to populate more informative auto-completion entries.
2. Auto-Complete Support for appJar
appJar might not have official type stubs, but you can get working auto-completion with these steps:
- Generate stubs for appJar: Install mypy via
pip install mypy, then runstubgen -p appJarin your terminal. This will generate.pyistub files for the appJar package. Move these stubs into your Python environment'ssite-packages/appJardirectory. - Use SublimeJEDI or LSP-pyright: Once the stubs are in place, either of these plugins will recognize appJar's CamelCase classes and methods, giving you proper auto-completion as you type.
- Verify your Python environment: Double-check that your Sublime plugin is pointing to the correct Python interpreter where appJar is installed—this is a common gotcha that breaks auto-completion for third-party packages.
3. Better Alternatives to Anaconda
Anaconda works for basics, but these plugins offer more robust third-party package support:
- LSP-pyright: As mentioned earlier, it's fast, accurate, and handles modern Python features plus third-party packages exceptionally well. It also includes built-in type checking, which is a bonus for catching bugs early.
- SublimeJEDI: A tried-and-true lightweight option focused solely on Python auto-completion. It's easy to configure and works out of the box with most packages once your Python path is set correctly.
- Python Autocomplete: A simpler alternative that uses the built-in Python
dir()function and static analysis to generate completions. It's less powerful than Jedi or Pyright but might suffice if you want a minimal setup.
Quick Setup Tip
Whichever plugin you choose, don't forget to configure the Python interpreter path in the plugin settings. For example, in SublimeJEDI, you can set "python_interpreter": "/path/to/your/python/env/bin/python" to ensure it finds your installed packages like appJar.
内容的提问来源于stack exchange,提问作者twomed
相关产品推荐
相关产品推荐

