@@ -32,10 +32,17 @@ class Host(object):
32
32
def __init__ (self , nvim ):
33
33
"""Set handlers for plugin_load/plugin_unload."""
34
34
self .nvim = nvim
35
+ self .nvim ._session .attached_buffers = {}
36
+ # TODO: delet this
37
+ self .nvim ._session .elog = []
35
38
self ._specs = {}
36
39
self ._loaded = {}
37
40
self ._load_errors = {}
38
- self ._notification_handlers = {}
41
+ self ._notification_handlers = {
42
+ 'nvim_buf_lines_event' : self ._on_buf_lines ,
43
+ 'nvim_buf_changedtick_event' : self ._on_buf_changedtick ,
44
+ 'nvim_buf_detach_event' : self ._on_buf_detach ,
45
+ }
39
46
self ._request_handlers = {
40
47
'poll' : lambda : 'ok' ,
41
48
'specs' : self ._on_specs_request ,
@@ -96,6 +103,7 @@ def _on_notification(self, name, args):
96
103
"""Handle a msgpack-rpc notification."""
97
104
if IS_PYTHON3 :
98
105
name = decode_if_bytes (name )
106
+ self .nvim ._session .elog .append ([name ]+ args )
99
107
handler = self ._notification_handlers .get (name , None )
100
108
if not handler :
101
109
msg = self ._missing_handler_error (name , 'notification' )
@@ -220,3 +228,22 @@ def _configure_nvim_for(self, obj):
220
228
if decode :
221
229
nvim = nvim .with_decode (decode )
222
230
return nvim
231
+
232
+ def _on_buf_lines (self , buf , changedtick , first , last , data , more ):
233
+ a = self .nvim ._session .attached_buffers [buf .handle ]
234
+ a .lines [first :last ] = data
235
+ a .changedtick = changedtick
236
+ if more : return
237
+ for cb in a .callbacks :
238
+ cb (buf , changedtick , a .lines )
239
+
240
+ def _on_buf_changedtick (self , buf , changedtick ):
241
+ a = self .nvim ._session .attached_buffers [buf .handle ]
242
+ a .changedtick = changedtick
243
+ for cb in a .callbacks :
244
+ cb (buf , changedtick , a .lines )
245
+
246
+ def _on_buf_detach (self , buf , changedtick , first , last , data , more ):
247
+ del self .nvim ._session .attached_buffers [buf .handle ]
248
+ for cb in a .callbacks :
249
+ cb (buf , - 1 , None )
0 commit comments