@@ -9,6 +9,7 @@ function! lsp#ui#vim#implementation(in_preview) abort
9
9
10
10
if len (l: servers ) == 0
11
11
call s: not_supported (' Retrieving implementation' )
12
+ call s: after_failure (' implementation' )
12
13
return
13
14
endif
14
15
let l: ctx = { ' counter' : len (l: servers ), ' list' :[], ' last_command_id' : l: command_id , ' jump_if_one' : 1 , ' in_preview' : a: in_preview }
@@ -33,6 +34,7 @@ function! lsp#ui#vim#type_definition(in_preview) abort
33
34
34
35
if len (l: servers ) == 0
35
36
call s: not_supported (' Retrieving type definition' )
37
+ call s: after_failure (' type definition' )
36
38
return
37
39
endif
38
40
let l: ctx = { ' counter' : len (l: servers ), ' list' :[], ' last_command_id' : l: command_id , ' jump_if_one' : 1 , ' in_preview' : a: in_preview }
@@ -83,6 +85,7 @@ function! lsp#ui#vim#declaration(in_preview) abort
83
85
84
86
if len (l: servers ) == 0
85
87
call s: not_supported (' Retrieving declaration' )
88
+ call s: after_failure (' declaration' )
86
89
return
87
90
endif
88
91
@@ -108,6 +111,7 @@ function! lsp#ui#vim#definition(in_preview) abort
108
111
109
112
if len (l: servers ) == 0
110
113
call s: not_supported (' Retrieving definition' )
114
+ call s: after_failure (' definition' )
111
115
return
112
116
endif
113
117
@@ -135,6 +139,7 @@ function! lsp#ui#vim#references() abort
135
139
let l: ctx = { ' counter' : len (l: servers ), ' list' :[], ' last_command_id' : l: command_id , ' jump_if_one' : 0 , ' in_preview' : 0 }
136
140
if len (l: servers ) == 0
137
141
call s: not_supported (' Retrieving references' )
142
+ call s: after_failure (' references' )
138
143
return
139
144
endif
140
145
@@ -185,6 +190,7 @@ function! lsp#ui#vim#rename() abort
185
190
186
191
if len (l: servers ) == 0
187
192
call s: not_supported (' Renaming' )
193
+ call s: after_failure (' rename' )
188
194
return
189
195
endif
190
196
@@ -212,6 +218,7 @@ function! s:document_format(sync) abort
212
218
213
219
if len (l: servers ) == 0
214
220
call s: not_supported (' Document formatting' )
221
+ call s: after_failure (' document format' )
215
222
return
216
223
endif
217
224
@@ -292,6 +299,7 @@ function! s:document_format_range(sync, type) abort
292
299
293
300
if len (l: servers ) == 0
294
301
call s: not_supported (' Document range formatting' )
302
+ call s: after_failure (' range format' )
295
303
return
296
304
endif
297
305
@@ -340,6 +348,7 @@ function! lsp#ui#vim#workspace_symbol() abort
340
348
341
349
if len (l: servers ) == 0
342
350
call s: not_supported (' Retrieving workspace symbols' )
351
+ call s: after_failure (' workspaceSymbol' )
343
352
return
344
353
endif
345
354
@@ -370,6 +379,7 @@ function! lsp#ui#vim#document_symbol() abort
370
379
371
380
if len (l: servers ) == 0
372
381
call s: not_supported (' Retrieving symbols' )
382
+ call s: after_failure (' documentSymbol' )
373
383
return
374
384
endif
375
385
@@ -393,6 +403,7 @@ function! s:handle_symbol(server, last_command_id, type, data) abort
393
403
394
404
if lsp#client#is_error (a: data [' response' ])
395
405
call lsp#utils#error (' Failed to retrieve ' . a: type . ' for ' . a: server . ' : ' . lsp#client#error_message (a: data [' response' ]))
406
+ call s: after_failure (a: type )
396
407
return
397
408
endif
398
409
@@ -402,6 +413,7 @@ function! s:handle_symbol(server, last_command_id, type, data) abort
402
413
403
414
if empty (l: list )
404
415
call lsp#utils#error (' No ' . a: type .' found' )
416
+ call s: after_failure (a: type )
405
417
else
406
418
echo ' Retrieved ' . a: type
407
419
botright copen
@@ -417,13 +429,15 @@ function! s:handle_location(ctx, server, type, data) abort "ctx = {counter, list
417
429
418
430
if lsp#client#is_error (a: data [' response' ]) || ! has_key (a: data [' response' ], ' result' )
419
431
call lsp#utils#error (' Failed to retrieve ' . a: type . ' for ' . a: server . ' : ' . lsp#client#error_message (a: data [' response' ]))
432
+ call s: after_failure (a: type )
420
433
else
421
434
let a: ctx [' list' ] = a: ctx [' list' ] + lsp#utils#location#_lsp_to_vim_list (a: data [' response' ][' result' ])
422
435
endif
423
436
424
437
if a: ctx [' counter' ] == 0
425
438
if empty (a: ctx [' list' ])
426
439
call lsp#utils#error (' No ' . a: type .' found' )
440
+ call s: after_failure (a: type )
427
441
else
428
442
call lsp#utils#tagstack#_update ()
429
443
@@ -464,6 +478,7 @@ function! s:handle_rename_prepare(server, last_command_id, type, data) abort
464
478
465
479
if lsp#client#is_error (a: data [' response' ])
466
480
call lsp#utils#error (' Failed to retrieve ' . a: type . ' for ' . a: server . ' : ' . lsp#client#error_message (a: data [' response' ]))
481
+ call s: after_failure (' rename' )
467
482
return
468
483
endif
469
484
@@ -495,6 +510,7 @@ function! s:handle_workspace_edit(server, last_command_id, type, data) abort
495
510
496
511
if lsp#client#is_error (a: data [' response' ])
497
512
call lsp#utils#error (' Failed to retrieve ' . a: type . ' for ' . a: server . ' : ' . lsp#client#error_message (a: data [' response' ]))
513
+ call s: after_failure (a: type )
498
514
return
499
515
endif
500
516
@@ -510,6 +526,7 @@ function! s:handle_text_edit(server, last_command_id, type, data) abort
510
526
511
527
if lsp#client#is_error (a: data [' response' ])
512
528
call lsp#utils#error (' Failed to ' . a: type . ' for ' . a: server . ' : ' . lsp#client#error_message (a: data [' response' ]))
529
+ call s: after_failure (a: type )
513
530
return
514
531
endif
515
532
@@ -584,6 +601,14 @@ function! s:get_treeitem_for_tree_hierarchy(Callback, object) dict abort
584
601
call a: Callback (' success' , s: hierarchyitem_to_treeitem (a: object ))
585
602
endfunction
586
603
604
+ function ! s: after_failure (type ) abort
605
+ execute ' doautocmd User ' . s: event_name_on_failure (a: type )
606
+ endfunction
607
+
608
+ function ! s: event_name_on_failure (type ) abort
609
+ return ' lsp_' . substitute (substitute (a: type , ' \s' , ' _' , ' g' ), ' \C[A-Z]' , ' \="_" . tolower(submatch(0))' , ' g' ) . ' _failed'
610
+ endfunction
611
+
587
612
function ! lsp#ui#vim#code_action () abort
588
613
call lsp#ui#vim#code_action#do ({
589
614
\ ' sync' : v: false ,
0 commit comments