Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pylsp/plugins/yapf_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@

@hookimpl
def pylsp_format_document(workspace, document, options):
log.info("Formatting document %s with yapf", document)
with workspace.report_progress("format: yapf"):
return _format(document, options=options)


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


def get_style_config(document_path, options=None):
# Exclude file if it follows the patterns for that
exclude_patterns_from_ignore_file = file_resources.GetExcludePatternsForDir(os.getcwd())
if file_resources.IsIgnored(document_path, exclude_patterns_from_ignore_file):
return []

# Get the default styles as a string
# for a preset configuration, i.e. "pep8"
style_config = file_resources.GetDefaultStyleForDir(
Expand Down