@@ -189,6 +189,37 @@ function M.use_client(callback)
189
189
)
190
190
end
191
191
192
+ local function get_handlers ()
193
+ local handlers = {
194
+ PanelSolution = api .handlers .PanelSolution ,
195
+ PanelSolutionsDone = api .handlers .PanelSolutionsDone ,
196
+ statusNotification = api .handlers .statusNotification ,
197
+ [" copilot/openURL" ] = api .handlers [" copilot/openURL" ],
198
+ }
199
+
200
+ -- optional handlers
201
+ local logger_conf = config .get (" logger" ) --[[ @as copilot_config_logging]]
202
+ if logger_conf .trace_lsp ~= " off" then
203
+ handlers = vim .tbl_extend (" force" , handlers , {
204
+ [" $/logTrace" ] = logger .handle_lsp_trace ,
205
+ })
206
+ end
207
+
208
+ if logger_conf .trace_lsp_progress then
209
+ handlers = vim .tbl_extend (" force" , handlers , {
210
+ [" $/progress" ] = logger .handle_lsp_progress ,
211
+ })
212
+ end
213
+
214
+ if logger_conf .log_lsp_messages then
215
+ handlers = vim .tbl_extend (" force" , handlers , {
216
+ [" window/logMessage" ] = logger .handle_log_lsp_messages ,
217
+ })
218
+ end
219
+
220
+ return handlers
221
+ end
222
+
192
223
local function prepare_client_config (overrides )
193
224
local node = config .get (" copilot_node_command" )
194
225
@@ -217,36 +248,6 @@ local function prepare_client_config(overrides)
217
248
workspaceFolders = true ,
218
249
}
219
250
220
- local handlers = {
221
- PanelSolution = api .handlers .PanelSolution ,
222
- PanelSolutionsDone = api .handlers .PanelSolutionsDone ,
223
- statusNotification = api .handlers .statusNotification ,
224
- [" copilot/openURL" ] = api .handlers [" copilot/openURL" ],
225
- -- set up "window/logMessage" handler here instead of in `logger.lua`, since some other lsp servers don't support this method, such as jsonlsp
226
- [" window/logMessage" ] = function (_ , result , _ )
227
- if not result then
228
- return
229
- end
230
-
231
- local message = string.format (" LSP message: %s" , result .message )
232
- local message_type = result .type --[[ @as integer]]
233
-
234
- if message_type == 1 then
235
- logger .error (message )
236
- elseif message_type == 2 then
237
- logger .warn (message )
238
- elseif message_type == 3 then
239
- logger .info (message )
240
- elseif message_type == 4 then
241
- logger .info (message )
242
- elseif message_type == 5 then
243
- logger .debug (message )
244
- else
245
- logger .trace (message )
246
- end
247
- end ,
248
- }
249
-
250
251
local root_dir = config .get_root_dir ()
251
252
local workspace_folders = {
252
253
--- @type workspace_folder
@@ -325,7 +326,7 @@ local function prepare_client_config(overrides)
325
326
end )
326
327
end
327
328
end ,
328
- handlers = handlers ,
329
+ handlers = get_handlers () ,
329
330
init_options = {
330
331
copilotIntegrationId = " vscode-chat" ,
331
332
-- Fix LSP warning: editorInfo and editorPluginInfo will soon be required in initializationOptions
0 commit comments