8000 Add support for Yapf ignore patterns (#60) · brandonwillard/python-lsp-server@659f6e5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 659f6e5

Browse files
authored
Add support for Yapf ignore patterns (pyth 8000 on-lsp#60)
1 parent 8fda905 commit 659f6e5

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
@@ -17,12 +17,14 @@
1717

1818
@hookimpl
1919
def pylsp_format_document(workspace, document, options):
20+
log.info("Formatting document %s with yapf", document)
2021
with workspace.report_progress("format: yapf"):
2122
return _format(document, options=options)
2223

2324

2425
@hookimpl
2526
def pylsp_format_range(workspace, document, range, options): # pylint: disable=redefined-builtin
27+
log.info("Formatting document %s in range %s with yapf", document, range)
2628
with workspace.report_progress("format_range: yapf"):
2729
# First we 'round' the range up/down to full lines only
2830
range['start']['character'] = 0
@@ -41,6 +43,11 @@ def pylsp_format_range(workspace, document, range, options): # pylint: disable=
4143

4244

4345
def get_style_config(document_path, options=None):
46+
# Exclude file if it follows the patterns for that
47+
exclude_patterns_from_ignore_file = file_resources.GetExcludePatternsForDir(os.getcwd())
48+
if file_resources.IsIgnored(document_path, exclude_patterns_from_ignore_file):
49+
return []
50+
4451
# Get the default styles as a string
4552
# for a preset configuration, i.e. "pep8"
4653
style_config = file_resources.GetDefaultStyleForDir(

0 commit comments

Comments
 (0)
0