emacs.d/pylsp-auto-import-modules.patch

42 lines
1.5 KiB
Diff
Raw Normal View History

diff --git a/pylsp/config/schema.json b/pylsp/config/schema.json
2022-10-11 21:09:20 +02:00
index bb82145..3c40d6a 100644
--- a/pylsp/config/schema.json
+++ b/pylsp/config/schema.json
@@ -87,6 +87,14 @@
"uniqueItems": true,
"description": "List of errors and warnings to enable."
},
+ "pylsp.plugins.jedi.auto_import_modules": {
+ "type": "array",
+ "default": ["numpy", "gi"],
+ "items": {
+ "type": "string"
+ },
+ "description": "List of module names for 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
--- a/pylsp/workspace.py
+++ b/pylsp/workspace.py
@@ -14,6 +14,8 @@ from . import lsp, uris, _utils
log = logging.getLogger(__name__)
2022-01-07 16:34:21 +01:00
+DEFAULT_AUTO_IMPORT_MODULES = ["numpy", "gi"]
+
# 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:
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')