Skip to content

Commit 6dd3149

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 bd23fcf commit 6dd3149

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

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
@@ -144,6 +144,7 @@ def _make_paths_dir_relative(paths, dirname):
144144
'tox.ini',
145145
'service/foo/setup.cfg',
146146
'service/foo/tox.ini',
147+
None,
147148
])
148149
def test_source_roots_config(tmpdir, metafile):
149150
"""Examine that source_roots config is intentionaly read in.
@@ -179,6 +180,12 @@ def test_source_roots_config(tmpdir, metafile):
179180
initializationOptions={}
180181
)
181182

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

0 commit comments

Comments
 (0)