Skip to content

Commit

Permalink
Load rope_autoimport cache on workspace/didChangeConfiguration (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
tkrabel-db authored and staticf0x committed Oct 27, 2023
1 parent 0fdd016 commit 60ba623
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
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
12 changes: 12 additions & 0 deletions pylsp/plugins/rope_autoimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,15 @@ 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

0 comments on commit 60ba623

Please sign in to comment.