Skip to content

Commit 40a5e77

Browse files
committed
Normalize ply.source_roots at LSP didChangeConfiguration method
This is useful to specify source roots in relative path, if pyls process might run in other than the root of the target workspace(s).
1 parent 00d32da commit 40a5e77

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pyls/config/pyls_conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ def project_config(self, document_path):
7070

7171
return settings
7272

73+
def lsp_config(self, config):
74+
self.normalize(config, self._norm_root_path)
75+
7376
def normalize(self, config, basedir):
7477
for config_path, inside_only in NORMALIZED_CONFIGS:
7578
paths = get_config_by_path(config, config_path)

test/test_workspace.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ def _make_paths_dir_relative(paths, dirname):
143143
'tox.ini',
144144
'service/foo/setup.cfg',
145145
'service/foo/tox.ini',
146+
None,
146147
])
147148
def test_source_roots_config(tmpdir, metafile):
148149
"""Examine that source_roots config is intentionaly read in.
@@ -178,6 +179,12 @@ def test_source_roots_config(tmpdir, metafile):
178179
initializationOptions={}
179180
)
180181

182+
if not metafile:
183+
# configured by client via LSP after pyls startup
184+
pyls.m_workspace__did_change_configuration({
185+
'pyls': {'source_roots': source_roots},
186+
})
187+
181188
# put new document under ROOT/service/foo
182189
test_uri = uris.from_fs_path(os.path.join(root_path, doc_root, 'hello/test.py'))
183190
pyls.workspace.put_document(test_uri, 'assert true')

0 commit comments

Comments
 (0)