@@ -32,10 +32,17 @@ class Host(object):
3232 def __init__ (self , nvim ):
3333 """Set handlers for plugin_load/plugin_unload."""
3434 self .nvim = nvim
35+ self .nvim ._session .attached_buffers = {}
36+ # TODO: delet this
37+ self .nvim ._session .elog = []
3538 self ._specs = {}
3639 self ._loaded = {}
3740 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+ }
3946 self ._request_handlers = {
4047 'poll' : lambda : 'ok' ,
4148 'specs' : self ._on_specs_request ,
@@ -96,6 +103,7 @@ def _on_notification(self, name, args):
96103 """Handle a msgpack-rpc notification."""
97104 if IS_PYTHON3 :
98105 name = decode_if_bytes (name )
106+ self .nvim ._session .elog .append ([name ]+ args )
99107 handler = self ._notification_handlers .get (name , None )
100108 if not handler :
101109 msg = self ._missing_handler_error (name , 'notification' )
@@ -220,3 +228,22 @@ def _configure_nvim_for(self, obj):
220228 if decode :
221229 nvim = nvim .with_decode (decode )
222230 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