Skip to content

Commit e587446

Browse files
authored
add support for yapf ignore patterns
1 parent 58b229b commit e587446

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pylsp/plugins/yapf_format.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212

1313
@hookimpl
1414
def pylsp_format_document(document):
15+
log.info("Formatting document %s with yapf", document)
1516
return _format(document)
1617

1718

1819
@hookimpl
1920
def pylsp_format_range(document, range): # pylint: disable=redefined-builtin
21+
log.info("Formatting document %s in range %s with yapf", document, range)
2022
# First we 'round' the range up/down to full lines only
2123
range['start']['character'] = 0
2224
range['end']['line'] += 1
@@ -34,6 +36,11 @@ def pylsp_format_range(document, range): # pylint: disable=redefined-builtin
3436

3537

3638
def _format(document, lines=None):
39+
40+
exclude_patterns_from_ignore_file = file_resources.GetExcludePatternsForDir(os.getcwd())
41+
if file_resources.IsIgnored(document.path, exclude_patterns_from_ignore_file):
42+
return []
43+
3744
new_source, changed = FormatCode(
3845
document.source,
3946
lines=lines,

0 commit comments

Comments
 (0)