Skip to content

Commit

Permalink
yapf_format: fix config lookup (#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
perrinjerome authored and gatesn committed Jan 19, 2019
1 parent 98977b6 commit db16c23
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyls/plugins/yapf_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
)

Expand Down
11 changes: 11 additions & 0 deletions test/plugins/test_yapf_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit db16c23

Please sign in to comment.