Skip to content

Commit 00d32da

Browse files
committed
Intorduce ConfigSource.lsp_config to hook at updating
1 parent 3cac737 commit 00d32da

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

pyls/config/config.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ def plugin_settings(self, plugin, document_path=None):
144144

145145
def update(self, settings):
146146
"""Recursively merge the given settings into the current settings."""
147+
sources = settings.get('configurationSources', DEFAULT_CONFIG_SOURCES) + ['pyls']
148+
for source_name in reversed(sources):
149+
source = self._config_sources.get(source_name)
150+
if not source:
151+
continue
152+
source.lsp_config(settings)
153+
147154
self.settings.cache_clear()
148155
self._settings = settings
149156
log.info("Updated settings to %s", self._settings)

pyls/config/source.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ def project_config(self, document_path):
2525
"""Return project-level (i.e. workspace directory) configuration."""
2626
raise NotImplementedError()
2727

28+
def lsp_config(self, config):
29+
"""Check configuration at updating.
30+
31+
Typical usecase is updating via LSP didChangeConfiguration
32+
method.
33+
34+
Change config directly, if any changing like normalization is
35+
needed. It is nested dictionay.
36+
"""
37+
2838
@staticmethod
2939
def read_config_from_files(files):
3040
config = configparser.RawConfigParser()

0 commit comments

Comments
 (0)