forked from vlime/vlime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vlime.vim
1893 lines (1727 loc) · 62.8 KB
/
vlime.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
""
" @dict VlimeConnection
" Vlime uses @dict(VlimeConnection) objects to represent connections to the
" servers. You can create such an object by calling
" @function(vlime#plugin#ConnectREPL) or @function(vlime#New).
"
" Most of the connection object's methods are thin wrappers around raw
" SLIME/SWANK messages, and they are asynchronous. These async methods have an
" optional callback argument, to allow a function be registered for handling
" the result returned by the server. The callback functions should accept two
" arguments:
"
" function! SomeCallbackFunc({conn_obj}, {result}) ...
"
" {conn_obj} is the connection object in question, and {result} is the
" returned value.
"
" See below for a detailed list of methods for @dict(VlimeConnection) objects.
"
""
" @usage [cb_data] [ui]
" @public
"
" Create a @dict(VlimeConnection).
"
" [cb_data] is arbitrary data, accessible from the connection callbacks.
" [ui] is an instance of @dict(VlimeUI), see @function(vlime#ui#GetUI).
"
" This function is seldom used directly. To connect to a server, call
" @function(vlime#plugin#ConnectREPL).
function! vlime#New(...)
let cb_data = get(a:000, 0, v:null)
let ui = get(a:000, 1, v:null)
let obj = {
\ 'cb_data': cb_data,
\ 'channel': v:null,
\ 'remote_prefix': '',
\ 'ping_tag': 1,
\ 'next_local_channel_id': 1,
\ 'local_channels': {},
\ 'remote_channels': {},
\ 'ui': ui,
\ 'Connect': function('vlime#Connect'),
\ 'IsConnected': function('vlime#IsConnected'),
\ 'Close': function('vlime#Close'),
\ 'Call': function('vlime#Call'),
\ 'SendRaw': function('vlime#SendRaw'),
\ 'Send': function('vlime#Send'),
\ 'FixRemotePath': function('vlime#FixRemotePath'),
\ 'FixLocalPath': function('vlime#FixLocalPath'),
\ 'GetCurrentPackage': function('vlime#GetCurrentPackage'),
\ 'SetCurrentPackage': function('vlime#SetCurrentPackage'),
\ 'GetCurrentThread': function('vlime#GetCurrentThread'),
\ 'SetCurrentThread': function('vlime#SetCurrentThread'),
\ 'WithPackage': function('vlime#WithPackage'),
\ 'WithThread': function('vlime#WithThread'),
\ 'MakeLocalChannel': function('vlime#MakeLocalChannel'),
\ 'RemoveLocalChannel': function('vlime#RemoveLocalChannel'),
\ 'MakeRemoteChannel': function('vlime#MakeRemoteChannel'),
\ 'RemoveRemoteChannel': function('vlime#RemoveRemoteChannel'),
\ 'EmacsChannelSend': function('vlime#EmacsChannelSend'),
\ 'EmacsRex': function('vlime#EmacsRex'),
\ 'Ping': function('vlime#Ping'),
\ 'Pong': function('vlime#Pong'),
\ 'ConnectionInfo': function('vlime#ConnectionInfo'),
\ 'SwankRequire': function('vlime#SwankRequire'),
\ 'SetPackage': function('vlime#SetPackage'),
\ 'DescribeSymbol': function('vlime#DescribeSymbol'),
\ 'OperatorArgList': function('vlime#OperatorArgList'),
\ 'SimpleCompletions': function('vlime#SimpleCompletions'),
\ 'ReturnString': function('vlime#ReturnString'),
\ 'Return': function('vlime#Return'),
\ 'SwankMacroExpandOne': function('vlime#SwankMacroExpandOne'),
\ 'SwankMacroExpand': function('vlime#SwankMacroExpand'),
\ 'SwankMacroExpandAll': function('vlime#SwankMacroExpandAll'),
\ 'DisassembleForm': function('vlime#DisassembleForm'),
\ 'CompileStringForEmacs': function('vlime#CompileStringForEmacs'),
\ 'CompileFileForEmacs': function('vlime#CompileFileForEmacs'),
\ 'LoadFile': function('vlime#LoadFile'),
\ 'XRef': function('vlime#XRef'),
\ 'FindDefinitionsForEmacs': function('vlime#FindDefinitionsForEmacs'),
\ 'FindSourceLocationForEmacs': function('vlime#FindSourceLocationForEmacs'),
\ 'AproposListForEmacs': function('vlime#AproposListForEmacs'),
\ 'DocumentationSymbol': function('vlime#DocumentationSymbol'),
\ 'Interrupt': function('vlime#Interrupt'),
\ 'SLDBAbort': function('vlime#SLDBAbort'),
\ 'SLDBBreak': function('vlime#SLDBBreak'),
\ 'SLDBContinue': function('vlime#SLDBContinue'),
\ 'SLDBStep': function('vlime#SLDBStep'),
\ 'SLDBNext': function('vlime#SLDBNext'),
\ 'SLDBOut': function('vlime#SLDBOut'),
\ 'SLDBReturnFromFrame': function('vlime#SLDBReturnFromFrame'),
\ 'SLDBDisassemble': function('vlime#SLDBDisassemble'),
\ 'InvokeNthRestartForEmacs': function('vlime#InvokeNthRestartForEmacs'),
\ 'RestartFrame': function('vlime#RestartFrame'),
\ 'FrameLocalsAndCatchTags': function('vlime#FrameLocalsAndCatchTags'),
\ 'FrameSourceLocation': function('vlime#FrameSourceLocation'),
\ 'EvalStringInFrame': function('vlime#EvalStringInFrame'),
\ 'InitInspector': function('vlime#InitInspector'),
\ 'InspectorReinspect': function('vlime#InspectorReinspect'),
\ 'InspectorRange': function('vlime#InspectorRange'),
\ 'InspectNthPart': function('vlime#InspectNthPart'),
\ 'InspectorCallNthAction': function('vlime#InspectorCallNthAction'),
\ 'InspectorPop': function('vlime#InspectorPop'),
\ 'InspectorNext': function('vlime#InspectorNext'),
\ 'InspectCurrentCondition': function('vlime#InspectCurrentCondition'),
\ 'InspectInFrame': function('vlime#InspectInFrame'),
\ 'InspectFrameVar': function('vlime#InspectFrameVar'),
\ 'ListThreads': function('vlime#ListThreads'),
\ 'KillNthThread': function('vlime#KillNthThread'),
\ 'DebugNthThread': function('vlime#DebugNthThread'),
\ 'UndefineFunction': function('vlime#UndefineFunction'),
\ 'UninternSymbol': function('vlime#UninternSymbol'),
\ 'OnServerEvent': function('vlime#OnServerEvent'),
\ 'server_event_handlers': {
\ 'PING': function('vlime#OnPing'),
\ 'NEW-PACKAGE': function('vlime#OnNewPackage'),
\ 'DEBUG': function('vlime#OnDebug'),
\ 'DEBUG-ACTIVATE': function('vlime#OnDebugActivate'),
\ 'DEBUG-RETURN': function('vlime#OnDebugReturn'),
\ 'WRITE-STRING': function('vlime#OnWriteString'),
\ 'READ-STRING': function('vlime#OnReadString'),
\ 'READ-FROM-MINIBUFFER': function('vlime#OnReadFromMiniBuffer'),
\ 'INDENTATION-UPDATE': function('vlime#OnIndentationUpdate'),
\ 'NEW-FEATURES': function('vlime#OnNewFeatures'),
\ 'INVALID-RPC': function('vlime#OnInvalidRPC'),
\ 'INSPECT': function('vlime#OnInspect'),
\ 'CHANNEL-SEND': function('vlime#OnChannelSend'),
\ }
\ }
return obj
endfunction
" ================== methods for vlime connections ==================
""
" @dict VlimeConnection.Connect
" @usage {host} {port} [remote_prefix] [timeout]
" @public
"
" Connect to a server.
"
" {host} and {port} specify the server to connect to.
" [remote_prefix], if specified, is an SFTP URL prefix, to tell Vlime to open
" remote files via SFTP (see |vlime-remote-server|).
" [timeout] is the time to wait for the connection to be made, in
" milliseconds.
function! vlime#Connect(host, port, ...) dict
let remote_prefix = get(a:000, 0, '')
let timeout = get(a:000, 1, v:null)
let self.channel = vlime#compat#ch_open(a:host, a:port,
\ {chan, msg -> self.OnServerEvent(chan, msg)},
\ timeout)
if vlime#compat#ch_status(self.channel) != 'open'
call self.Close()
throw 'vlime#Connect: failed to open channel'
endif
let self['remote_prefix'] = remote_prefix
return self
endfunction
""
" @dict VlimeConnection.IsConnected
" @public
"
" Return |TRUE| for a connected connection, |FALSE| otherwise.
function! vlime#IsConnected() dict
return type(self.channel) == vlime#compat#ch_type() &&
\ vlime#compat#ch_status(self.channel) == 'open'
endfunction
""
" @dict VlimeConnection.Close
" @public
"
" Close this connection.
function! vlime#Close() dict
if type(self.channel) == vlime#compat#ch_type()
try
call vlime#compat#ch_close(self.channel)
catch /^vlime#compat#.*not an open channel.*/
endtry
let self.channel = v:null
endif
return self
endfunction
""
" @dict VlimeConnection.Call
" @public
"
" Send a raw message {msg} to the server, and wait for a reply.
function! vlime#Call(msg) dict
return vlime#compat#ch_evalexpr(self.channel, a:msg)
endfunction
""
" @dict VlimeConnection.Send
" @usage {msg} [callback]
" @private
"
" Send a raw message {msg} to the server.
function! vlime#SendRaw(msg) dict
" TODO: remove that indirection?
return call('vlime#compat#ch_sendraw', [self.channel, a:msg])
endfunction
""
" @dict VlimeConnection.Send
" @usage {msg} [callback]
" @public
"
" Send a message {msg} to the server, and optionally register an async
" [callback] function to handle the reply.
"
" An additional optional flag, [raw-or-tag], can be used to get a (swank)
" message ID conditionally appended to message; in particular, the specified
" value will be used as follows:
"
" - -1: a new ID will be generated and appended to the message
" - 0: no ID will be generated nor appended to the message
" - >0: [raw-or-tag] is assumed to be a valid swank ID, and will be appended to
" the message as is
function! vlime#Send(msg, ...) dict
" TODO: remove that indirection?
return call('vlime#compat#ch_sendexpr', [self.channel, a:msg] + a:000)
endfunction
""
" @dict VlimeConnection.FixRemotePath
" @public
"
" Fix the remote file paths after they are received from the server, so that
" Vim can open the files via SFTP.
" {path} can be a plain string or a Swank source location object.
function! vlime#FixRemotePath(path) dict
if type(a:path) == v:t_string
return self['remote_prefix'] . a:path
elseif type(a:path) == v:t_list && a:path[0] == vlime#KW('LOCATION')
if a:path[1][0] == vlime#KW('FILE')
let a:path[1][1] = self['remote_prefix'] . a:path[1][1]
elseif a:path[1][0] == vlime#KW('BUFFER-AND-FILE')
let a:path[1][2] = self['remote_prefix'] . a:path[1][2]
endif
return a:path
else
throw 'vlime#FixRemotePath: unknown path: ' . string(a:path)
endif
endfunction
""
" @dict VlimeConnection.FixLocalPath
" @public
"
" Fix the local file paths before sending them to the server, so that the
" server can see the correct files.
" {path} should be a plain string or v:null.
function! vlime#FixLocalPath(path) dict
if type(a:path) != v:t_string
return a:path
endif
let prefix_len = len(self['remote_prefix'])
if prefix_len > 0 && a:path[0:prefix_len-1] == self['remote_prefix']
return a:path[prefix_len:]
else
return a:path
endif
endfunction
""
" @dict VlimeConnection.GetCurrentPackage
" @public
"
" Return the Common Lisp package bound to the current buffer. See
" |vlime-current-package|.
function! vlime#GetCurrentPackage() dict
if type(self.ui) != type(v:null)
return self.ui.GetCurrentPackage()
else
return v:null
endif
endfunction
""
" @dict VlimeConnection.SetCurrentPackage
" @public
"
" Bind a Common Lisp package to the current buffer. See
" |vlime-current-package|. This method does NOT check whether the argument is
" a valid package. See @function(VlimeConnection.SetPackage) for a safer
" alternative.
function! vlime#SetCurrentPackage(package) dict
if type(self.ui) != type(v:null)
call self.ui.SetCurrentPackage(a:package)
endif
endfunction
""
" @dict VlimeConnection.GetCurrentThread
" @public
"
" Return the thread bound to the current buffer. Currently this method only
" makes sense in the debugger buffer.
function! vlime#GetCurrentThread() dict
if type(self.ui) != type(v:null)
return self.ui.GetCurrentThread()
else
return v:true
endif
endfunction
""
" @dict VlimeConnection.SetCurrentThread
" @public
"
" Bind a thread to the current buffer. Don't call this method directly, unless
" you know what you're doing.
function! vlime#SetCurrentThread(thread) dict
if type(self.ui) != type(v:null)
call self.ui.SetCurrentThread(a:thread)
endif
endfunction
""
" @dict VlimeConnection.WithThread
" @public
"
" Call {Func} with {thread} set as the current thread. The current thread will
" be reset once this method returns. This is useful when you want to e.g.
" evaluate something in certain threads.
function! vlime#WithThread(thread, Func) dict
let old_thread = self.GetCurrentThread()
try
call self.SetCurrentThread(a:thread)
return a:Func()
finally
call self.SetCurrentThread(old_thread)
endtry
endfunction
""
" @dict VlimeConnection.WithPackage
" @public
"
" Call {Func} with {package} set as the current package. The current package
" will be reset once this method returns.
function! vlime#WithPackage(package, Func) dict
let old_package = self.GetCurrentPackage()
try
call self.SetCurrentPackage([a:package, a:package])
return a:Func()
finally
call self.SetCurrentPackage(old_package)
endtry
endfunction
""
" @dict VlimeConnection.MakeLocalChannel
" @usage [chan_id] [callback]
" @public
"
" Create a local channel (in the sense of SLIME channels). [chan_id], if
" provided and not v:null, should be be a unique integer to identify the new
" channel. A new ID will be generated if [chan_id] is omitted or v:null.
" [callback] is a function responsible for handling the messages directed to
" this very channel. It should have such a signature:
"
" SomeCallbackFunction(<conn>, <chan>, <msg>)
"
" <conn> is a @dict(VlimeConnection) object. <chan> is the channel object in
" question, and <msg> is the channel message received from the server.
function! vlime#MakeLocalChannel(...) dict
let chan_id = get(a:000, 0, v:null)
let Callback = get(a:000, 1, v:null)
if type(chan_id) == type(v:null)
let chan_id = self['next_local_channel_id']
let self['next_local_channel_id'] += 1
endif
if has_key(self['local_channels'], chan_id)
throw 'vlime#MakeLocalChannel: channel ' . chan_id . ' already exists'
endif
let chan_obj = {
\ 'id': chan_id,
\ 'callback': Callback,
\ }
let self['local_channels'][chan_id] = chan_obj
return chan_obj
endfunction
""
" @dict VlimeConnection.RemoveLocalChannel
" @public
"
" Remove a local channel with the ID {chan_id}.
function! vlime#RemoveLocalChannel(chan_id) dict
call remove(self['local_channels'], a:chan_id)
endfunction
""
" @dict VlimeConnection.MakeRemoteChannel
" @usage {chan_id}
" @public
"
" Save the info for a remote channel (in the sense of SLIME channels).
" {chan_id} should be an ID assigned by the server.
function! vlime#MakeRemoteChannel(chan_id) dict
if has_key(self['remote_channels'], a:chan_id)
throw 'vlime#MakeRemoteChannel: channel ' . a:chan_id . ' already exists'
endif
let chan_obj = {'id': a:chan_id}
let self['remote_channels'][a:chan_id] = chan_obj
return chan_obj
endfunction
""
" @dict VlimeConnection.RemoveRemoteChannel
" @public
"
" Remove a remote channel with the ID {chan_id}
function! vlime#RemoveRemoteChannel(chan_id) dict
call remove(self['remote_channels'], a:chan_id)
endfunction
""
" @dict VlimeConnection.EmacsChannelSend
" @public
"
" Construct an :EMACS-CHANNEL-SEND message. {chan_id} should be the destination
" remote channel ID, and {msg} is the message to be sent. Note that, despite
" the word "Send" in its name, this function WILL NOT send the constructed
" message. You still need to call @function(VlimeConnection.Send) for that.
function! vlime#EmacsChannelSend(chan_id, msg) dict
if !has_key(self['remote_channels'], a:chan_id)
throw 'vlime#EmacsChannelSend: channel ' . a:chan_id . ' does not exist'
else
return [vlime#KW('EMACS-CHANNEL-SEND'), a:chan_id, a:msg]
endif
endfunction
""
" @dict VlimeConnection.EmacsRex
" @public
"
" Construct an :EMACS-REX message, with the current package and the current
" thread.
" {cmd} should be a raw :EMACS-REX command.
function! vlime#EmacsRex(cmd) dict
let pkg_info = self.GetCurrentPackage()
if type(pkg_info) != v:t_list
let pkg = v:null
else
let pkg = pkg_info[0]
endif
return s:EmacsRex(a:cmd, pkg, self.GetCurrentThread())
endfunction
""
" @dict VlimeConnection.Ping
" @public
"
" Send a PING request to the server, and wait for the reply.
function! vlime#Ping() dict
let cur_tag = self.ping_tag
let self.ping_tag = (self.ping_tag >= 65536) ? 1 : (self.ping_tag + 1)
let result = self.Call(self.EmacsRex([vlime#SYM('SWANK', 'PING'), cur_tag]))
if type(result) == v:t_string && len(result) == 0
" Error or timeout
throw 'vlime#Ping: failed'
endif
call s:CheckReturnStatus(result, 'vlime#Ping')
if result[1][1] != cur_tag
throw 'vlime#Ping: bad tag'
endif
endfunction
""
" @dict VlimeConnection.Pong
" @private
"
" Reply to server PING messages.
" {thread} and {ttag} are parameters received in the PING message from the
" server.
function! vlime#Pong(thread, ttag) dict
call self.Send([vlime#KW('EMACS-PONG'), a:thread, a:ttag], v:null, 0)
endfunction
""
" @dict VlimeConnection.ConnectionInfo
" @usage [return_dict] [callback]
" @public
"
" Ask the server for some info regarding this connection, and optionally
" register a [callback] function to handle the result.
"
" If [return_dict] is specified and |TRUE|, this method will convert the
" result to a dictionary before passing it to the [callback] function.
function! vlime#ConnectionInfo(...) dict
" We pass local variables as extra arguments instead of
" using the 'closure' flag on inner functions, to prevent
" messed-up variable values caused by calling the outer
" function more than once.
function! s:ConnectionInfoCB(conn, Callback, return_dict, chan, msg) abort
call s:CheckReturnStatus(a:msg, 'vlime#ConnectionInfo')
if a:return_dict
call s:TryToCall(a:Callback, [a:conn, vlime#PListToDict(a:msg[1][1])])
else
call s:TryToCall(a:Callback, [a:conn, a:msg[1][1]])
endif
endfunction
let return_dict = get(a:000, 0, v:true)
let Callback = get(a:000, 1, v:null)
call self.Send(self.EmacsRex([vlime#SYM('SWANK', 'CONNECTION-INFO')]),
\ function('s:ConnectionInfoCB', [self, Callback, return_dict]))
endfunction
""
" @dict VlimeConnection.SwankRequire
" @usage {contrib} [callback]
" @public
"
" Require Swank contrib modules, and optionally register a [callback] function
" to handle the result.
"
" {contrib} can be a string or a list of strings. Each string is a contrib
" module name. These names are case-sensitive. Normally you should use
" uppercase.
"
" For example, "conn_obj.SwankRequire('SWANK-REPL')" tells Swank to load the
" SWANK-REPL contrib module, and "conn_obj.SwankRequire(['SWANK-REPL',
" 'SWANK-PRESENTATIONS'])" tells Swank to load both SWANK-REPL and
" SWANK-PRESENTATIONS.
function! vlime#SwankRequire(contrib, ...) dict
let Callback = get(a:000, 0, v:null)
if type(a:contrib) == v:t_list
let required = [vlime#SYM("COMMON-LISP", 'QUOTE'), map(copy(a:contrib), {k, v -> vlime#KW(v)})]
else
let required = vlime#KW(a:contrib)
endif
call self.Send(self.EmacsRex([vlime#SYM('SWANK', 'SWANK-REQUIRE'), required]),
\ function('vlime#SimpleSendCB', [self, Callback, 'vlime#SwankRequire']))
endfunction
""
" @dict VlimeConnection.Interrupt
" @public
"
" Interrupt {thread}.
" {thread} should be a numeric thread ID, or vlime#KW("REPL-THREAD")
" for the REPL thread. The debugger will be activated upon
" interruption.
function! vlime#Interrupt(thread) dict
call self.Send([vlime#KW('EMACS-INTERRUPT'), a:thread], v:null, 0)
endfunction
""
" @dict VlimeConnection.SLDBAbort
" @usage [callback]
" @public
"
" When the debugger is active, invoke the ABORT restart.
function! vlime#SLDBAbort(...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex([vlime#SYM('SWANK', 'SLDB-ABORT')]),
\ function('s:SLDBSendCB', [self, Callback, 'vlime#SLDBAbort']))
endfunction
""
" @dict VlimeConnection.SLDBBreak
" @usage {func_name} [callback]
" @public
"
" Set a breakpoint at entry to a function with the name {func_name}.
function! vlime#SLDBBreak(func_name, ...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex([vlime#SYM('SWANK', 'SLDB-BREAK'), a:func_name]),
\ function('vlime#SimpleSendCB',
\ [self, Callback, 'vlime#SLDBBreak']))
endfunction
""
" @dict VlimeConnection.SLDBContinue
" @usage [callback]
" @public
"
" When the debugger is active, invoke the CONTINUE restart.
function! vlime#SLDBContinue(...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex([vlime#SYM('SWANK', 'SLDB-CONTINUE')]),
\ function('s:SLDBSendCB', [self, Callback, 'vlime#SLDBContinue']))
endfunction
""
" @dict VlimeConnection.SLDBStep
" @usage {frame} [callback]
" @public
"
" When the debugger is active, enter stepping mode in {frame}.
" {frame} should be a valid frame number presented by the debugger.
function! vlime#SLDBStep(frame, ...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex([vlime#SYM('SWANK', 'SLDB-STEP'), a:frame]),
\ function('s:SLDBSendCB', [self, Callback, 'vlime#SLDBStep']))
endfunction
""
" @dict VlimeConnection.SLDBNext
" @usage {frame} [callback]
" @public
"
" When the debugger is active, step over the current function call in {frame}.
function! vlime#SLDBNext(frame, ...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex([vlime#SYM('SWANK', 'SLDB-NEXT'), a:frame]),
\ function('s:SLDBSendCB', [self, Callback, 'vlime#SLDBNext']))
endfunction
""
" @dict VlimeConnection.SLDBOut
" @usage {frame} [callback]
" @public
"
" When the debugger is active, step out of the current function in {frame}.
function! vlime#SLDBOut(frame, ...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex([vlime#SYM('SWANK', 'SLDB-OUT'), a:frame]),
\ function('s:SLDBSendCB', [self, Callback, 'vlime#SLDBOut']))
endfunction
""
" @dict VlimeConnection.SLDBReturnFromFrame
" @usage {frame} {str} [callback]
" @public
"
" When the debugger is active, evaluate {str} and return from {frame} with the
" evaluation result.
" {str} should be a plain string containing the lisp expression to be
" evaluated.
function! vlime#SLDBReturnFromFrame(frame, str, ...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex([vlime#SYM('SWANK', 'SLDB-RETURN-FROM-FRAME'), a:frame, a:str]),
\ function('s:SLDBSendCB',
\ [self, Callback, 'vlime#SLDBReturnFromFrame']))
endfunction
""
" @dict VlimeConnection.SLDBDisassemble
" @usage {frame} [callback]
" @public
"
" Disassemble the code for {frame}.
function! vlime#SLDBDisassemble(frame, ...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex([vlime#SYM('SWANK', 'SLDB-DISASSEMBLE'), a:frame]),
\ function('vlime#SimpleSendCB',
\ [self, Callback, 'vlime#SLDBDisassemble']))
endfunction
""
" @dict VlimeConnection.InvokeNthRestartForEmacs
" @usage {level} {restart} [callback]
" @public
"
" When the debugger is active, invoke a {restart} at {level}.
" {restart} should be a valid restart number, and {level} a valid debugger
" level.
function! vlime#InvokeNthRestartForEmacs(level, restart, ...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex(
\ [vlime#SYM('SWANK', 'INVOKE-NTH-RESTART-FOR-EMACS'), a:level, a:restart]),
\ function('s:SLDBSendCB', [self, Callback, 'vlime#InvokeNthRestartForEmacs']))
endfunction
""
" @dict VlimeConnection.RestartFrame
" @usage {frame} [callback]
" @public
"
" When the debugger is active, restart a {frame}.
function! vlime#RestartFrame(frame, ...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex(
\ [vlime#SYM('SWANK', 'RESTART-FRAME'), a:frame]),
\ function('s:SLDBSendCB',
\ [self, Callback, 'vlime#RestartFrame']))
endfunction
""
" @dict VlimeConnection.FrameLocalsAndCatchTags
" @usage {frame} [callback]
" @public
"
" When the debugger is active, get info about local variables and catch tags
" for {frame}.
function! vlime#FrameLocalsAndCatchTags(frame, ...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex(
\ [vlime#SYM('SWANK', 'FRAME-LOCALS-AND-CATCH-TAGS'), a:frame]),
\ function('vlime#SimpleSendCB',
\ [self, Callback, 'vlime#FrameLocalsAndCatchTags']))
endfunction
""
" @dict VlimeConnection.FrameSourceLocation
" @usage {frame} [callback]
" @public
"
" When the debugger is active, get the source location for {frame}.
function! vlime#FrameSourceLocation(frame, ...) dict
function! s:FrameSourceLocationCB(conn, Callback, chan, msg)
let msg_content = a:msg[1][1] " Remove :RETURN and :OK
call s:CheckReturnStatus(a:msg, 'vlime#FrameSourceLocation')
if msg_content[0] == vlime#KW('LOCATION')
let fixed_loc = a:conn.FixRemotePath(msg_content)
else
let fixed_loc = msg_content
endif
call s:TryToCall(a:Callback, [a:conn, fixed_loc])
endfunction
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex(
\ [vlime#SYM('SWANK', 'FRAME-SOURCE-LOCATION'), a:frame]),
\ function('s:FrameSourceLocationCB', [self, Callback]))
endfunction
""
" @dict VlimeConnection.EvalStringInFrame
" @usage {str} {frame} {package} [callback]
" @public
"
" When the debugger is active, evaluate {str} in {package}, and within the
" context of {frame}.
function! vlime#EvalStringInFrame(str, frame, package, ...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex(
\ [vlime#SYM('SWANK', 'EVAL-STRING-IN-FRAME'),
\ a:str, a:frame, a:package]),
\ function('vlime#SimpleSendCB',
\ [self, Callback, 'vlime#EvalStringInFrame']))
endfunction
""
" @dict VlimeConnection.InitInspector
" @usage {thing} [callback]
" @public
"
" Evaluate {thing} and start inspecting the evaluation result with the
" inspector.
" {thing} should be a plain string containing the lisp expression to be
" evaluated.
function! vlime#InitInspector(thing, ...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex(
\ [vlime#SYM('SWANK', 'INIT-INSPECTOR'), a:thing]),
\ function('vlime#SimpleSendCB',
\ [self, Callback, 'vlime#InitInspector']))
endfunction
""
" @dict VlimeConnection.InspectorReinspect
" @usage [callback]
" @public
"
" Reload the object being inspected, and update inspector states.
function! vlime#InspectorReinspect(...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex(
\ [vlime#SYM('SWANK', 'INSPECTOR-REINSPECT')]),
\ function('vlime#SimpleSendCB',
\ [self, Callback, 'vlime#InspectorReinspect']))
endfunction
""
" @dict VlimeConnection.InspectorRange
" @usage {r_start} {r_end} [callback]
" @public
"
" Pagination for inspector content.
" {r_start} is the first index to retrieve in the inspector content list.
" {r_end} is the last index plus one.
function! vlime#InspectorRange(r_start, r_end, ...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex(
\ [vlime#SYM('SWANK', 'INSPECTOR-RANGE'), a:r_start, a:r_end]),
\ function('vlime#SimpleSendCB',
\ [self, Callback, 'vlime#InspectorRange']))
endfunction
""
" @dict VlimeConnection.InspectNthPart
" @usage {nth} [callback]
" @public
"
" Inspect an object presented by the inspector.
" {nth} should be a valid part number presented by the inspector.
function! vlime#InspectNthPart(nth, ...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex(
\ [vlime#SYM('SWANK', 'INSPECT-NTH-PART'), a:nth]),
\ function('vlime#SimpleSendCB',
\ [self, Callback, 'vlime#InspectNthPart']))
endfunction
""
" @dict VlimeConnection.InspectorCallNthAction
" @usage {nth} [callback]
" @public
"
" Perform an action in the inspector.
" {nth} should be a valid action number presented by the inspector.
function! vlime#InspectorCallNthAction(nth, ...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex(
\ [vlime#SYM('SWANK', 'INSPECTOR-CALL-NTH-ACTION'), a:nth]),
\ function('vlime#SimpleSendCB',
\ [self, Callback, 'vlime#InspectorCallNthAction']))
endfunction
""
" @dict VlimeConnection.InspectorPop
" @usage [callback]
" @public
"
" Inspect the previous object in the stack of inspected objects.
function! vlime#InspectorPop(...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex(
\ [vlime#SYM('SWANK', 'INSPECTOR-POP')]),
\ function('vlime#SimpleSendCB',
\ [self, Callback, 'vlime#InspectorPop']))
endfunction
""
" @dict VlimeConnection.InspectorNext
" @usage [callback]
" @public
"
" Inspect the next object in the stack of inspected objects.
function! vlime#InspectorNext(...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex(
\ [vlime#SYM('SWANK', 'INSPECTOR-NEXT')]),
\ function('vlime#SimpleSendCB',
\ [self, Callback, 'vlime#InspectorNext']))
endfunction
""
" @dict VlimeConnection.InspectCurrentCondition
" @usage [callback]
" @public
"
" When the debugger is active, inspect the current condition.
function! vlime#InspectCurrentCondition(...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex(
\ [vlime#SYM('SWANK', 'INSPECT-CURRENT-CONDITION')]),
\ function('vlime#SimpleSendCB',
\ [self, Callback, 'vlime#InspectCurrentCondition']))
endfunction
""
" @dict VlimeConnection.InspectInFrame
" @usage {thing} {frame} [callback]
" @public
"
" When the debugger is active, evaluate {thing} in the context of {frame}, and
" start inspecting the evaluation result.
function! vlime#InspectInFrame(thing, frame, ...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex(
\ [vlime#SYM('SWANK', 'INSPECT-IN-FRAME'), a:thing, a:frame]),
\ function('vlime#SimpleSendCB',
\ [self, Callback, 'vlime#InspectInFrame']))
endfunction
""
" @dict VlimeConnection.InspectFrameVar
" @usage {var_num} {frame} [callback]
" @public
"
" When the debugger is active, inspect variable #{var_num} in the context of {frame}.
function! vlime#InspectFrameVar(var_num, frame, ...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex(
\ [vlime#SYM('SWANK', 'INSPECT-FRAME-VAR'), a:frame, a:var_num]),
\ function('vlime#SimpleSendCB',
\ [self, Callback, 'vlime#InspectFrameVar']))
endfunction
""
" @dict VlimeConnection.ListThreads
" @usage [callback]
" @public
"
" Get a list of running threads.
function! vlime#ListThreads(...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex(
\ [vlime#SYM('SWANK', 'LIST-THREADS')]),
\ function('vlime#SimpleSendCB',
\ [self, Callback, 'vlime#ListThreads']))
endfunction
""
" @dict VlimeConnection.KillNthThread
" @usage {nth} [callback]
" @public
"
" Kill a thread presented in the thread list.
" {nth} should be a valid index in the thread list, instead of a thread ID.
function! vlime#KillNthThread(nth, ...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex(
\ [vlime#SYM('SWANK', 'KILL-NTH-THREAD'), a:nth]),
\ function('vlime#SimpleSendCB',
\ [self, Callback, 'vlime#KillNthThread']))
endfunction
""
" @dict VlimeConnection.DebugNthThread
" @usage {nth} [callback]
" @public
"
" Activate the debugger in a thread presented in the thread list.
" {nth} should be a valid index in the thread list, instead of a thread ID.
function! vlime#DebugNthThread(nth, ...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex(
\ [vlime#SYM('SWANK', 'DEBUG-NTH-THREAD'), a:nth]),
\ function('vlime#SimpleSendCB',
\ [self, Callback, 'vlime#DebugNthThread']))
endfunction
""
" @dict VlimeConnection.UndefineFunction
" @usage {func_name} [callback]
" @public
"
" Undefine a function with the name {func_name}.
function! vlime#UndefineFunction(func_name, ...) dict
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex(
\ [vlime#SYM('SWANK', 'UNDEFINE-FUNCTION'), a:func_name]),
\ function('vlime#SimpleSendCB',
\ [self, Callback, 'vlime#UndefineFunction']))
endfunction
""
" @dict VlimeConnection.UninternSymbol
" @usage {sym_name} [package] [callback]
" @public
"
" Unintern a symbol with the name {sym_name}.
" {sym_name} should be a plain string containing the name of the symbol to be
" uninterned.
function! vlime#UninternSymbol(sym_name, ...) dict
let pkg = get(a:000, 0, v:null)
let Callback = get(a:000, 1, v:null)
if type(pkg) == type(v:null)
let pkg_info = self.GetCurrentPackage()
if type(pkg_info) == v:t_list
let pkg = pkg_info[0]
endif
endif
call self.Send(self.EmacsRex(
\ [vlime#SYM('SWANK', 'UNINTERN-SYMBOL'), a:sym_name, pkg]),
\ function('vlime#SimpleSendCB',
\ [self, Callback, 'vlime#UninternSymbol']))
endfunction
""
" @dict VlimeConnection.SetPackage
" @usage {package} [callback]
" @public
"
" Bind a Common Lisp package to the current buffer. See
" |vlime-current-package|.
function! vlime#SetPackage(package, ...) dict
function! s:SetPackageCB(conn, buf, Callback, chan, msg) abort
call s:CheckReturnStatus(a:msg, 'vlime#SetPackage')
call vlime#ui#WithBuffer(a:buf, function(a:conn.SetCurrentPackage, [a:msg[1][1]]))
call s:TryToCall(a:Callback, [a:conn, a:msg[1][1]])
endfunction
let Callback = get(a:000, 0, v:null)
call self.Send(self.EmacsRex([vlime#SYM('SWANK', 'SET-PACKAGE'), a:package]),