Skip to content

Load rope_autoimport cache on workspace/didChangeConfiguration #461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pylsp/hookspecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,8 @@ def pylsp_settings(config):
@hookspec(firstresult=True)
def pylsp_signature_help(config, workspace, document, position):
pass


@hookspec
def pylsp_workspace_configuration_changed(config, workspace):
pass
11 changes: 11 additions & 0 deletions pylsp/plugins/rope_autoimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,14 @@ def pylsp_document_did_open(config: Config, workspace: Workspace):
def pylsp_document_did_save(config: Config, workspace: Workspace, document: Document):
"""Update the names associated with this document."""
_reload_cache(config, workspace, [document])


@hookimpl
def pylsp_workspace_configuration_chaged(config: Config, workspace: Workspace):
"""Initialize AutoImport if it has been enabled through a
workspace/didChangeConfiguration message from the frontend.

Generates the cache for local and global items.
"""
if config.plugin_settings("rope_autoimport").get("enabled", False):
_reload_cache(config, workspace)
1 change: 1 addition & 0 deletions pylsp/python_lsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@ def m_workspace__did_change_configuration(self, settings=None):
self.config.update((settings or {}).get("pylsp", {}))
for workspace in self.workspaces.values():
workspace.update_config(settings)
self._hook("pylsp_workspace_configuration_changed")
for doc_uri in workspace.documents:
self.lint(doc_uri, is_saved=False)

Expand Down