@@ -116,6 +116,7 @@ def pylsp_format_document(workspace: Workspace, document: Document) -> Generator
116
116
Document to apply ruff on.
117
117
118
118
"""
119
+
119
120
log .debug (f"textDocument/formatting: { document } " )
120
121
outcome = yield
121
122
result = outcome .get_result ()
@@ -128,34 +129,37 @@ def pylsp_format_document(workspace: Workspace, document: Document) -> Generator
128
129
if not settings .format_enabled :
129
130
return
130
131
131
- new_text = run_ruff_format (
132
- settings = settings , document_path = document .path , document_source = source
133
- )
134
-
135
- if settings .format :
136
- # A second pass through the document with `ruff check` and only the rules
137
- # enabled via the format config property. This allows for things like
138
- # specifying `format = ["I"]` to get import sorting as part of formatting.
139
- new_text = run_ruff (
140
- settings = PluginSettings (
141
- ignore = ["ALL" ], select = settings .format , executable = settings .executable
142
- ),
143
- document_path = document .path ,
144
- document_source = new_text ,
145
- fix = True ,
132
+ with workspace .report_progress ("format: ruff" ):
133
+ new_text = run_ruff_format (
134
+ settings = settings , document_path = document .path , document_source = source
146
135
)
147
136
148
- # Avoid applying empty text edit
149
- if not new_text or new_text == source :
150
- return
137
+ if settings .format :
138
+ # A second pass through the document with `ruff check` and only the rules
139
+ # enabled via the format config property. This allows for things like
140
+ # specifying `format = ["I"]` to get import sorting as part of formatting.
141
+ new_text = run_ruff (
142
+ settings = PluginSettings (
143
+ ignore = ["ALL" ],
144
+ select = settings .format ,
145
+ executable = settings .executable ,
146
+ ),
147
+ document_path = document .path ,
148
+ document_source = new_text ,
149
+ fix = True ,
150
+ )
151
151
152
- range = Range (
153
- start = Position (line = 0 , character = 0 ),
154
- end = Position (line = len (document .lines ), character = 0 ),
155
- )
156
- text_edit = TextEdit (range = range , new_text = new_text )
152
+ # Avoid applying empty text edit
153
+ if not new_text or new_text == source :
154
+ return
155
+
156
+ range = Range (
157
+ start = Position (line = 0 , character = 0 ),
158
+ end = Position (line = len (document .lines ), character = 0 ),
159
+ )
160
+ text_edit = TextEdit (range = range , new_text = new_text )
157
161
158
- outcome .force_result (converter .unstructure ([text_edit ]))
162
+ outcome .force_result (converter .unstructure ([text_edit ]))
159
163
160
164
161
165
@hookimpl
@@ -174,10 +178,12 @@ def pylsp_lint(workspace: Workspace, document: Document) -> List[Dict]:
174
178
List of dicts containing the diagnostics.
175
179
176
180
"""
177
- settings = load_settings (workspace , document .path )
178
- checks = run_ruff_check (document = document , settings = settings )
179
- diagnostics = [create_diagnostic (check = c , settings = settings ) for c in checks ]
180
- return converter .unstructure (diagnostics )
181
+
182
+ with workspace .report_progress ("lint: ruff" ):
183
+ settings = load_settings (workspace , document .path )
184
+ checks = run_ruff_check (document = document , settings = settings )
185
+ diagnostics = [create_diagnostic (check = c , settings = settings ) for c in checks ]
186
+ return converter .unstructure (diagnostics )
181
187
182
188
183
189
def create_diagnostic (check : RuffCheck , settings : PluginSettings ) -> Diagnostic :
0 commit comments