2022-01-01 11:42:28 +01:00
|
|
|
diff --git a/pylsp/config/schema.json b/pylsp/config/schema.json
|
2022-07-09 06:30:27 +02:00
|
|
|
index 4443780..a19972b 100644
|
2022-01-01 11:42:28 +01:00
|
|
|
--- a/pylsp/config/schema.json
|
|
|
|
+++ b/pylsp/config/schema.json
|
2022-07-09 06:30:27 +02:00
|
|
|
@@ -87,6 +87,14 @@
|
2022-07-01 09:43:42 +02:00
|
|
|
"uniqueItems": true,
|
2022-01-01 11:42:28 +01:00
|
|
|
"description": "List of errors and warnings to enable."
|
|
|
|
},
|
|
|
|
+ "pylsp.plugins.jedi.auto_import_modules": {
|
|
|
|
+ "type": "array",
|
2022-07-01 09:43:42 +02:00
|
|
|
+ "default": ["numpy", "gi"],
|
2022-01-01 11:42:28 +01:00
|
|
|
+ "items": {
|
|
|
|
+ "type": "string"
|
|
|
|
+ },
|
|
|
|
+ "description": "List of module names for jedi to import (jedi.settings.auto_import_modules)."
|
|
|
|
+ },
|
|
|
|
"pylsp.plugins.jedi.extra_paths": {
|
|
|
|
"type": "array",
|
|
|
|
"default": [],
|
|
|
|
diff --git a/pylsp/workspace.py b/pylsp/workspace.py
|
2022-01-07 16:34:21 +01:00
|
|
|
index bf312f6..4758b53 100644
|
2022-01-01 11:42:28 +01:00
|
|
|
--- a/pylsp/workspace.py
|
|
|
|
+++ b/pylsp/workspace.py
|
|
|
|
@@ -14,6 +14,8 @@ from . import lsp, uris, _utils
|
2022-02-08 13:34:50 +01:00
|
|
|
|
2022-01-01 11:42:28 +01:00
|
|
|
log = logging.getLogger(__name__)
|
2022-02-08 13:34:50 +01:00
|
|
|
|
2022-01-07 16:34:21 +01:00
|
|
|
+DEFAULT_AUTO_IMPORT_MODULES = ["numpy", "gi"]
|
2022-01-01 11:42:28 +01:00
|
|
|
+
|
|
|
|
# TODO: this is not the best e.g. we capture numbers
|
|
|
|
RE_START_WORD = re.compile('[A-Za-z_0-9]*$')
|
|
|
|
RE_END_WORD = re.compile('^[A-Za-z_0-9]*')
|
|
|
|
@@ -252,6 +254,8 @@ class Document:
|
2022-02-08 13:34:50 +01:00
|
|
|
|
2022-01-01 11:42:28 +01:00
|
|
|
if self._config:
|
|
|
|
jedi_settings = self._config.plugin_settings('jedi', document_path=self.path)
|
|
|
|
+ jedi.settings.auto_import_modules = jedi_settings.get('auto_import_modules',
|
|
|
|
+ DEFAULT_AUTO_IMPORT_MODULES)
|
|
|
|
environment_path = jedi_settings.get('environment')
|
|
|
|
extra_paths = jedi_settings.get('extra_paths') or []
|
|
|
|
env_vars = jedi_settings.get('env_vars')
|