Skip to content

Commit 6ff9aa9

Browse files
authored
Load rope_autoimport cache on workspace/didChangeConfiguration (#461)
1 parent 4f6aa20 commit 6ff9aa9

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

Diff for: pylsp/hookspecs.py

+5
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,8 @@ def pylsp_settings(config):
127127
@hookspec(firstresult=True)
128128
def pylsp_signature_help(config, workspace, document, position):
129129
pass
130+
131+
132+
@hookspec
133+
def pylsp_workspace_configuration_changed(config, workspace):
134+
pass

Diff for: pylsp/plugins/rope_autoimport.py

+12
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,15 @@ def pylsp_document_did_open(config: Config, workspace: Workspace):
238238
def pylsp_document_did_save(config: Config, workspace: Workspace, document: Document):
239239
"""Update the names associated with this document."""
240240
_reload_cache(config, workspace, [document])
241+
242+
243+
@hookimpl
244+
def pylsp_workspace_configuration_chaged(config: Config, workspace: Workspace):
245+
"""
246+
Initialize autoimport if it has been enabled through a
247+
workspace/didChangeConfiguration message from the frontend.
248+
249+
Generates the cache for local and global items.
250+
"""
251+
if config.plugin_settings("rope_autoimport").get("enabled", False):
252+
_reload_cache(config, workspace)

Diff for: pylsp/python_lsp.py

+1
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,7 @@ def m_workspace__did_change_configuration(self, settings=None):
766766
self.config.update((settings or {}).get("pylsp", {}))
767767
for workspace in self.workspaces.values():
768768
workspace.update_config(settings)
769+
self._hook("pylsp_workspace_configuration_changed")
769770
for doc_uri in workspace.documents:
770771
self.lint(doc_uri, is_saved=False)
771772

0 commit comments

Comments
 (0)