Autoimport for pylsp
Requirements:
- install
python-lsp-server[rope] - set
pylsp.plugins.rope_autoimport.enabledtotrue - This enables both completions and code actions. You can switch them off by setting
pylsp.plugins.rope_autoimport.completions.enabledand/orpylsp.plugins.rope_autoimport.code_actions.enabledtofalse
Startup
Autoimport will generate an autoimport sqllite3 database in .ropefolder/autoimport.db on startup.
This will take a few seconds but should be much quicker on future runs.
Usage
Autoimport will provide suggestions to import names from everything in sys.path. You can change this by changing where pylsp is running or by setting rope's 'python_path' option.
It will suggest modules, submodules, keywords, functions, and classes.
Since autoimport inserts everything towards the end of the import group, its recommended you use the isort plugin.