From 77c451c837d2592134b00a63b28f453f5f37b21e Mon Sep 17 00:00:00 2001 From: jjlorenzo <48272+jjlorenzo@users.noreply.github.com> Date: Sat, 24 Jul 2021 00:52:06 -0500 Subject: [PATCH] add support for yapf ignore patterns --- pylsp/plugins/yapf_format.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pylsp/plugins/yapf_format.py b/pylsp/plugins/yapf_format.py index 4d296eaa..754d9cbb 100644 --- a/pylsp/plugins/yapf_format.py +++ b/pylsp/plugins/yapf_format.py @@ -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 @@ -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(