diff --git a/pyls/plugins/yapf_format.py b/pyls/plugins/yapf_format.py index 4d770a4b..16afe97d 100644 --- a/pyls/plugins/yapf_format.py +++ b/pyls/plugins/yapf_format.py @@ -37,7 +37,7 @@ def _format(document, lines=None): lines=lines, filename=document.filename, style_config=file_resources.GetDefaultStyleForDir( - os.path.dirname(document.filename) + os.path.dirname(document.path) ) ) diff --git a/test/plugins/test_yapf_format.py b/test/plugins/test_yapf_format.py index 98f37b66..4bf6be32 100644 --- a/test/plugins/test_yapf_format.py +++ b/test/plugins/test_yapf_format.py @@ -45,3 +45,14 @@ def test_range_format(): def test_no_change(): doc = Document(DOC_URI, GOOD_DOC) assert not pyls_format_document(doc) + + +def test_config_file(tmpdir): + # a config file in the same directory as the source file will be used + conf = tmpdir.join('.style.yapf') + conf.write('[style]\ncolumn_limit = 14') + src = tmpdir.join('test.py') + doc = Document(uris.from_fs_path(src.strpath), DOC) + + # A was split on multiple lines because of column_limit from config file + assert pyls_format_document(doc)[0]['newText'] == "A = [\n 'h', 'w',\n 'a'\n]\n\nB = ['h', 'w']\n"